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

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

Related

Celluloid 0.17.3 giving unexpected "undefined method" error

I have started using Celluloid gem this morning for that first time. I am following this Railscasts tutorial and trying to figure things out.
I have a class called "SomeClass" and it has only one method. Here is the code:
require 'celluloid'
class SomeClass
include Celluloid
def initialize(name)
#name = name
end
def assholify()
puts "#{#name} has become an ASSHOLE."
end
end
When I create new instances of the class and call its method (with a bang i.e. "assholify!"), I am getting the undefined method 'assholify!', error. But Celluloid is supposed to trigger the method asynchronously when it is called with a bang. So here is how I am calling the method:
names = ['John', 'Tom', 'Harry']
names.each do |name|
n = SomeClass.new name
n.assholify!
end
Here is the full backtrace of the error:
I, [2016-09-09T11:28:02.488618 #3682] INFO -- : Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
/home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/calls.rb:42:in `rescue in check': undefined method `assholify!' for #<SomeClass:0x10897dc> (NoMethodError)
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/calls.rb:39:in `check'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/calls.rb:26:in `dispatch'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/call/sync.rb:16:in `dispatch'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/cell.rb:50:in `block in dispatch'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/cell.rb:76:in `block in task'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:339:in `block in task'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/task.rb:44:in `block in initialize'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14:in `block in create'
from (celluloid):0:in `remote procedure call'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/call/sync.rb:45:in `value'
from /home/railsdev/.rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/proxy/sync.rb:22:in `method_missing'
from some_class.rb:18:in `block in <main>'
from some_class.rb:16:in `each'
from some_class.rb:16:in `<main>'
Why am I getting this error? Is it the right way to call the function? Also how do I get rid of Celluloid 0.17.3 is running in BACKPORTED mode. warning?
The undefined method error occurred because actor methods are not called with a bang in the recent versions of celluloid gem. Instead you call the method like this: n.async.assholify. So here is what the code should look like:
names = ['John', 'Tom', 'Harry']
names.each do |name|
n = SomeClass.new name
n.async.assholify # Instead of "n.assholify!"
end
For "Celluloid 0.17.0 is running in BACKPORTED mode" warning, take a look at this wiki. Backported Mode is the default, for a limited time. If you use require 'celluloid/current' instead of require 'celluloid', you should not see this warning.

How to define Ruby Test::Unit testcase with `must`

I had a test case of the following form:
require 'test/unit'
class SomeTests < Test::Unit::TestCase
def test_should_do_action
assert true
end
end
and have re-written it using must as suggested in the book A Test::Unit Trick to Know About:
require 'test/unit'
class SomeTests < Test::Unit::TestCase
must "do action" do
assert true
end
end
And when I run it, I get an undefined method 'must' error shown as follows:
SomeTests.rb:3:in `<class:SomeTests>': undefined method `must' for SomeTests:Class (NoMethodError) from
SomeTests.rb:2:in `<top (required)>' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb:9:in `each' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb:9:in `block in <main>' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb:4:in `select' from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb:4:in `<main>' rake aborted! Command failed with status (1): [ruby -w -I"lib" -I"/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0" "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/rake_test_loader.rb" "test/**/*Tests.rb" ]
Tasks: TOP => default => test (See full trace by running task with --trace)
I thought that must might be a part of minitest, so I required 'minitest/unit' instead, but I still get an error. I also assume that must keyword isn't part of rspec, which I'm not using yet.
How do I get this to work properly?
It looks like that method is not provided out of the box, but was developed by a third party. You need to add code described here.

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