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 Todo Items

JONATHAN PACHA
JONATHAN PACHA
12,039 Points

I'm running into 3 rspec failures and i cant figure them out

Here's my rspec

treehouse:~/projects/odot (master *) $ bin/rspec --format=documentation spec/features/todo_items/index_spec.rb

Viewing todo items displays item content when a todo list has items (FAILED - 1) displays no items when the todo list is empty (FAILED - 2) displays the title of the todo list (FAILED - 3)

Failures:

1) Viewing todo items displays item content when a todo list has items Failure/Error: visit "/todo_lists" ActionView::Template::Error: /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: unterminated string meets end of file /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: syntax error, unexpected end-of-input, expecting ')' # ./spec/features/todo_items/index_spec.rb:7:in visit_todo_list' # ./spec/features/todo_items/index_spec.rb:30:inblock (2 levels) in <top (required)>'

2) Viewing todo items displays no items when the todo list is empty Failure/Error: visit "/todo_lists" ActionView::Template::Error: /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: unterminated string meets end of file /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: syntax error, unexpected end-of-input, expecting ')' # ./spec/features/todo_items/index_spec.rb:7:in visit_todo_list' # ./spec/features/todo_items/index_spec.rb:22:inblock (2 levels) in <top (required)>'

3) Viewing todo items displays the title of the todo list Failure/Error: visit "/todo_lists" ActionView::Template::Error: /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: unterminated string meets end of file /home/treehouse/projects/odot/app/views/layouts/application.html.erb:12: syntax error, unexpected end-of-input, expecting ')' # ./spec/features/todo_items/index_spec.rb:7:in visit_todo_list' # ./spec/features/todo_items/index_spec.rb:15:inblock (2 levels) in <top (required)>'

Deprecation Warnings:


RSpec::Core::ExampleGroup#example is deprecated and will be removed in RSpec 3. There are a few options for what you can use instead:

  • rspec-core's DSL methods (it, before, after, let, subject, etc) now yield the example as a block argument, and that is the recommended way to access the current example from those contexts.
  • The current example is now exposed via RSpec.current_example, which is accessible from any context.
  • If you can't update the code at this call site (e.g. because it is in an extension gem), you can use this snippet to continue making this method available in RSpec 2.99 and RSpec 3:

    RSpec.configure do |c| c.expose_current_running_example_as :example end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')


RSpec::Core::ExampleGroup#example is deprecated and will be removed in RSpec 3. There are a few options for what you can use instead:

  • rspec-core's DSL methods (it, before, after, let, subject, etc) now yield the example as a block argument, and that is the recommended way to access the current example from those contexts.
  • The current example is now exposed via RSpec.current_example, which is accessible from any context.
  • If you can't update the code at this call site (e.g. because it is in an extension gem), you can use this snippet to continue making this method available in RSpec 2.99 and RSpec 3:

    RSpec.configure do |c| c.expose_current_running_example_as :example end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')

If you need more of the backtrace for any of these deprecations to identify where to make the necessary changes, you can configure config.raise_errors_for_deprecations!, and it will turn the deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.46951 seconds 3 examples, 3 failures

Failed examples:

rspec ./spec/features/todo_items/index_spec.rb:26 # Viewing todo items displays item content when a todo list has items rspec ./spec/features/todo_items/index_spec.rb:21 # Viewing todo items displays no items when the todo list is empty rspec ./spec/features/todo_items/index_spec.rb:14 # Viewing todo items displays the title of the todo list

and the cited code that the failure comes from

<!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>

JONATHAN PACHA
JONATHAN PACHA
12,039 Points

<!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 have to head out in a minute but I will try to get round to looking at this soon.

It might be worth editing your post to get rid of the deprecation warnings - they don't add much!

Steve.

1 Answer

Brandon Barrette
Brandon Barrette
20,485 Points

The error is here:

/home/treehouse/projects/odot/app/views/layouts/application.html.erb:12

Looks like here:

<!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>

Particularly this line:

<div class= "alert flash <%= type %">

Notice after type, the % is missing the closing tag:

<div class= "alert flash <%= type %>">

Simple typo that is not related to rspec at all.

Well spotted! :-)