Esad Hajdarevic
2007-Feb-13 15:22 UTC
[rspec-users] "should.be_in [values]" and "each_should_satisfy"
Hi! I just started using RSpec and have some question that I couldn''t find answers to. If I have a result that can have two valid values, is there a better way of writing the following assertion? [value1,value2].should_include actual Is there a more elegant way of performing should_satisfy on a collection, for example I currently use something like collection.each {|x| x.should_satisfy {|x| ... } } which is very ugly. Is there something like each_should_satisfy? Thanks, Esad
David Chelimsky
2007-Feb-14 00:27 UTC
[rspec-users] "should.be_in [values]" and "each_should_satisfy"
On 2/13/07, Esad Hajdarevic <esad at esse.at> wrote:> Hi! > > I just started using RSpec and have some question that I couldn''t find > answers to. > > If I have a result that can have two valid values, is there a better way > of writing > the following assertion? > > [value1,value2].should_include actualNo, but you''ll soon (0.8) be able to write your own custom expectation matchers. So you''d be able to write, for example: actual.should be_in(value1,value2)> > Is there a more elegant way of performing should_satisfy on a > collection, for > example I currently use something like collection.each {|x| > x.should_satisfy {|x| ... } } > which is very ugly. Is there something like each_should_satisfy?There''s not. Again, when 0.8 is released you''ll be able to right this yourself. Probably something like: collection.should satisfy_for_each { |x| ... } Coming soon.... Cheers, David> > Thanks, > > Esad > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Feb-14 00:27 UTC
[rspec-users] "should.be_in [values]" and "each_should_satisfy"
PS - you can do that now if you''re a trunkster. On 2/13/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 2/13/07, Esad Hajdarevic <esad at esse.at> wrote: > > Hi! > > > > I just started using RSpec and have some question that I couldn''t find > > answers to. > > > > If I have a result that can have two valid values, is there a better way > > of writing > > the following assertion? > > > > [value1,value2].should_include actual > > No, but you''ll soon (0.8) be able to write your own custom expectation > matchers. So you''d be able to write, for example: > > actual.should be_in(value1,value2) > > > > > Is there a more elegant way of performing should_satisfy on a > > collection, for > > example I currently use something like collection.each {|x| > > x.should_satisfy {|x| ... } } > > which is very ugly. Is there something like each_should_satisfy? > > There''s not. Again, when 0.8 is released you''ll be able to right this > yourself. Probably something like: > > collection.should satisfy_for_each { |x| ... } > > Coming soon.... > > Cheers, > David > > > > > > Thanks, > > > > Esad > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > rubyforge.org/mailman/listinfo/rspec-users > > >
David Chelimsky
2007-Feb-14 00:28 UTC
[rspec-users] "should.be_in [values]" and "each_should_satisfy"
PPS - s/right/write On 2/13/07, David Chelimsky <dchelimsky at gmail.com> wrote:> PS - you can do that now if you''re a trunkster. > > On 2/13/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 2/13/07, Esad Hajdarevic <esad at esse.at> wrote: > > > Hi! > > > > > > I just started using RSpec and have some question that I couldn''t find > > > answers to. > > > > > > If I have a result that can have two valid values, is there a better way > > > of writing > > > the following assertion? > > > > > > [value1,value2].should_include actual > > > > No, but you''ll soon (0.8) be able to write your own custom expectation > > matchers. So you''d be able to write, for example: > > > > actual.should be_in(value1,value2) > > > > > > > > Is there a more elegant way of performing should_satisfy on a > > > collection, for > > > example I currently use something like collection.each {|x| > > > x.should_satisfy {|x| ... } } > > > which is very ugly. Is there something like each_should_satisfy? > > > > There''s not. Again, when 0.8 is released you''ll be able to right this > > yourself. Probably something like: > > > > collection.should satisfy_for_each { |x| ... } > > > > Coming soon.... > > > > Cheers, > > David > > > > > > > > > > Thanks, > > > > > > Esad > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > rubyforge.org/mailman/listinfo/rspec-users > > > > > >