はじまりの大地
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@post = posts(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get posts_url, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create post" do
|
||||
assert_difference("Post.count") do
|
||||
post posts_url, params: { post: { body: @post.body, title: @post.title } }, as: :json
|
||||
end
|
||||
|
||||
assert_response :created
|
||||
end
|
||||
|
||||
test "should show post" do
|
||||
get post_url(@post), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update post" do
|
||||
patch post_url(@post), params: { post: { body: @post.body, title: @post.title } }, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should destroy post" do
|
||||
assert_difference("Post.count", -1) do
|
||||
delete post_url(@post), as: :json
|
||||
end
|
||||
|
||||
assert_response :no_content
|
||||
end
|
||||
end
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
title: MyString
|
||||
body: MyText
|
||||
|
||||
two:
|
||||
title: MyString
|
||||
body: MyText
|
||||
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class PostTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require_relative "../config/environment"
|
||||
require "rails/test_help"
|
||||
|
||||
module ActiveSupport
|
||||
class TestCase
|
||||
# Run tests in parallel with specified workers
|
||||
parallelize(workers: :number_of_processors)
|
||||
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user