my Rspec in rails suddenly got weird errors.
it said
Failure/Error: Unable to find (erb) to read failed line
NoMethodError:
undefined method `id' for nil:NilClass
# (erb):63:in `get_binding'
to most of my test spec and it said the same thing, any one can help me please? thank you :)
note: i`m using rspec-rails 3.4.2 and my version rails is 4.2.5.2
Related
When I try running the rspec file of a task of my ruby application by using the command
rspec /Users/priyanshu.sahoo/Desktop/Fk/ltl-worker/spec/tasks/four_kites_common/background_job/tasks/calculate_auto_delivery_appointment_time_task_spec.rb
I get this error.
An error occurred while loading spec_helper. - Did you mean?
rspec ./spec/spec_helper.rb Failure/Error: require 'simplecov' LoadError: cannot load such file -- simplecov
#./spec/spec_helper.rb:1:in `<top (required)>' No examples found.
This is my first time working with a rails application. Can anyone help me resolve this?
I am using ruby 2.7.5p203, rails 4.2.11.1
I installed exception_notifier gem following this http://railscasts.com/episodes/104-exception-notifications-revised. But when running rails s, I got this
/home/ruby-2.0.0-p195/gems/actionpack-3.2.13/lib/action_dispatch/middleware/stack.rb:43:in `build': undefined method `new' for ExceptionNotifier:Module (NoMethodError)
So I tried to Google this problem, and I found that I could use in my production.rb file this config.middleware.use ExceptionNotifier::Rack... insted of this config.middleware.use ExceptionNotifier...
But then I got this message:
uninitialized constant ExceptionNotifier::Rack (NameError)
How should I handle this gem installation ?
If you follow the link https://github.com/smartinez87/exception_notification indicated by #pdobb, you 'll find you have to use
ExceptionNotification::Rack
instead of
ExceptionNotifier::Rack
It's ExceptionNotification::Rack. ExceptionNotifier was for the pre-4.0 versions. See the Getting Started info here: https://github.com/smartinez87/exception_notification for the specifics.
When using kaminari with mongoid, I get the error
undefined method `page' for #<Mongoid::Contextual::Mongo:0x007fe48c195af0>
Not sure what is wrong. I even tried running
Item.page(params[:page])
and I get the error
NoMethodError: undefined method `page' for Item:Class
The gem is present in the Gemfile. Double checked.
I see you are using mongoid, in that case add to the Gemfile will_paginate_mongoid gem and run $ bundle
More info can be found here and here.
I am following a Rails tutorial and have to run rails console. I never had a issue with it before but now it doesn't run.
Here's the error.
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.11/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `generators' for
#<Rails::Railtie::Configuration:0x007ffc41d4a9a0> (NoMethodError)
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/rspec-rails-2.0.0.beta.18/lib/rspec-rails.rb:4:in `<class:Railtie>'
I noticed that your rspec gem is the same version as listed here: "rails generate rspec:install" seems to be failing
Maybe that will help.
I'm learning Rails with the awesome Ruby on Rails Tutorial by Michael Hartl. I'm on section 3.2.2 (Test Driven Development) in which I need to run the following command to run the rspec tests for my Rails project:
bundle exec rspec spec/
But it doesn't work. Instead I get this error:
/Users/mh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/
activerecord-3.1.3/lib/active_record/base.rb:1088:in `method_missing':
undefined method `mass_assignment_sanitizer=' for
ActiveRecord::Base:Class (NoMethodError)
I've tried reinstalling rspec and changing my Gemfile, but nothing appeases the undefined method error!
Did you downgrade from Rails 3.2 RC1? Comment out the following two lines from your development.rb:
config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
While m818's answer will solve the problem, you might still get errors if you are tyring to use deprecated methods elsewhere in your code.
I had the same problem, commenting out those lines got rid of some errors, but not all of them, anywhere I was using attr_accessible gave me the same error.
It turned out to be the `active_record' gem that was updated to 4.0 when I didn't want it to. Since I'm using a Padrino app, I had to do this in the Gemfile:
gem 'activerecord', '= 3.2.12', :require => "active_record"
That solved all issues and I didn't have to comment out the lines in database.rb.