Reputation: 9145
I'm getting:
Expected: {text: "Hello World"}
got: {:text => "Hello World"}
When the key is a symbol.
And
Expected: {text: "Hello World"}
got: {"text" => "Hello World"}
When the key is a string.
How can I output {text: "Hello World"}
?
My code:
@output = {} of Symbol => Output'
@output[name] = @buffer # name is a Symbol
language.parse("Hello World").should eq({ text: "Hello World" })
And to use a string I do:
@output = {} of String => Output'
@output[name.to_s] = @buffer # name is a Symbol
Upvotes: 0
Views: 48
Reputation: 191
Essentially, {text: "Hello World"}
is a NamedTuple, so you're comparing a Hash
to a NamedTuple
. What you need is {:text => "Hello World"}
or {"text" => "Hello World"}
. See the docs of Hash for details.
Upvotes: 2