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 trialJohn Stoveld
4,203 PointsErrors upon rake
Adventures in troubleshooting.
After a colossal fail with my spelling error earlier I now have the next item on my laundry list.
The following command :
bin/rake spec
spits out the following errors I am about to post.
Before you tell me what I need to do. I need to start learning to crawl before I can start jogging.
What do these errors mean? I figured out that the errors link to to the files and the line of code. What gets me is what is it telling me to fix?
JSs-MacBook-Pro:odot JS$ bin/rake spec
/Users/JS/.rvm/rubies/ruby-2.2.0/bin/ruby -S rspec ./spec/controllers/todo_lists_controller_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/models/todo_list_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in <top (required)> at /Users/JS/Documents/Projects/odot/config/environments/test.rb:16)
*........FFFFDEPRECATION WARNING: `named_routes.helpers` is deprecated, please use `route_defined?(route_name)` to see if a named route was defined. (called from block (4 levels) in <top (required)> at /Users/JS/Documents/Projects/odot/spec/controllers/todo_lists_controller_spec.rb:75)
FF...FFFFFFF..............*.
Pending:
TodoListsHelper add some examples to (or delete) /Users/JS/Documents/Projects/odot/spec/helpers/todo_lists_helper_spec.rb
# No reason given
# ./spec/helpers/todo_lists_helper_spec.rb:14
TodoList add some examples to (or delete) /Users/JS/Documents/Projects/odot/spec/models/todo_list_spec.rb
# No reason given
# ./spec/models/todo_list_spec.rb:4
Failures:
1) TodoListsController DELETE destroy destroys the requested todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:147:in `block (3 levels) in <top (required)>'
2) TodoListsController DELETE destroy redirects to the todo_lists list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:154:in `block (3 levels) in <top (required)>'
3) TodoListsController GET edit assigns the requested todo_list as @todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:58:in `block (3 levels) in <top (required)>'
4) TodoListsController POST create with valid params creates a new TodoList
Failure/Error: expect {
count should have been changed by 1, but was changed by 0
# ./spec/controllers/todo_lists_controller_spec.rb:67:in `block (4 levels) in <top (required)>'
5) TodoListsController POST create with valid params assigns a newly created todo_list as @todo_list
Failure/Error: assigns(:todo_list).should be_persisted
expected persisted? to return true, got false
# ./spec/controllers/todo_lists_controller_spec.rb:75:in `block (4 levels) in <top (required)>'
6) TodoListsController POST create with valid params redirects to the created todo_list
Failure/Error: response.should redirect_to(TodoList.last)
Expected response to be a <redirect>, but was <200>
# ./spec/controllers/todo_lists_controller_spec.rb:80:in `block (4 levels) in <top (required)>'
7) TodoListsController GET show assigns the requested todo_list as @todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:43:in `block (3 levels) in <top (required)>'
8) TodoListsController PUT update with valid params updates the requested todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:104:in `block (4 levels) in <top (required)>'
9) TodoListsController PUT update with valid params assigns the requested todo_list as @todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:114:in `block (4 levels) in <top (required)>'
10) TodoListsController PUT update with valid params redirects to the todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:120:in `block (4 levels) in <top (required)>'
11) TodoListsController PUT update with invalid params assigns the todo_list as @todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:128:in `block (4 levels) in <top (required)>'
12) TodoListsController PUT update with invalid params re-renders the 'edit' template
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:136:in `block (4 levels) in <top (required)>'
13) TodoListsController GET index assigns all todo_lists as @todo_lists
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:35:in `block (3 levels) in <top (required)>'
Next we have the warnings
I believe these are due to version updates and warnings of code malfunctioning in the future?
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 /Users/JS/.rvm/gems/ruby-2.2.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 /Users/JS/.rvm/gems/ruby-2.2.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/JS/Documents/Projects/odot/spec/views/todo_lists/new.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/JS/Documents/Projects/odot/spec/views/todo_lists/edit.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
`stub_model` is deprecated. Use the `rspec-activemodel-mocks` gem instead. Called from /Users/JS/Documents/Projects/odot/spec/views/todo_lists/show.html.erb_spec.rb:5:in `block (2 levels) in <top (required)>'.
Too many uses of deprecated '`stub_model`'. Pass `--deprecation-out` or set `config.deprecation_stream` to a file for full output.
--------------------------------------------------------------------------------
rspec-rails 3 will no longer automatically infer an example group's spec type
from the file location. You can explicitly opt-in to this feature using this
snippet:
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end
If you wish to manually label spec types via metadata you can safely ignore
this warning and continue upgrading to RSpec 3 without addressing it.
--------------------------------------------------------------------------------
Clearly the below are the errors - though it looks like it makes sense, I just dont know what needs to be changed.
Finished in 0.62342 seconds
41 examples, 13 failures, 2 pending
Failed examples:
rspec ./spec/controllers/todo_lists_controller_spec.rb:146 # TodoListsController DELETE destroy destroys the requested todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:153 # TodoListsController DELETE destroy redirects to the todo_lists list
rspec ./spec/controllers/todo_lists_controller_spec.rb:57 # TodoListsController GET edit assigns the requested todo_list as @todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:66 # TodoListsController POST create with valid params creates a new TodoList
rspec ./spec/controllers/todo_lists_controller_spec.rb:72 # TodoListsController POST create with valid params assigns a newly created todo_list as @todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:78 # TodoListsController POST create with valid params redirects to the created todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:42 # TodoListsController GET show assigns the requested todo_list as @todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:103 # TodoListsController PUT update with valid params updates the requested todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:113 # TodoListsController PUT update with valid params assigns the requested todo_list as @todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:119 # TodoListsController PUT update with valid params redirects to the todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:127 # TodoListsController PUT update with invalid params assigns the todo_list as @todo_list
rspec ./spec/controllers/todo_lists_controller_spec.rb:135 # TodoListsController PUT update with invalid params re-renders the 'edit' template
rspec ./spec/controllers/todo_lists_controller_spec.rb:34 # TodoListsController GET index assigns all todo_lists as @todo_lists
Randomized with seed 16979
/Users/JS/.rvm/rubies/ruby-2.2.0/bin/ruby -S rspec ./spec/controllers/todo_lists_controller_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/models/todo_list_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb failed
3 Answers
Brandon Barrette
20,485 PointsI'll walk you through the first error... after that you'll have to ask more specific questions.
1) TodoListsController DELETE destroy destroys the requested todo_list
Failure/Error: todo_list = TodoList.create! valid_attributes
ActiveRecord::UnknownAttributeError:
unknown attribute 'Description' for TodoList.
# ./spec/controllers/todo_lists_controller_spec.rb:147:in `block (3 levels) in <top (required)>'
The last line tells you where the error is:
# ./spec/controllers/todo_lists_controller_spec.rb:147:in `block (3 levels) in <top (required)>'
So it's in your todo_lists_controller spec on line 147. Then look above that line, it tells you what's wrong:
unknown attribute 'Description' for TodoList.
Without seeing your todo_list_controller_spec, I can only speculate what's wrong. But my guess is only 1 line of code is causing most of these errors (because notice each failure says "unknown attribute 'Description' for TodoList.") This means it is happening in one place that every test uses. My guess is the valid_attributes at the top of the page. I have a feeling it looks something like this:
let(:valid_attributes) { { "title" => "MyString", "Description" => "My Description" } }
When it should really be lowercase (all keys should be lowercase to match with the database)
let(:valid_attributes) { { "title" => "MyString", "description" => "My Description" } }
Hope that helps! Happy coding =)
Brandon Barrette
20,485 PointsOk, so what's happened is you are using the newest version of Rails (4.2.0) but using the old version of Rspec (2.0). Rails 4.2 requires Rspec 3.1
So here's what you are going to do. Go to your Gemfile and change the following and add a new gem:
gem 'rails', '4.1.8'
# development, test
gem 'rspec-rails', '~> 2.9'
gem 'rspec-activemodel-mocks' # THIS ONE IS NEW
# test
gem 'capybara', '~> 2.1.0'
Then run
bundle update
Then run your bin/rspec.. You will still get some depreciation warnings. Read them, and follow the instructions to change your spec_helper.rb file and they will go away. Open a new forum discussion if you have questions about those depreciations.
gusf
11,070 PointsThank you Brandon Barrete, i spent like 5 hours trying to solve my tests failures when bin/rake spec. Finally i followed your instructions and it all worked!
Thanx!
John Stoveld
4,203 PointsJohn Stoveld
4,203 PointsHey Brandon -
Didnt see this til Just now. Ill look at all of this today around 6est. Thanks for taking the time to point this all out.
John Stoveld
4,203 PointsJohn Stoveld
4,203 PointsFrustration up the wazoo.
Just tried to go back to the project after not touching it for a while. rails server command now dies:
Im baffled.
If youd like to look at what I have for code its hosted here:
https://github.com/jstoveld/odot
What a pain in the butt.
John Stoveld
4,203 PointsJohn Stoveld
4,203 PointsSo Im still getting a series of errors on this.
Re bundled and what not - and this is what my todo_lists_controller_spec looks like (Please note the S on the end... would this be my issue?)