sorry if this gets posted twice. I accidentally sent this before I was confirmed for the mailing list.
On Thu, May 2, 2013 at 5:11 PM, Kwasi Mensah <kwasi.men...@gmail.com> wrote: > I'm having trouble with one of my rspecs and it's coming down to the tests > being confused about what the subject is. Here's an example spec and the > corresponding test failures I get: > > describe "HashBug" do > before do > @test_hash = {"foobar" => ["a", "b", "c"]} > end > describe "Test fails" do > it do > @test_hash["foobar"].size should be 1 > end > end > > describe "Test passes" do > it do > @test_hash["foobar"][0].should eq "a" > end > end > end > > Failures: > > 1) HashBug Test fails > Failure/Error: @test_hash["foobar"].size should be 1 > > expected #<Fixnum:3> => 1 > got #<String:70131453842100> => "Test fails" > > Compared using equal?, which compares object identity, > but expected and actual are not the same object. Use > 'actual.should eq(expected)' if you don't care about > object identity in this example. > # ./spec/requests/test_hash_bug_spec.rb:7:in `block (3 levels) in > <top (required)>' > > Finished in 0.00215 seconds > 2 examples, 1 failure > > Failed examples: > > rspec ./spec/requests/test_hash_bug_spec.rb:6 # HashBug Test fails > > > I'm not clear on why the match fails with one level of using [] but passes > with two levels. > > I'm using the command: > bundle exec rspec spec/requests/test_hash_bug_spec.rb > > I'm using the following rspec gems: > rspec (2.11.0) > rspec-core (2.11.1) > rspec-expectations (2.11.3) > rspec-mocks (2.11.3) > rspec-rails (2.11.0) > > And I can provide my full gem list if needed. > > Kwasi >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users