rspec/rspec-rails — Issue #508: Anonymous controller with namespaced controller fails with ArgumentError: wrong number of arguments (1 for 0)
Author: Nothus
Created: 2012-02-22 21:27:24+00:00
State: open

When I try to run this test:

```ruby
require 'spec_helper'

class Api::V1::BaseController < ApplicationController
before_filter :validate_developer_key

def validate_developer_key
true
end
end

describe Api::V1::BaseController do
context "before_filter" do
context "validate_developer_key" do
before :each do
@controller = controller(Api::V1::BaseController) do
def test_me
render :nothing => true
end
end
end

it "should call validate_developer_key" do
@controller.should_receive(:validate_developer_key)
get :test_me
end
end
# https://www.relishapp.com/rspec/rspec-rails/v/2-8/docs/controller-specs/anonymous-controller
#pending "Errors out"
end
end
```

I get:

```
ArgumentError: wrong number of arguments (1 for 0)
/Users/mvazquez/work/redrobot/platform/r2platform_server/spec/controllers/api/v1/base_controller_spec.rb:15:in `block (4 levels) in '
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:35:in `instance_eval'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:35:in `run_in'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `block in run_all'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `each'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `run_all'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:368:in `run_hook'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `block in run_before_each_hooks'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `each'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `run_before_each_hooks'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:217:in `run_before_each'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:79:in `block in run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
/Users/mvazquez/.rvm/gems/ruby-1.9.3-p0@r2platform_server/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

1 example, 1 failure, 0 passed

Finished in 0.078371 seconds

Process finished with exit code 1
```

ruby-1.9.3
rails-3.2.0
rspec-rails-2.8.1
rspec-2.8.0