Sha256: 58e2c94ba188df3d176f0d579eea8b570790bd41f55abc45b519484b3552822d

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require "minitest_helper"

<% module_namespacing do -%>
class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
  before do
    @<%= singular_table_name %> = <%= table_name %>(:one)
  end

  def test_index
    get :index
    assert_response :success
    assert_not_nil assigns(:<%= table_name %>)
  end

  def test_new
    get :new
    assert_response :success
  end

  def test_create
    assert_difference('<%= class_name %>.count') do
      post :create, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
    end

    assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
  end

  def test_show
    get :show, <%= key_value :id, "@#{singular_table_name}.to_param" %>
    assert_response :success
  end

  def test_edit
    get :edit, <%= key_value :id, "@#{singular_table_name}.to_param" %>
    assert_response :success
  end

  def test_update
    put :update, <%= key_value :id, "@#{singular_table_name}.to_param" %>, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
    assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
  end

  def test_destroy
    assert_difference('<%= class_name %>.count', -1) do
      delete :destroy, <%= key_value :id, "@#{singular_table_name}.to_param" %>
    end

    assert_redirected_to <%= index_helper %>_path
  end
end
<% end -%>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-rails-0.0.6 lib/generators/mini_test/scaffold/templates/controller_test.rb