lib/generators/minitest/scaffold/templates/controller_spec.rb in minitest-rails-2.2.1 vs lib/generators/minitest/scaffold/templates/controller_spec.rb in minitest-rails-3.0.0.rc1

- old
+ new

@@ -1,47 +1,50 @@ require "test_helper" <% module_namespacing do -%> describe <%= controller_class_name %>Controller do - let(:<%= singular_table_name %>) { <%= table_name %> :one } + <%- if mountable_engine? -%> + include Engine.routes.url_helpers + <%- end -%> + let(:<%= singular_table_name %>) { <%= fixture_name %> :one } + it "gets index" do - get :index + get <%= index_helper %>_url value(response).must_be :success? - value(assigns(:<%= table_name %>)).wont_be :nil? end it "gets new" do - get :new + get <%= new_helper %> value(response).must_be :success? end it "creates <%= singular_table_name %>" do expect { - post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %> + post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> } }.must_change "<%= class_name %>.count" - must_redirect_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) + must_redirect_to <%= singular_table_name %>_path(<%= class_name %>.last) end it "shows <%= singular_table_name %>" do - get :show, id: <%= singular_table_name %> + get <%= show_helper %> value(response).must_be :success? end it "gets edit" do - get :edit, id: <%= singular_table_name %> + get <%= edit_helper %> value(response).must_be :success? end it "updates <%= singular_table_name %>" do - put :update, id: <%= singular_table_name %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> - must_redirect_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>)) + patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> } + must_redirect_to <%= singular_table_name %>_path(<%= "#{singular_table_name}" %>) end it "destroys <%= singular_table_name %>" do expect { - delete :destroy, id: <%= singular_table_name %> + delete <%= show_helper %> }.must_change "<%= class_name %>.count", -1 must_redirect_to <%= index_helper %>_path end end