I'm trying to spec a dead simple "show non-existent record should render
404" case, but it seems the RecordNotFound exception is making it
impossible for some reason.
#controller
def show
@event = Event.find(params[:id])
end
#spec - pretty much straight from the rspec site
before do
Event.stub!(:find)
get :show, :id => 'broken'
end
# passes
it "should not assign an event" do
assigns[:event].should == nil
end
# fails - expected 404 but got events/show
it "should render 404" do
response.should render_template("#{RAILS_ROOT}/public/404.html")
response.response_code.should == 404
end
#end spec
Because I'm stubbing find does that mean the RecordNotFound exception
doesn't happen and thus the 404 doesn't render? I tried stubbing and
using should_raise, and_raise, whatever the heck it is, but I just don't
get it, nothing seems to work. It behaves as expected when browser
tested! :O
I'm going to spontaneously combust!
[RSpec 1.1.2, Rails 2.0.2, ZenTest 3.8.0]
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users