Rspec any_instance stub causing error undefined method __rspec_original_dup - ruby

I'm trying to stub out a Class method for any instance of the class (via any_instance). My tests run through successfully, but at the end of the test when rspec is trying to reset the any_instance stub, it throws an error (Unable to find matching line from backtrace). Here's the apparent culprit line of code (removing it removes the error):
Confetti::Config.any_instance.stub(:write_info)
The full error is below. Seems like stub should've (but fails to) created the __rspec_original_dup method, and when the reset happens, it can't find the expected method.
Failure/Error: Unable to find matching line from backtrace
NameError:
undefined method `__rspec_original_dup' for class `Confetti::Config'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/any_instance.rb:73:in `alias_method'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/any_instance.rb:73:in `restore_dup'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/any_instance.rb:72:in `class_eval'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/any_instance.rb:72:in `restore_dup'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/any_instance.rb:46:in `rspec_reset'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/space.rb:17:in `reset_all'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/space.rb:16:in `each'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks/space.rb:16:in `reset_all'
# /Library/Ruby/Gems/1.8/gems/rspec-mocks-2.11.1/lib/rspec/mocks.rb:23:in `teardown'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/mocking/with_rspec.rb:18:in `teardown_mocks_for_rspec'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:308:in `run_after_each'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:119:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253:in `with_around_each_hooks'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374:in `run_examples'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `map'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in `report'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `autorun'
# /usr/bin/rspec:19

I solved this by simply using Rspec v2.10.0 instead of v2.11.0:
gem 'rspec', '~> 2.10.0'
From the links that Henrik provided, it sounds like they may release a bugfix for Rspec. Watch this issue for more information. In the meantime, downgrading solved the issue for me.
(Thanks for your work in helping me figure this out, Henrik.)

Related

TypeError: wrong argument type class (expected module) in rspec

i'm developing a simple net application (packed as a gem) to learn Ruby and TDD.
I have this class (receiver.rb):
require 'eventmachine'
class Receiver < EM::Connection
def initialize(port)
EM.run do
EM.open_datagram_socket('0.0.0.0', port, self)
end
end
end
And this test (receiver_spec.rb):
require "spec_helper"
require "net/receiver"
describe "Receiver" do
it "can istantiate" do
#rec = Receiver.new(500)
end
end
Anyway, when i run rspec it prints out this:
1) Receiver can istantiate
Failure/Error: #rec = Receiver.new(500)
TypeError:
wrong argument type Receiver (expected Module)
# /var/lib/gems/1.9.1/gems/eventmachine- 1.0.7/lib/eventmachine.rb:1535:in `include'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:1535:in `block in klass_from_handler'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:1535:in `initialize'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:1535:in `new'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:1535:in `klass_from_handler'
# /var/lib/gems/1.9.1/gems/eventmachine- 1.0.7/lib/eventmachine.rb:867:in `open_datagram_socket'
# ./lib/rppc/net/receiver.rb:9:in `block in initialize'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `call'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'
# /var/lib/gems/1.9.1/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'
# ./lib/rppc/net/receiver.rb:8:in `initialize'
# ./spec/net/receiver_spec.rb:6:in `new'
# ./spec/net/receiver_spec.rb:6:in `block (2 levels) in <top (required)>'
I'm quite new to the ruby environment, so if i missed something let me know.
I'm not sure what documentation you're working from, but it appears the open_datagram_socket requires a Module and cannot accept a Class as the third (handler) argument.
Per the comment in http://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine.open_datagram_socket, it appears this restriction may have been loosened in a later version of EventMachine

RSpec "Failure/Error: Unable to find matching line from backtrace" On every test

I am working through some Ruby problem sets. I'm using Ubuntu 14.04, rbenv 0.4.0-98-g13a474c, rspec 3.1.4, and ruby 2.0.0p353. I'm running into the following errors for every test I run and I'm hoping someone might be able to guide me in the right direction to a solution.
I have run rspec tests successfully in the past but I can't seem to figure out the issue with my current setup.
Here is the message I receive for every test I run:
6) age is an integer
Failure/Error: Unable to find matching line from backtrace
ArgumentError:
wrong number of arguments (0 for 1)
# /usr/lib/ruby/vendor_ruby/rspec/mocks.rb:10:in `setup'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/mocking_adapters/rspec.rb:19:in `setup_mocks_for_rspec'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:366:in `run_before_example'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:150:in `block in run'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:328:in `with_around_example_hooks'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:148:in `run'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:500:in `block in run_examples'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:496:in `map'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:496:in `run_examples'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:463:in `run'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `map'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block in run_specs'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/reporter.rb:53:in `report'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:107:in `run_specs'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:85:in `run'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:69:in `run'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:37:in `invoke'
# /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/exe/rspec:4:in `<top (required)>'
# /usr/local/bin/rspec:23:in `load'
# /usr/local/bin/rspec:23:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Edit: Here is an example of one of the spec files, however, the issue comes up on about 20 spec files. I know my solutions are correct and my peers aren't having the same issues I am:
first_name = "M"
last_name = "R"
age = 23
describe 'first_name' do
it "is defined as a local variable" do
expect(defined?(first_name)).to eq 'local-variable'
end
it "is a String" do
expect(first_name).to be_a String
end
end
describe 'last_name' do
it "is defined as a local variable" do
expect(defined?(last_name)).to eq 'local-variable'
end
it "be a String" do
expect(last_name).to be_a String
end
end
describe 'age' do
it "is defined as a local variable" do
expect(defined?(age)).to eq 'local-variable'
end
it "is an integer" do
expect(age).to be_a Fixnum
end
end

rspec bugs when trying to run rake

I'm trying to teach myself some ruby using the app academy tutorials and after doing the readings, installing rvm,rubygems and rspec2 when I even try to run the first most basic code (00_hello) with rake I get the whole error :
(in /home/deadpool/Documents/learn_ruby)
/home/deadpool/Documents/learn_ruby/rspec_config.rb:3:in `block in <top (required)>': undefined method `color=' for #<RSpec::Core::Configuration:0x0000000293dee0> (NoMethodError)
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core.rb:67:in `configure'
from /home/deadpool/Documents/learn_ruby/rspec_config.rb:1:in `<top (required)>'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:162:in `require'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:162:in `block in requires='
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:162:in `map'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration.rb:162:in `requires='
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration_options.rb:22:in `block in configure'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration_options.rb:21:in `each'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/configuration_options.rb:21:in `configure'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:17:in `run'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:in `run_in_process'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in `run'
from /home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
ruby -S bundle exec rspec -I/home/deadpool/Documents/learn_ruby/00_hello -I/home/deadpool/Documents/learn_ruby/00_hello/solution -f documentation -r ./rspec_config "/home/deadpool/Documents/learn_ruby/00_hello/hello_spec.rb" failed
/home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/rake_task.rb:117:in `rescue in block (2 levels) in initialize'
/home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/rake_task.rb:113:in `block (2 levels) in initialize'
/home/deadpool/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.0.0/lib/rspec/core/rake_task.rb:109:in `block in initialize'
Tasks: TOP => default => spec
(See full trace by running task with --trace)
I tried to google some of the errors, but with no success. I had previously another error with the rake file using rspec v2 and the current version is 3.0.0, so I had to install the older and I think it might be another setup problem. Thanks if someone can help me or direct me.
rspec_config.rb file :
RSpec.configure do |c|
c.fail_fast = true
c.color = true
end
hello.rb file:
def hello
"Hello!"
end
def greet(who)
"Hello, #{who}!"
end
UPDATE
Getting new error as :-
While I changed c.color = true to c.color_enabled = true
(in /home/deadpool/Documents/learn_ruby)
the hello function says hello (FAILED - 1)
Failures: 1) the hello function says hello Failure/Error:
Unable to find matching line from backtrace undefined method run_all' for []:Array
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/hooks.rb:116:inrun_hook_filtered'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:176:in eval_before_alls'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/example_group.rb:231:inrun'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in block (2 levels) in run'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:inmap'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:26:in block in run'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/reporter.rb:11:inreport'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/command_line.rb:23:in run'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:55:inrun_in_process'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:46:in run'
# /home/deadpool/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.0.0/lib/rspec/core/runner.rb:10:inblock in autorun'
UPDATE
hello_spec.rb file :
require "hello"
describe "the hello function" do
it "says hello" do
hello.should == "Hello!"
end
end
describe "the greet function" do
it "says hello to someone" do
greet("Alice").should == "Hello, Alice!"
end
it "says hello to someone else" do
greet("Bob").should == "Hello, Bob!"
end
end
UPDATE
So, I updated rspec to v3.0.0 and changed Rakefile gem 'rspec', '~>3.0.0' and c.color = true back. Everything is working now(getting some deprecation warnings, but nothing critical), getting the output that is in the tutorial. Guess I just had to updae my rspec and change the version in the Rakefile. Thank you so much :)
Your error log is showing you are in rspec-core-2.0.0 version and your error is saying -
rspec_config.rb:3:in `block in <top (required)>': undefined method `color=' for
#<RSpec::Core::Configuration:0x0000000293dee0> (NoMethodError)
Now Deprecate config options confirms that below versions of 2.99.0.rc1 / 2014-05-18 or 2.99.0 methods were - #color_enabled, #color_enabled= and #color?. Which are changed since 2.99.0 to #color, #color= and #color_enabled?.
I got the information from the changelog as I linked -
Deprecate #color_enabled, #color_enabled= and #color? in favour of #color, #color= and #color_enabled? output. (Jon Rowe)
Thus you need to write as
RSpec.configure do |c|
c.fail_fast = true
c.color_enabled = true
end
Regarding your new error, I found it as a bug undefined methodrun_all' for []:Array`. Which has been fixed in this patch. Check this Rspec issue.
My suggestion use Rspec 3.0, at least you will be happy. In this case revert the color_enabled to color.
Hope this would help you.

Error while upgrading from Rails 3.1 to Rails 3.2

Upgrade steps were performed as mentioned in http://guides.rubyonrails.org/3_2_release_notes.html
Right now I'm on Ruby 1.8.7 and Rails 3.1.x (using system ruby). I installed RVM with ruby 1.8.7 and added to rails 3.2 and then I get the following error:
[app]$ rails console
Faraday: you may want to install system_timer for reliable timeouts
$HOME/src/qbol/tapp/config/environment.rb:16:in `add': undefined method `>' for nil:NilClass (NoMethodError)
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb:55:in `add'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb:61:in `info'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activerecord-3.2.17/lib/active_record/railtie.rb:86
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `each'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activerecord-3.2.17/lib/active_record/railtie.rb:80
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `run_initializers'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `send'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
from $HOME/src/app/config/environment.rb:48
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in `load_dependency'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/application.rb:103:in `require_environment!'
from $HOME/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.17/lib/rails/commands.rb:40
from script/rails:6:in `require'
from script/rails:6
This is on my development box. Any idea why this is happening?
EDIT: Below is the environment.rb. The error is happening on the last line App::Application.initialize!
# Load the rails application
require File.expand_path('../application', __FILE__)
module ActiveSupport
class BufferedLogger
def self.current_user
Thread.current[:user]
end
def self.current_user=(user)
Thread.current[:user] = user
end
def add(severity, message = nil, progname = nil, &block)
return if #level > severity
message = (message || (block && block.call) || progname).to_s
level = {
0 => "DEBUG",
1 => "INFO ",
2 => "WARN ",
3 => "ERROR",
4 => "FATAL"
}[severity] || "UNKNOWN"
user=BufferedLogger.current_user
if(!user.nil?)
idstr = "uid:#{user.id}"
if !user.current_app_user.nil?
idstr.concat(", acid: #{user.current_app_user.account_id}")
end
else
idstr=""
end
message = "[%s: %s #{idstr}] %s" %
["#{level} pid: #{$$}", Time.now.strftime("%y-%m-%d %H:%M:%S"), message]
message = "#{message}\n" unless message[-1] == ?\n
buffer << message
auto_flush
message
end
end
end
# Initialize the rails application
App::Application.initialize!
The error is happening inside ActiveSupport::BufferedLogger#add method call and you appear to be monkey-patching this class. The internals of ActiveSupport::BufferedLogger have likely changing between the versions of Rails you're using.
Try removing all of the ActiveSupport::BufferedLogger code from your environment.rb to work past this error and get your app running. Then, if you still need the monkeypatch (don't know why), you'd have to rewrite it on top of the newer version of the class.

undefined method `infer_base_class_for_anonymous_controllers=' for #<RSpec::Core::Configuration:0x007f7fb3a62b80> (NoMethodError)

I'm currently on Chapter 7 of Hartl's Tutorial, and every time I run
bundle exec rspec spec/
the following results:
/Users/siciliana/sample_app/spec/spec_helper.rb:31:in `block in <top (required)>': undefined method `infer_base_class_for_anonymous_controllers=' for #<RSpec::Core::Configuration:0x007f7fb3a62b80> (NoMethodError)
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core.rb:79:in `configure'
from /Users/siciliana/sample_app/spec/spec_helper.rb:11:in `<top (required)>'
from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `require'
from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
Can someone please explain what is happening here to an absolute newbie?
spec_helper.rb :
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
#
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
I was getting the same error (although not following the tutorial).
I believe this setting requires 'rspec/rails'
My solution was to move the line
config.infer_base_class_for_anonymous_controllers = # whatever
From spec_helper.rb to rails_helper.rb.

Resources