[rspec-devel] [ rspec-Bugs-6643 ] script/generate rspec_controller: invalid symbol generation for 'controller_name' for *modularized* controllers

noreply at rubyforge.org noreply at rubyforge.org
Mon Nov 13 05:14:53 EST 2006


Bugs item #6643, was opened at 2006-11-13 01:41
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6643&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Michal Bakowski (dr_bonzo)
Assigned to: Nobody (None)
Summary: script/generate rspec_controller: invalid symbol generation for 'controller_name' for *modularized* controllers

Initial Comment:
script/generate rspec_controller generates invalid symbol (parameter of 'controller_name') for MODULARIZED (ex. Admin::UserController) controllers.


Environment
-----------
rails 1.1.6
rpsec 0.7.2
zentest 3.4.1 (3.4.2 does not work with this rpsec :( )
rspec_rails rev 1100


How to reproduce bug
---------------------
$ rails test
$ cd test
$ ./script/plugin install svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_2/vendor/rspec_on_rails/vendor/plugins/rspec
$ ./script/generate rspec
$ ./script/generate rspec_controller 'admin/user' list # with user of single quotes, just as help says:

    # Modules Example:
    #     ./script/generate rspec_controller 'pets/dog' bark fetch



$ spec spec/controllers/admin/user_controller_spec.rb 
/usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:13:in `call': undefined local variable or method `user' for #<Spec::Runner::ContextEvalModule:0xb751bd5c> (NameError)
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:13:in `_method_missing'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/expectations/sugar.rb:9:in `method_missing'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.7.2/lib/spec/runner/context_eval.rb:37:in `method_missing'
        from ./spec/controllers/admin/user_controller_spec.rb:5


The  problem is with symbol for 'controller_name' generation:

$ cat spec/controllers/admin/user_controller_spec.rb  | grep controller_name
  controller_name :admin/user

Changing it to:
  controller_name :"admin/user"
or
  controller_name :"Admin::User"

solves this problem. 

Spec will pass only if you set up your database.yml and create appropriate databases.


--
Michal Bakowski

----------------------------------------------------------------------

>Comment By: Michal Bakowski (dr_bonzo)
Date: 2006-11-13 11:14

Message:
> Now THAT is an informative report.

Thanks :)


> It turns out that you can pass a String as well as a 
Symbol,
> so this might just be a matter of documentation:

But the problem is with generator, it should produce 
correct code.


$ ./script_generate rspec_controller "'with/module'"
wrong constant name 'with
$

also does not work.

--
Michal

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-13 05:23

Message:
Now THAT is an informative report. Thank you Michal.

It turns out that you can pass a String as well as a Symbol, so this might just be a matter of documentation:

controller_name :unmodularized
controller_name "unmodularized"
controller_name "with/module"

Thoughts?

David


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6643&group_id=797


More information about the rspec-devel mailing list