Hello. My question was solved by David's answer.
Thank you David! On Sat, Dec 18, 2010 at 12:44 AM, David Chelimsky <dchelim...@gmail.com> wrote: > > On Dec 17, 2010, at 8:12 AM, niku -E:) wrote: > >> Hello. >> My name is niku. >> >> I'm using rspec 2.2.1 >> >> /tmp% rspec --version >> 2.2.1 >> >> I tested http://gist.github.com/744935 and passed. >> >> /tmp% rspec stdout_spec.rb >> .. >> >> Finished in 0.00105 seconds >> 2 examples, 0 failures >> >> But I expected test fail. >> Because It's wrong order that argument of 'write' method. > > > Message expectations are not constrained by order unless you explicitly tell > them to be. This is documented for rspec-1 here: > http://rspec.info/documentation/mocks/message_expectations.html. The docs for > rspec-mocks-2 don't have this yet, but will soon. > > Basically, do this instead. > > it "puts 'foo' and 'bar'" do > mock = double("stdout") > mock.should_receive(:write).with("\n").ordered > mock.should_receive(:write).with("\n").ordered > mock.should_receive(:write).with("foo").ordered > mock.should_receive(:write).with("bar").ordered > $stdout = mock > > puts "foo" > puts "bar" > end > > HTH, > David > > > >> >> How do I check order of argument ? >> >> regards. >> _______________________________________________ >> rspec-users mailing list >> rspec-users@rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users