Я хочу проверить, проходит ли действие создания.
describe "#create" do
let!(:user){ create(:user) }
let!(:post){ create_list(:post, 3, user: user) }
context "authenticated user" do
it "adds a new post" do
post_params = FactoryBot.attributes_for(:post)
sign_in user
expect{ post :create, params: {post: post_params} }.to change(user.posts, :count).by(1)
end
end
end
, но моя ошибка
Failure/Error: expect{ post :create, params: {post: post_params} }.to change(user.posts, :count).by(1)
ArgumentError:
wrong number of arguments (given 2, expected 0)
posts_controller:
def create
@post = Post.new(post_params)
if params[:images]
if @post.save
params[:images].each do |img|
@post.photos.create(image: img)
end
else
end
redirect_to posts_path
flash[:notice] = "success"
else
redirect_to posts_path
flash[:alert] = "failure"
end
end