Skip to content

Instantly share code, notes, and snippets.

@hardbap
Forked from brookr/gist:76557
Created March 10, 2009 00:26
Show Gist options
  • Save hardbap/76582 to your computer and use it in GitHub Desktop.
Save hardbap/76582 to your computer and use it in GitHub Desktop.
survey_controller_test.rb:
context 'PUT to update for existing survey' do
setup do
@survey = Factory(:survey)
put :update, :id => @survey.to_param,
:survey => Factory.attributes_for(:survey)
end
should_set_the_flash_to /updated/i
should_redirect_to 'survey_path(@survey)'
end
context "given a survey" do
setup do
@survey = Factory(:survey)
end
context 'DELETE to destroy' do
setup do
delete :destroy, :id => @survey.to_param
end
should_change 'Survey.count', :from => 1, :to => 0
should_set_the_flash_to /deleted/i
should_redirect_to 'surveys_path'
end
end
$ rake test/functional/surveys_controller_test.rb
1) Failure:
test: DELETE to destroy should change "Survey.count" from 1 to 0. (SurveysControllerTest)
[/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/macros.rb:42:in `__bind_1236641961_459826'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `call'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `test: DELETE to destroy should change "Survey.count" from 1 to 0. '
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run']:
"Survey.count" did not originally match 1.
<1> expected to be
===
<0>.
2) Failure:
test: DELETE to destroy should set the flash to /deleted/i. (SurveysControllerTest)
[/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/assertions.rb:50:in `assert_accepts'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/macros.rb:39:in `__bind_1236641961_562145'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `call'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `test: DELETE to destroy should set the flash to /deleted/i. '
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run']:
Expected the flash to be set to /deleted/i, but no flash was set
3) Error:
test: PUT to update for existing survey should redirect to surveys_path(@survey). (SurveysControllerTest):
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in `extra_keys'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in `map'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in `extra_keys'
generated code (/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route.rb:154):3:in `generate'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:339:in `generate'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:208:in `rewrite_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:187:in `rewrite_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:165:in `rewrite'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:626:in `url_for'
(eval):18:in `surveys_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:469:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:469:in `method_missing'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/macros.rb:236:in `send'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/macros.rb:236:in `__bind_1236641962_106939'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/helpers.rb:40:in `call'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/helpers.rb:40:in `instantiate_variables_from_assigns'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/action_controller/macros.rb:235:in `__bind_1236641962_106939'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `call'
/Library/WebServer/Documents/radmatch/vendor/plugins/shoulda/lib/shoulda/context.rb:253:in `test: PUT to update for existing survey should redirect to surveys_path(@survey). '
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in `run'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment