Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Jacob Horn9,255 Points
application.html.erb edits case 2 failures when running bin/rake
I have created the following div on the application.html.erb file:
<div class="nav"> <h1><%= link_to "Odot", root_path %> </h1> <ul> <li><%= link_to "Todo Lists", todo_lists_path %></li> </ul> <br class="clear" /> </div>
1) Adding todo items displays the title of the todo list Failure/Error: within ("h1") do Capybara::Ambiguous: Ambiguous match, found 2 elements matching css "h1" # ./spec/features/todo_items/create_spec.rb:10:in `block (2 levels) in <top (required)>'
2) Viewing todo items displays the title of the todo list Failure/Error: within ("h1") do Capybara::Ambiguous: Ambiguous match, found 2 elements matching css "h1" # ./spec/features/todo_items/index_spec.rb:11:in `block (2 levels) in <top (required)>'
The application is running fine but I don't want to move forward with these errors
It's because we added an h1 in the nav bar. What I did was wrap my yield tag in a div with the class "container" and then change the first spec in index_spec.rb to from within("h1") to within(".container h1")
Here is the whole spec:
it "displays the title of the todo list" do visit_todo_list(todo_list) within(".container h1") do expect(page).to have_content(todo_list.title) end end
Maximiliane QuelCourses Plus Student 55,489 Points
The test seems to be confused whether to check the h1 in your application layout view or one in the 'app/views/todo_items/index.html.erb' and 'app/views/todo_items/new.html.erb' respectively.
Can you maybe post the it block with the line that causes the error from either the index or create spec? Also can you post the div where you yield in the application layout?