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 Adding Validations to Todo Items

Ed Fernandez
Ed Fernandez
13,245 Points

untouched spec file fails

In this lesson video, when running "rake" to validate all spec files, I get an error on a spec file that I did not modify.

The error message is:


Failures:

1) todo_lists/index renders a list of todo_lists Failure/Error: assert_select "tr>td", :text => "Title".to_s, :count => 2 MiniTest::Assertion: <Title> expected but was <Title MyText>.. <0> expected but was <2>. # ./spec/views/todo_lists/index.html.erb_spec.rb:20:in `block (2 levels) in <top (required)>'


The contents of the unmodified index.html.erb_spec.rb file are:


require 'spec_helper'

describe "todo_lists/index" do before(:each) do assign(:todo_lists, [ stub_model(TodoList, :title => "Title", :description => "MyText" ), stub_model(TodoList, :title => "Title", :description => "MyText" ) ]) end

it "renders a list of todo_lists" do render # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "tr>td", :text => "Title".to_s, :count => 2 assert_select "tr>td", :text => "MyText".to_s, :count => 2 end end


Has anyone else experienced this error? Any solutions?

Thanks.

1 Answer

Ed Fernandez
Ed Fernandez
13,245 Points

Ok, mystery solved.

The error had to do with forgetting to add a closing "</td>" after the "Title" field in my "/todo_lists/index.html.erb" file.