I am new to RSpec and I am trying to run “must == A || B”, but it ignores “B” and only compares with “A” (and thus fails when val is “B '):Sample.find(:all).map(&:param).each{|val| val.should == 'A'||'B'}
Sample.find(:all).map(&:param).each{|val| val.should == 'A'||'B'}
Does anyone know how I include "B" in the comparison?
['A', 'B'].should include(val)
This may lead to passing the spec, but is that what you want to check? What is the return value a member of the set? If so, then perhaps this is a good solution.
You can also do:
(x == A || x == B).should be_true
Sample.find(:all).map(&:param).each{ |val| ['A', 'B'].should.include?(value) }
.
, , :
Sample.exists?(:conditions => {:params => %w(A B)}).should_be_true