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 Generate a Scaffold

problems with bin/rake RAILS_ENV=test 4 failures 2 pending rspec woes

I had problems at this stage on Windows 8 as well, so I got everything back up to speed on Ubunto 14.04. I am posting the project on github for easier review.

I'm running the error below:

PC:~/Documents/odot$ bin/rake RAILS_ENV=test Warning: Running gem pristine --all to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring. /usr/bin/ruby2.2 -I/var/lib/gems/2.2.0/gems/rspec-core-3.2.3/lib:/var/lib/gems/2.2.0/gems/rspec-support-3.2.2/lib /var/lib/gems/2.2.0/gems/rspec-core-3.2.3/exe/rspec --pattern spec/**{,/*/**}/*_spec.rb

Randomized with seed 50605 .................FF.......F**F

Pending: (Failures listed here are expected and do not affect your suite's status)

1) TodoListsHelper add some examples to (or delete) /home/hoopsmooth/Documents/odot/spec/helpers/todo_lists_helper_spec.rb # Not yet implemented # ./spec/helpers/todo_lists_helper_spec.rb:14

2) TodoList add some examples to (or delete) /home/hoopsmooth/Documents/odot/spec/models/todo_list_spec.rb # Not yet implemented # ./spec/models/todo_list_spec.rb:4

Failures:

1) todo_lists/index renders a list of todo_lists Failure/Error: stub_model(TodoList, NoMethodError: undefined method stub_model' for #<RSpec::ExampleGroups::TodoListsIndex:0x000000080676d0> # /var/lib/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/assertions/routing.rb:171:inmethod_missing' # /var/lib/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/test_case.rb:271:in method_missing' # ./spec/views/todo_lists/index.html.erb_spec.rb:6:inblock (2 levels) in <top (required)>'

2) todo_lists/edit renders the edit todo_list form Failure/Error: @todo_list = assign(:todo_list, stub_model(TodoList, NoMethodError: undefined method stub_model' for #<RSpec::ExampleGroups::TodoListsEdit:0x000000041fe4e8> # /var/lib/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/assertions/routing.rb:171:inmethod_missing' # /var/lib/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/test_case.rb:271:in method_missing' # ./spec/views/todo_lists/edit.html.erb_spec.rb:5:inblock (2 levels) in <top (required)>'

3) todo_lists/show renders attributes in <p> Failure/Error: @todo_list = assign(:todo_list, stub_model(TodoList, NoMethodError: undefined method stub_model' for #<RSpec::ExampleGroups::TodoListsShow:0x000000080e04b8> # /var/lib/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/assertions/routing.rb:171:inmethod_missing' # /var/lib/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/test_case.rb:271:in method_missing' # ./spec/views/todo_lists/show.html.erb_spec.rb:5:inblock (2 levels) in <top (required)>'

4) todo_lists/new renders new todo_list form Failure/Error: assign(:todo_list, stub_model(TodoList, NoMethodError: undefined method stub_model' for #<RSpec::ExampleGroups::TodoListsNew:0x00000008107d38> # /var/lib/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/assertions/routing.rb:171:inmethod_missing' # /var/lib/gems/2.2.0/gems/actionview-4.2.1/lib/action_view/test_case.rb:271:in method_missing' # ./spec/views/todo_lists/new.html.erb_spec.rb:5:inblock (2 levels) in <top (required)>'

Deprecation Warnings:

Using any_instance from rspec-mocks' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should instead. Called from /home/hoopsmooth/Documents/odot/spec/controllers/todo_lists_controller_spec.rb:109:in `block (4 levels) in <top (required)>'.

Using should from rspec-expectations' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should with config.expect_with(:rspec) { |c| c.syntax = :should } instead. Called from /home/hoopsmooth/Documents/odot/spec/controllers/todo_lists_controller_spec.rb:116:in `block (4 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 1.18 seconds (files took 4.86 seconds to load) 30 examples, 4 failures, 2 pending

Failed examples:

rspec ./spec/views/todo_lists/index.html.erb_spec.rb:17 # todo_lists/index renders a list of todo_lists rspec ./spec/views/todo_lists/edit.html.erb_spec.rb:11 # todo_lists/edit renders the edit todo_list form rspec ./spec/views/todo_lists/show.html.erb_spec.rb:11 # todo_lists/show renders attributes in <p> rspec ./spec/views/todo_lists/new.html.erb_spec.rb:11 # todo_lists/new renders new todo_list form

Randomized with seed 50605

/usr/bin/ruby2.2 -I/var/lib/gems/2.2.0/gems/rspec-core-3.2.3/lib:/var/lib/gems/2.2.0/gems/rspec-support-3.2.2/lib /var/lib/gems/2.2.0/gems/rspec-core-3.2.3/exe/rspec --pattern spec/**{,/*/**}/*_spec.rb failed

1 Answer

Solved it myself, sorta. Stack Overflow helped a lot.

http://stackoverflow.com/questions/24059805/rspec-view-undefined-method-stub-model

essentially, i needed to add the gem rspec-activemodel-mocks 1.0.1 to my gemfile