Sha256: fadae45ef239cc05a4db769e709bb99e1fbd8446935ce0f14841f570f649d152

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

class <%= pluralize camelize(name) %>ControllerTest < FunctionalTestCase
  def setup
    <%= module_name %>::<%= camelize name %>.delete_all
  end

  def test_get_<%= name %>_by_id
    <%= name %> = <%= camelize name %>Factory.post

    get "/<%= pluralize name %>/#{<%= name %>._id}"
    assert_equal 200, last_response.status
  end

  def test_get_<%= pluralize name %>
    3.times { <%= camelize name %>Factory.post }

    get "/<%= pluralize name %>"
    assert_equal 200, last_response.status
  end

  def test_post_<%= pluralize name %>
    post "/<%= pluralize name %>", to_json(<%= camelize name %>Factory.attrs)
    assert_equal 201, last_response.status
  end

  def test_patch_<%= name %>_by_id
    <%= name %> = <%= camelize name %>Factory.post

    hash = {content: 'my content'}
    patch "/<%= pluralize name %>/#{<%= name %>._id}", to_json(hash)
    assert_equal 200, last_response.status
  end

  def test_delete_<%= name %>_by_id
    <%= name %> = <%= camelize name %>Factory.post

    delete "/<%= pluralize name %>/#{<%= name %>._id}"
    assert_equal 204, last_response.status
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
apimaster-0.1.4 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.1.3 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.1.2 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.1.1 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.0.7 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.0.6 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.0.5 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb
apimaster-0.0.4 lib/apimaster/generators/templates/test/functional/examples_controller_test.rb.erb