Good morning, I did what you told me, but the error persists. I'm using:
File:
authentication_helpers.rb
module AuthenticationHelpers
def sign_in_as!(user)
visit '/signin'
fill_in "Name", with: user.name
fill_in "Password", with: user.password
click_button 'Sign in'
expect(page).to have_content("Signed in successfully.")
end
end
RSpec.configure do |c|
c.include AuthenticationHelpers, type: :feature
end
The RSpec.configure of the | c | ... does not it include the entire test?
The file I am testing is as follows:
editing_tickets_spec.rb
require 'rails_helper'
require 'capybara / rails'
"Editing tickets" feature
let!(:project) { FactoryGirl.create(:project) }
let!(:user) { FactoryGirl.create(:user) }
let!(:ticket) do
ticket = FactoryGirl.create(:ticket, project: project)
ticket.update(user: user)
ticket
end
before do
sign_in_as!(user)
visit "/"
click_link project.name
click_link ticket.title
click_link "Edit Ticket"
end
scenario "Updating a ticket" do
fill_in "Title", with: "Make it really shiny!"
click_button "Update Ticket"
expect(page).to have_content "Ticket has been updated."
within("#ticket h2") do
expect(page).to have_content("Make it really shiny!")
end
expect(page).to_not have_content ticket.title
end
scenario "Updating a ticket with invalid information" do
fill_in "Title", with: ""
click_button "Update Ticket"
expect(page).to have_content("Ticket has not been updated.")
end
end
I already gave include and tried to also put the type:: feature feature and before, but nothing! this same error will always appear:
rodolfopeixoto@rodolfopeixoto-3IBit:~/portifolio/projeto/rails/ticketee$ rspec spec/features/editing_tickets_spec.rb
FF
Failures:
1) Editing tickets Updating a ticket
Failure / Error: sign_in_as! (User)
NoMethodError:
undefined method sign_in_as!' for #<RSpec::ExampleGroups::EditingTickets:0x007f199ed16e38>
# ./spec/features/editing_tickets_spec.rb:17:in
block (2 levels) in '
2) Editing tickets Updating a ticket with invalid information
Failure / Error: sign_in_as! (User)
NoMethodError:
undefined method sign_in_as!' for #<RSpec::ExampleGroups::EditingTickets:0x007f199ef569a0>
# ./spec/features/editing_tickets_spec.rb:17:in
block (2 levels) in '
Finished in 0.04161 seconds (files took 1.52 seconds to load)
2 examples, 2 failures
Failed examples:
rspec ./spec/features/editing_tickets_spec.rb:24 # Editing tickets Updating a ticket
rspec ./spec/features/editing_tickets_spec.rb:37 # Editing tickets Updating a ticket with invalid information
I am grateful my friend.