Good morning, I did what you told me, but the error persists. I am using:
Archive:
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
Rspec.configure from |c| ... does not include in the whole test?
The file I am performing the test is as follows:
editing_tickets_spec.Rb
require 'rails_helper'
require 'Capybara/Rails'
Feature "Editing tickets" from
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
already dei include and tried to put also the type: :Feature Feature and before, but nothing! always appears this same error:
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’m grateful my friend.
So, the problem I’m using in module, how would I call this module? or authenticationTest is already created automatically and I just need to include it in it?
– Rodolfo Peixoto
Give the include in the module
– user3603
Thank you very much, I got it solved! Actually I used a require 'support/authentication_helpers' The test passed! o/ But thanks again!
– Rodolfo Peixoto
@Rodolfopexy, with the
include AuthenticationHelper
didn’t work out?– user3603
It didn’t work! " / only when called by require the file it worked.
– Rodolfo Peixoto