require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb') describe "<%= @controller if @controller %>Controller" do # START GET index describe "GET index" do before do get "/<%= @pluralized %>" end it "should display the <%= @pluralized %> index page" do assert_match "This is the index page", body end end # END GET index # START GET show describe "GET show" do before do @<%= @singular %> = <%= @model %>.make! get "/<%= @pluralized %>/show/#{@<%= @singular %>.to_param}" end it "should display the <%= @pluralized %> show page" do assert_match "This is the show page", body end end # END GET show <% if @create_full -%> # START GET new describe "GET new" do before do get "/<%= @pluralized %>/new" end it "should display the <%= @pluralized %> new page" do assert_match "This is the new page", body end end # END GET new # START POST create describe "Post create" do before do @count = <%= @model %>.count post "/<%= @pluralized %>/create", :<%= @singular %> => <%= @model %>.make.attributes end it "should redirect to the show page" do assert_equal 302, last_response.status assert location.include?("/<%= @pluralized %>/show/") end it "should create a new <%= @singular %>" do assert_equal @count + 1, <%= @model %>.count end end # END POST create # START GET edit describe "GET edit" do before do @<%= @singular %> = <%= @model %>.make! get "/<%= @pluralized %>/edit/#{@<%= @singular %>.to_param}" end it "should display the <%= @pluralized %> edit page" do assert_match "This is the edit page", body end end # END GET edit # START PUT update describe "PUT update" do before do @<%= @singular %> = <%= @model %>.make! @count = <%= @model %>.count put "/<%= @pluralized %>/update/#{@<%= @singular %>.to_param}", :<%= @singular %> => <%= @model %>.make.attributes @updated_<%= @singular %> = <%= @model %>.find(@<%= @singular %>.to_param) end it "should redirect to the show page" do assert_equal 302, last_response.status assert location.include?("/<%= @pluralized %>/show/") end it "should not create a new <%= @singular %>" do assert_equal @count, <%= @model %>.count assert_equal @updated_<%= @singular %>.id, @<%= @singular %>.id end end # END PUT update # START DELETE destroy describe "on DELETE destroy" do before do @<%= @singular %> = <%= @model %>.make! @count = <%= @model %>.count delete "/<%= @pluralized %>/destroy/#{@<%= @singular %>.to_param}" end it "should redirect to the index page" do assert_equal 302, last_response.status end it "should delete the <%= @singular %>" do assert_equal(@count - 1, <%= @model %>.count) end end # END DELETE destroy <% end -%> end