Commit eef1ff210eef5e2f98a2e2000a3fed826368fe1e

Authored by Dan Croak
1 parent 7a7e6d8f

updated blitz

vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb
... ... @@ -46,28 +46,38 @@ end
46 46  
47 47 Then /^a standard "show" functional test for "posts" should be generated$/ do
48 48 assert_generated_file("test/functional/posts_controller_test.rb") do
49   - " context 'GET to show for existing post' do\n" <<
50   - " setup do\n" <<
51   - " @post = Factory(:post)\n" <<
52   - " get :show, :id => @post.to_param\n" <<
53   - " end\n\n" <<
54   - " should_assign_to :post, :equals => '@post'\n" <<
55   - " should_render_template :show\n" <<
56   - " should_respond_with :success\n" <<
  49 + " context 'GET to show for existing post' do\n" <<
  50 + " setup do\n" <<
  51 + " @post = Factory(:post)\n" <<
  52 + " Post.stubs(:find).returns(@post)\n" <<
  53 + " get :show, :id => @post.to_param\n" <<
  54 + " end\n\n" <<
  55 + " should 'find post' do\n" <<
  56 + " assert_received(Post, :find) do |expects|\n" <<
  57 + " expects.with(@post.id)\n" <<
  58 + " end\n" <<
  59 + " end\n\n" <<
  60 + " should_render_template :show\n" <<
  61 + " should_respond_with :success\n" <<
57 62 " end"
58 63 end
59 64 end
60 65  
61 66 Then /^a standard "edit" functional test for "posts" should be generated$/ do
62 67 assert_generated_file("test/functional/posts_controller_test.rb") do
63   - " context 'GET to edit for existing post' do\n" <<
64   - " setup do\n" <<
65   - " @post = Factory(:post)\n" <<
66   - " get :edit, :id => @post.to_param\n" <<
67   - " end\n\n" <<
68   - " should_assign_to(:post) { '@post' }\n" <<
69   - " should_render_template :edit\n" <<
70   - " should_respond_with :success\n" <<
  68 + " context 'GET to edit for existing post' do\n" <<
  69 + " setup do\n" <<
  70 + " @post = Factory(:post)\n" <<
  71 + " Post.stubs(:find).returns(@post)\n" <<
  72 + " get :edit, :id => @post.to_param\n" <<
  73 + " end\n\n" <<
  74 + " should 'find post' do\n" <<
  75 + " assert_received(Post, :find) do |expects|\n" <<
  76 + " expects.with(@post.id)\n" <<
  77 + " end\n" <<
  78 + " end\n\n" <<
  79 + " should_render_template :edit\n" <<
  80 + " should_respond_with :success\n" <<
71 81 " end"
72 82 end
73 83 end
... ...
vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb
... ... @@ -35,10 +35,16 @@ class &lt;%= class_name %&gt;ControllerTest &lt; ActionController::TestCase
35 35 context 'GET to show for existing <%= resource %>' do
36 36 setup do
37 37 @<%= resource %> = Factory(:<%= resource %>)
  38 + <%= resource_class %>.stubs(:find).returns(@<%= resource %>)
38 39 get :show, :id => @<%= resource %>.to_param
39 40 end
40 41  
41   - should_assign_to :<%= resource %>, :equals => '@<%= resource %>'
  42 + should 'find <%= resource %>' do
  43 + assert_received(<%= resource_class %>, :find) do |expects|
  44 + expects.with(@<%= resource %>.id)
  45 + end
  46 + end
  47 +
42 48 should_render_template :show
43 49 should_respond_with :success
44 50 end
... ... @@ -48,10 +54,16 @@ class &lt;%= class_name %&gt;ControllerTest &lt; ActionController::TestCase
48 54 context 'GET to edit for existing <%= resource %>' do
49 55 setup do
50 56 @<%= resource %> = Factory(:<%= resource %>)
  57 + <%= resource_class %>.stubs(:find).returns(@<%= resource %>)
51 58 get :edit, :id => @<%= resource %>.to_param
52 59 end
53 60  
54   - should_assign_to(:<%= resource %>( { @<%= resource %> }
  61 + should 'find <%= resource %>' do
  62 + assert_received(<%= resource_class %>, :find) do |expects|
  63 + expects.with(@<%= resource %>.id)
  64 + end
  65 + end
  66 +
55 67 should_render_template :edit
56 68 should_respond_with :success
57 69 end
... ...