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

Tong Vang
Tong Vang
9,926 Points

Testing Errors

Failures:

  1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: click_button "Creat Todo list"
     Capybara::ElementNotFound:
       Unable to find button "Creat Todo list"
     # ./spec/features/todo_lists/create_spec.rb:11:in `block (2 levels) in <top
 (required)>'

  2) Creating todo lists displays an error when the todo list has no title
     Failure/Error: click_button "Creat Todo list"
     Capybara::ElementNotFound:
       Unable to find button "Creat Todo list"
     # ./spec/features/todo_lists/create_spec.rb:25:in `block (2 levels) in <top
 (required)>'

Finished in 0.79305 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirect
s to the todo list index page on success
rspec ./spec/features/todo_lists/create_spec.rb:16 # Creating todo lists display
s an error when the todo list has no title

Randomized with seed 18206

My errors are totally different than Jason's. Help...

require 'spec_helper'

describe "Creating todo lists" do
    it "redirects to the todo list 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 "Creat Todo list"

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

    end 
    it "displays an error when the todo list has no title" do
        expect(TodoList.count).to eq(0)

        visit "/todo_lists"
        click_link "New Todo list"
        expect(page).to have_content("New todo_list")

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

        expect(page).to have_content("error")
        expect(TodoList.count).to eq(0)

        visit "/todo_lists"
        expect(page).to_not have_content("This is what I'm doing today.")
    end
end

These are the test codes..

2 Answers

Nick Fuller
Nick Fuller
9,027 Points

Capybara is case sensitive. Perhaps the text on the button in your view file does not match?

click_button "Creat Todo list"

you misspelled Create above twice. Maybe that will solve it.