I'm learning TDD and running some Feature tests and am having issues with a helper method.
I've pulled out the following method from the feature test:
todo_helper.rb
module Features
def create_todo(todo_title)
click_on "Add a new todo"
fill_in "Title", with: todo_title
click_on "Submit"
end
end
However, I'm getting the following error when I run the Feature Test.
Failures:
1) User creates todo successfully
Failure/Error: create_todo 'Buy Milk'
NoMethodError:
undefined method `create_todo' for # <RSpec::ExampleGroups::UserCreatesTodo:0x007fb1f351b150>
# ./spec/features/user_creates_todo_spec.rb:8:in `block (2 levels) in <top (required)>'
Finished in 0.34992 seconds (files took 2.01 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/features/user_creates_todo_spec.rb:5 # User creates todo successfully
I have two tests that are pulling this method and they are both failing. Here is the one above:
user_creates_todo_spec.rb
require "rails_helper"
feature "User creates todo" do
scenario "successfully" do
sign_in
create_todo 'Buy Milk'
expect(page).to have_css '.todos li', text: 'Buy Milk'
end
end
This is strange because I created another helper that I'm using for the sign_in method above and that is working fine, but can't figure out why the second one is not working. I isolated the create_todo method within the original feature and it passes within each Feature but not as a helper. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire