I'm new to feature tests and capybara, I have a real simple feature test right now and I can't get it to pass but I believe it's because of something I'm doing wrong writing the test. I'll post my test and let me know if anything jumps out at anyone and is a clear dev error. I think it's something I'm doing with the check?
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: "staff@example.com", password: "password")
fill_in "Email", with: "staff@example.com"
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
This is the error message I get.
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 staff@example.com 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