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 trialBrian Patterson
19,588 PointsNot getting the same error message as Jason
Not getting the same error message as Jason at 2.20 mins. The error message I am getting is Adding todo items displays an error with no content (FAILED - 1) is successful with valid content
Failures:
1) Adding todo items displays an error with no content Failure/Error: within("div.flash") do Capybara::ElementNotFound: Unable to find css "div.flash" # ./spec/features/todo_items/create_spec.rb:30:in `block (2 levels) in <top (required)>'
The code it relates to is :
require 'spec_helper'
describe "Adding todo items" do
let!(:todo_list) { TodoList.create(title: "Grocery list", description: "Groceries") }
def visit_todo_list(list)
visit "/todo_lists"
within "#todo_list_#{list.id}" do
click_link "List Items"
end
end
it "is successful with valid content" do
visit_todo_list(todo_list)
click_link "New Todo Item"
fill_in "Content", with: "Milk"
click_button "Save"
expect(page).to have_content("Added todo list item.")
within("ul.todo_items") do
expect(page).to have_content("Milk")
end
end
it "displays an error with no content" do
visit_todo_list(todo_list)
click_link "New Todo Item"
fill_in "Content", with: ""
click_button "Save"
within("div.flash") do
expect(page).to have_content("There was a problem adding that todolist item")
end
expect(page).to have_content("Content cant be blank")
end
end
1 Answer
Brian Patterson
19,588 PointsI think this might be the answer:
<!DOCTYPE html>
<html>
<head>
<title>Odot</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<% flash.each do |type, message| %>
<div class="alert flash <%= type %>">
<%= message %>
</div>
<% end %>
<%= yield %>
</body>
</html>
I didn't write the alert flash message properly.