kendog
2009-Aug-04 09:47 UTC
[rspec-users] A passing test that I expected be a fail - any suggestions please?
Just started to learn the basics of rspec. Before doing anything serious I wanted to get to know the set-up and commands to run tests. I''m pretty sure that is all OK now with respect to gems and my test environment. It will run the tests but it seems to get the wrong answer. I have a controller with a single action ''index''. I wanted to observe a failing test so I created a super-simple test as follows: require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') describe Test4Controller do describe "responding to show" do it "show should be successful" do get :show response.should be_success end end end There is NO action called ''show'' in my controller but the test passes successfully. On running the app the response code is 404 not 200. Could anyone please explain what''s happening.
David Chelimsky
2009-Aug-04 13:17 UTC
[rspec-users] A passing test that I expected be a fail - any suggestions please?
On Tue, Aug 4, 2009 at 4:47 AM, kendog<brian at kendog.freeserve.co.uk> wrote:> Just started to learn the basics of rspec. > Before doing anything serious I wanted to get to know the set-up and > commands to run tests. > I''m pretty sure that is all OK now with respect to gems and my test > environment. It will run the tests but it seems to get the wrong > answer. > > I have a controller with ?a single action ''index''. > > I wanted to observe a failing test so I created a super-simple test as > follows: > > require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') > > describe Test4Controller do > > describe "responding to show" dointegrate_views> ?it "show should be successful" do > ? ? ?get :show > ? ? ?response.should be_success > ? ?end > ?end > end > > There is NO action called ''show'' in my controller but the test passes > successfully. On running the app the response code is 404 not 200. > Could anyone please explain what''s happening.You''ve hit a bug in rspec-rails when running in the default isolation mode. https://rspec.lighthouseapp.com/projects/5645/tickets/860-rspec-rails-swallows-missing-action This will be fixed for the next release, but in the mean time you''ll get the expected behaviour if you add integrate_views at the top of the example group, as shown above. HTH, David