Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Write Our First Tests

Amanda Folson
Amanda Folson
1,050 Points

Potential test fix for those using Rails 4.1.7, Rspec 3.1.0, Capybara 2.4.4

This is more of an "I fixed this by doing $x and want to know if that's okay to do" sort of question.

I decided to use the latest version of these gems because I was feeling adventurous. When I tried to run the tests as written in the video, I received this error:

Failures:

  1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: visit "/todo_lists"
     NoMethodError:
       undefined method `visit' for #<RSpec::ExampleGroups::CreatingTodoLists:0x007fae13175520>
     # ./spec/features/todo_lists/create_spec.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.00061 seconds (files took 0.12594 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on success

In order to fix it, I had to remove require 'spec_helper' from spec_helper.rb and add require 'rails_helper' to the top of the test file. It simply wouldn't pass the test otherwise.

So my question is this: It appears to work just fine, but I don't know enough about Rails to be certain that this is the correct way to fix this. I know this doesn't follow the video exactly, but any input is appreciated. Thanks!

3 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Gems change a lot. If you look at older RSpec tutorials, they don't even resemble the ones you see in Treehouse videos. And RSpec changed a bit in version 3+. One of those changes was the require statement, so yeah, it is the correct fix :). Be prepared for other potential differences along the way compared to the videos. There were some syntax changes.

Amanda Folson
Amanda Folson
1,050 Points

Okay, awesome. Thanks for your help!

Jason Prior
Jason Prior
1,441 Points

I was receiving the same error and was getting pretty frustrated. This thread popped up as I was logging my question and resolved my problem. Thanks so much!