[rspec-devel] [ rspec-Bugs-10534 ] Windows: undefined method `controller_name'

noreply at rubyforge.org noreply at rubyforge.org
Sun May 6 07:52:55 EDT 2007

Bugs item #10534, was opened at 2007-05-02 23:52
You can respond by visiting: 

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Larry Kluger (larrykluger)
Assigned to: Nobody (None)
Summary: Windows: undefined method `controller_name' 

Initial Comment:
Running 0.9.1 on windows -- (InstantRails with updated rails and other gems) gives following trace (below).

I have updated to all the latest gems and plugins as of today, May 2, 07.

The exact same svn tree on Linux works fine for rake spec

I think something is not requiring the right modules due to Window's back slashes.




Trace followed by list of installed gems

> rake spec

C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/dsl/behaviour_eval.rb:95:in `method_missing': undefined method `controller_name' for #<Spec::DSL::EvalModule:0x47b489c> (NoMethodError)
        from ./spec/controllers/session_controller_spec.rb:4
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/dsl/
behaviour.rb:47:in `class_eval'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/dsl/
behaviour.rb:47:in `eval_behaviour'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/dsl/
behaviour.rb:29:in `initialize'
        from C:/instant_rails_1.7/InstantRails/rails_apps/am2/vendor/plugins/rspec_on_rails/lib/spec
/dsl/behaviour_factory.rb:43:in `new'
        from C:/instant_rails_1.7/InstantRails/rails_apps/am2/vendor/plugins/rspec_on_rails/lib/spec
/dsl/behaviour_factory.rb:43:in `create'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/runn
er/extensions/kernel.rb:4:in `context'
        from ./spec/controllers/session_controller_spec.rb:3
         ... 14 levels...
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/runn
er/option_parser.rb:261:in `parse'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/runn
er/option_parser.rb:28:in `create_behaviour_runner'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib/spec/runn
er/command_line.rb:14:in `run'
        from C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/bin/spec:3
rake aborted!
Command ruby -I"C:/instant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/lib" "C:/i
nstant_rails_1.7/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.9.1/bin/spec" "spec/controllers/se
ssion_controller_spec.rb" "spec/controllers/users_controller_spec.rb" "spec/controllers/user_assets_
controller_spec.rb" "spec/helpers/user_assets_helper_spec.rb" "spec/helpers/user_assets_url_helpers_
spec.rb" "spec/models/asset_spec.rb" "spec/models/authenticated_base_spec.rb" "spec/models/user_spec
.rb" "spec/views/assets/edit_rhtml_spec.rb" "spec/views/assets/index_rhtml_spec.rb" "spec/views/asse
ts/new_rhtml_spec.rb" "spec/views/assets/show_rhtml_spec.rb" "spec/views/users/edit_rhtml_spec.rb" "
spec/views/users/index_rhtml_spec.rb" "spec/views/users/new_rhtml_spec.rb" "spec/views/users/show_rh
tml_spec.rb" --options "C:/instant_rails_1.7/InstantRails/rails_apps/am2/config/../spec/spec.opts"

C:\instant_rails_1.7\InstantRails\rails_apps\am2>gem list --local

*** LOCAL GEMS ***

actionmailer (1.3.3)
    Service layer for easy email delivery and testing.

actionpack (1.13.3)
    Web-flow and rendering framework putting the VC in MVC.

actionwebservice (1.2.3)
    Web service support for Action Pack.

activerecord (1.15.3)
    Implements the ActiveRecord pattern for ORM.

activesupport (1.4.2)
    Support and utility classes used by the Rails framework.

capistrano (1.4.1)
    Capistrano is a framework and utility for executing commands in
    parallel on multiple remote machines, via SSH. The primary goal is
    to simplify and automate the deployment of web applications.

cgi_multipart_eof_fix (2.1)
    Fix an exploitable bug in CGI multipart parsing which affects Ruby
    <= 1.8.5 when multipart boundary attribute contains a non-halting
    regular expression string.

cmdparse (2.0.2)
    Advanced command line parser supporting commands

fxri (0.3.6)
    Graphical interface to the RI documentation, with search engine.

fxruby (1.6.6)
    FXRuby is the Ruby binding to the FOX GUI toolkit.

gem_plugin (0.2.2)
    A plugin system based only on rubygems that uses dependencies only

highline (1.2.7)
    HighLine is a high-level command-line IO library.

hpricot (0.4)
    a swift, liberal HTML parser with a fantastic library

log4r (1.0.5)
    Log4r is a comprehensive and flexible logging library for Ruby.

mongrel (1.0.1)
    A small fast HTTP library and server that runs Rails, Camping, Nitro
    and Iowa apps.

mongrel_cluster (0.2.1)
    Mongrel plugin that provides commands and Capistrano tasks for
    managing multiple Mongrel processes.

mysql (2.7.3)
    A win32-native build of the MySQL API module for Ruby.

needle (1.3.0)
    Needle is a Dependency Injection/Inversion of Control container for
    Ruby. It supports both type-2 (setter) and type-3 (constructor)
    injection. It takes advantage of the dynamic nature of Ruby to
    provide a rich and flexible approach to injecting dependencies.

net-sftp (1.1.0)
    Net::SFTP is a pure-Ruby implementation of the SFTP client protocol.

net-ssh (1.0.10)
    Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.

piston (1.3.3)
    Piston is a utility that enables merge tracking of remote

rails (1.2.3)
    Web-application framework with template engine, control-flow layer,
    and ORM.

rake (0.7.2)
    Ruby based make-like utility.

rcov (
    Code coverage analysis tool for Ruby

rmagick (1.14.1)
    RMagick is an interface between the Ruby programming language and
    the ImageMagick and GraphicsMagick image processing libraries.

rspec (0.9.1, 0.8.2)
    RSpec-0.9.1 (r1880) - BDD for Ruby http://rspec.rubyforge.org/

sources (0.0.1)
    This package provides download sources for remote gem installation

win32-clipboard (0.4.1)
    A package for interacting with the Windows clipboard

win32-dir (0.3.1)
    Extra constants and methods for the Dir class on Windows.

win32-eventlog (0.4.3)
    Interface for the MS Windows Event Log.

win32-file (0.5.3)
    Extra or redefined methods for the File class on Windows.

win32-file-stat (1.2.3)
    A File::Stat class tailored to MS Windows

win32-process (0.5.1)
    Adds fork, wait, wait2, waitpid, waitpid2 and a special kill method

win32-sapi (0.1.3)
    An interface to the MS SAPI (Sound API) library.

win32-sound (0.4.0)
    A package for playing with sound on Windows.

win32console (1.0.8)
    A library giving the Win32 console ANSI escape sequence support.

windows-pr (0.6.2)
    Windows functions and constants predefined via Win32API


>Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-06 11:52

"However, I think maybe the call to caller might yield slightly different values on Windows and Linux/OS X."

Now THAT would make sense.

Larry, would you kindly apply the patch below, run `script/spec spec/controllers/session_controller_spec.rb` and show us the output?


Index: rspec_on_rails/lib/spec/dsl/behaviour_factory.rb
--- rspec_on_rails/lib/spec/dsl/behaviour_factory.rb    (revision 1893)
+++ rspec_on_rails/lib/spec/dsl/behaviour_factory.rb    (working copy)
@@ -31,6 +31,7 @@
         #   describe "name", :behaviour_type => :view ...
         def create(*args, &block)
           opts = Hash === args.last ? args.last : {}
+          puts opts[:spec_path]
           if opts[:shared]
             key = :default
           elsif opts[:behaviour_type]


Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-05-06 11:44

There shouldn't be any need to support Windows style paths with \. Ruby will always report forward slashes for paths, even on Windows.

I don't think Regexp support is different on Windows either, that would never slip through the Ruby community.

However, I think maybe the call to caller might yield slightly different values on Windows and Linux/OS X.


Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-06 11:12

Here's the regexp used to determine the path:


The (\/|\) is there to support /unix/style and \windows\style paths. This used be to expressed in 4 separate regexps and this release merged them into one. The specs that describe windows style paths still pass, but I'm running them on *nix. Could there be a difference in the way windows is handling regexps?

Also, please try this one windows as well:

script/spec spec/controllers/session_controller_spec.rb

and let us know if you get the same result.



Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-05-06 10:24

I think the source of this bug is in rspec_on_rails/lib/spec/rails/extensions/kernel.rb

This is where Spec::Rails tries to guess what kind of spec this is. Perhaps this behaves differently on windows?

Could you investigate this please?


Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-05-06 10:10

Hint: Spec::Rails mixes in different modules for specs depending on whether it thinks it is a model spec, controller spec, view spec or helper spec.

Your error tells me that the controller mixin wasn't included.

RSpec decides what to mix in by looking at the folder of your spec. If it's under spec/controllers this should happen automatically (and apparently this is buggy on windows).

Just to verify this theory (and work around it until a fix has been committed), you could try to be explicit about it:

describe MyController, :behaviour_type => :controller do


You can respond by visiting: 

More information about the rspec-devel mailing list