0
フィーチャテストとカピバラの新機能ですが、今は本当のシンプルな機能テストがありますが、それをパスすることはできませんが、テストを書くのが間違っている。私はテストを投稿し、誰かに何かが飛び出してきて、明確な開発者エラーであることを知らせます。私はそれが私が小切手でやっていることだと思う?「チェック」を使用しようとすると機能テストに失敗する
require "rails_helper"
RSpec.feature "Send a message" do
scenario "Staff can send a message" do
visit "/"
group = Group.create!(name: "Group A")
user = User.create!(email: "[email protected]", password: "password")
fill_in "Email", with: "[email protected]"
fill_in "Password", with: "password"
click_button "Sign in"
fill_in "Enter a Message:", with: "Test Message"
check("message_group_#{group.id}")
click_button "Send Message"
expect(page).to have_content("Messages on their way!")
end
これは私が得るエラーメッセージです。
Send a message Staff can send a message
Failure/Error: expect(page).to have_content("Messages on their way!")
expected to find text "Messages on their way!" in "Tulip Time Text Numbers Sent Messages Scheduled Messages Statistics [email protected] Logout SMS Notifications Use this form to send SMS notifications to Visitors, Staff or Volunteers. Enter a Message: Groups: Group A Scheduled Text Message:"
Message.rb
def create
@message = Message.create(message_params)
if @message.save
run_at_time = @message.send_at.present? ? @message.send_at : Time.zone.now
people = Person.in_groups(message_params[:group_ids])
if people.any?
people.each do |person|
person.delay(run_at: run_at_time).send_message(@message.body)
end
flash[:success] = "Messages on their way!"
end
redirect_to root_path
else
render "new"
end
end
あなたはこの小切手が問題だと思いますか?チェックが失敗した場合、Capybaraはその行にエラーを表示します。テストログをチェックして、どのパラメータが送信されているか確認してください。 –
ええ、それはチェックではありませんが、 。それはすべてのバリデーションを渡し、このコードは合格するはずです。 – Bitwise
コントローラコードとレスポンスの投稿HTML –