Sha256: 7168c5cced0abe45a9b8275605f2ffa8253ba70683f1129bf3fca78d496724d6

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
 
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
  context "GET to index" do
    setup { get :index }
    
    should_respond_with :success
    should_assign_to :<%= table_name %>
  end
 
  context "GET to new" do
    setup { get :new }
 
    should_respond_with :success
    should_render_template :new
    should_assign_to :<%= file_name %>
  end
 
  context 'POST to create' do
    setup do
      post :create, :<%= file_name %> => Factory.attributes_for(:<%= file_name %>)
      @<%= file_name %> = <%= class_name %>.find(:all).last
    end
    
    should_redirect_to '<%= file_name %>_path(@<%= file_name %>)'
  end
 
  context 'GET to show' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      get :show, :id => @<%= file_name %>.id
    end
    
    should_respond_with :success
    should_render_template :show
    should_assign_to :<%= file_name %>
  end
 
  context 'GET to edit' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      get :edit, :id => @<%= file_name %>.id
    end
    
    should_respond_with :success
    should_render_template :edit
    should_assign_to :<%= file_name %>
  end
 
  context 'PUT to update' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      put :update, :id => @<%= file_name %>.id, :<%= file_name %> => Factory.attributes_for(:<%= file_name %>)
    end
    
    should_redirect_to '<%= file_name %>_path(@<%= file_name %>)'
  end
 
  context 'DELETE to destroy' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      delete :destroy, :id => @<%= file_name %>.id
    end
    
    should_redirect_to '<%= table_name %>_path'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hardbap-coulda-0.4.0 generators/coulda_scaffold/templates/functional_test/shoulda_controller.rb