Reputation: 7138
Am trying to evaluating the below code using rspec.
Given :
# book = ...
Rails.logger.info book.inspect
The above code prints the value of return type is boolean
i.e {:foo=>false}
eval(book[:foo]).should be_false
but that doesn't seem to work. While trying to run rspec, it throws the following exception:
Failure/Error: eval(book[:foo]).should be_false TypeError: can't convert false into String
So, how can i evaluate a boolean to a method, such as my final result would be the equivalent ?
Upvotes: 0
Views: 589
Reputation: 8094
eval
executes passed argument interpreting it as Ruby code. What Ruby code do you think is contained in false
object?
eval(false) # cannot execute false object
eval("false") # executes a string and returns false object
see the difference?
i don't know what exactly are you testing but you could simply try
book[:foo].should be_false
Upvotes: 2