From eef1ff210eef5e2f98a2e2000a3fed826368fe1e Mon Sep 17 00:00:00 2001 From: Dan Croak Date: Mon, 17 Aug 2009 09:42:32 -0400 Subject: [PATCH] updated blitz --- vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb | 42 ++++++++++++++++++++++++++---------------- vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb | 16 ++++++++++++++-- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb b/vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb index dcaa8c3..f5c3a6b 100644 --- a/vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb +++ b/vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb @@ -46,28 +46,38 @@ end Then /^a standard "show" functional test for "posts" should be generated$/ do assert_generated_file("test/functional/posts_controller_test.rb") do - " context 'GET to show for existing post' do\n" << - " setup do\n" << - " @post = Factory(:post)\n" << - " get :show, :id => @post.to_param\n" << - " end\n\n" << - " should_assign_to :post, :equals => '@post'\n" << - " should_render_template :show\n" << - " should_respond_with :success\n" << + " context 'GET to show for existing post' do\n" << + " setup do\n" << + " @post = Factory(:post)\n" << + " Post.stubs(:find).returns(@post)\n" << + " get :show, :id => @post.to_param\n" << + " end\n\n" << + " should 'find post' do\n" << + " assert_received(Post, :find) do |expects|\n" << + " expects.with(@post.id)\n" << + " end\n" << + " end\n\n" << + " should_render_template :show\n" << + " should_respond_with :success\n" << " end" end end Then /^a standard "edit" functional test for "posts" should be generated$/ do assert_generated_file("test/functional/posts_controller_test.rb") do - " context 'GET to edit for existing post' do\n" << - " setup do\n" << - " @post = Factory(:post)\n" << - " get :edit, :id => @post.to_param\n" << - " end\n\n" << - " should_assign_to(:post) { '@post' }\n" << - " should_render_template :edit\n" << - " should_respond_with :success\n" << + " context 'GET to edit for existing post' do\n" << + " setup do\n" << + " @post = Factory(:post)\n" << + " Post.stubs(:find).returns(@post)\n" << + " get :edit, :id => @post.to_param\n" << + " end\n\n" << + " should 'find post' do\n" << + " assert_received(Post, :find) do |expects|\n" << + " expects.with(@post.id)\n" << + " end\n" << + " end\n\n" << + " should_render_template :edit\n" << + " should_respond_with :success\n" << " end" end end diff --git a/vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb b/vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb index 7db592c..58fadc1 100644 --- a/vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb +++ b/vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb @@ -35,10 +35,16 @@ class <%= class_name %>ControllerTest < ActionController::TestCase context 'GET to show for existing <%= resource %>' do setup do @<%= resource %> = Factory(:<%= resource %>) + <%= resource_class %>.stubs(:find).returns(@<%= resource %>) get :show, :id => @<%= resource %>.to_param end - should_assign_to :<%= resource %>, :equals => '@<%= resource %>' + should 'find <%= resource %>' do + assert_received(<%= resource_class %>, :find) do |expects| + expects.with(@<%= resource %>.id) + end + end + should_render_template :show should_respond_with :success end @@ -48,10 +54,16 @@ class <%= class_name %>ControllerTest < ActionController::TestCase context 'GET to edit for existing <%= resource %>' do setup do @<%= resource %> = Factory(:<%= resource %>) + <%= resource_class %>.stubs(:find).returns(@<%= resource %>) get :edit, :id => @<%= resource %>.to_param end - should_assign_to(:<%= resource %>( { @<%= resource %> } + should 'find <%= resource %>' do + assert_received(<%= resource_class %>, :find) do |expects| + expects.with(@<%= resource %>.id) + end + end + should_render_template :edit should_respond_with :success end -- libgit2 0.21.2