I have a simple test like this:
require 'rails_helper'
RSpec.feature "Evaluating Questions" do
before do
puts "before"
@john = FactoryBot.create(:admin_user)
login_as(@john, :scope => :admin_user)
FactoryBot.create(:question)
QuestionStatus.create!(name: "Approved")
visit questions_path
end
scenario "A user evaluates a question correctly" do
puts "scenario"
visit questions_path
click_link "Evaluate"
select('Approved', :from => 'revision_history_question_status_id')
click_button "Create Revision history"
expect(page).to have_content("Question was successfully reviewed")
end
end
The problem is that "Evaluate" link is only showed if the user has the permission from cancan. But that user I'm creating on my factory has the permission. But still, rspec can't find the link on the page, so I guess it's not being rendered. Any ideas how to fix that? Thanks
EDIT:
Rspec error message: Failure/Error: click_link "Evaluate"
Capybara::ElementNotFound:
Unable to find visible link "Evaluate"
RSpec.feature "Evaluating Questions", js: true do
to run tests in browser to see if link is not visible for sure? – Hubert Jakubiak