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

Netguru S.A.
Netguru S.A.
10,461 Points

bin/rspec spec/features/todo_lists/create_spec.rb is executed but then fails

message recieved

Finished in 0.67304 seconds 1 example, 1 failure

Failed examples:

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

Randomized with seed 41395

2 Answers

Daniel Pointecker
Daniel Pointecker
19,593 Points

I struggled kind with the same problem yesterday. I don't know about your rails version but I'm on rails 5 and to fix this I had to delete the require 'rspec/autorun' from spec_helper.rb.

So the head of the file looks like this:

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara'

I also modified my gemfile and changed the requirements for rspec and capybara

group :development, :test do
    gem 'rspec-rails', '~> 3.5'
end

group :test do
    gem 'capybara', '~> 2.4'
end

then run bundler again in your terminal

In the create_spec.rb file be aware of any typos! I had to fix also some typos I had to get this running. e.g. I had

click_button "Create Todo List"

instead of

click_button "Create Todo list"

I hope this can help

Karen Ho
Karen Ho
10,190 Points

I'm using rails 5 too but there is no 'rspec/autorun' on spec_helper.rb

Did the >3.5 version changes and checked for typo indeed, after fixing the typos this works:

require 'spec_helper'

describe "Creating todo lists" do it "redirects to the todolist index page on success" do visit "/todo_lists" click_link "New Todo List" expect(page).to have_content("New Todo List")

    fill_in "Title", with: "My todo list"
    fill_in "Description", with: "This is what I'm doing today."
    click_button "Create Todo list"

    expect(page).to have_content("My todo list")
end

end