Sha256: c1cfd93440a4972ae359f612bff0283f6d0507ee78730f9e129a1e7b57f083a7

Contents?: true

Size: 960 Bytes

Versions: 4

Compression:

Stored size: 960 Bytes

Contents

require 'test_helper'

class BooksControllerTest < ActionDispatch::IntegrationTest
  setup do
    @book = books(:one)
  end

  test "should get index" do
    get books_url, as: :json
    assert_response :success
  end

  test "should create book" do
    assert_difference('Book.count') do
      post books_url, params: {
        book: {
          name: "test-book",
          label: "test-label",
          value: 1500
        }
      }, as: :json
    end

    assert_response 201
  end

  test "should show book" do
    get book_url(@book), as: :json
    assert_response :success
  end

  test "should update book" do
    patch book_url(@book), params: {
      book: {
        name: "test-book",
        label: "test-label",
        value: 1500
      }
    }, as: :json
    assert_response 200
  end

  test "should destroy book" do
    assert_difference('Book.count', -1) do
      delete book_url(@book), as: :json
    end

    assert_response 204
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yamls-0.2.0 example/rails5/test/controllers/books_controller_test.rb
yamls-0.1.4 example/rails5/test/controllers/books_controller_test.rb
yamls-0.1.3 example/rails5/test/controllers/books_controller_test.rb
yamls-0.1.2 example/rails5/test/controllers/books_controller_test.rb