[rspec-devel] [ rspec-Patches-11221 ] Autotest support does not work w/o Rails Gem installed

noreply at rubyforge.org noreply at rubyforge.org
Wed May 30 17:26:51 EDT 2007


Patches item #11221, was opened at 2007-05-30 05:47
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=11221&group_id=797

Category: rails plugin
Group: None
>Status: Closed
Resolution: Accepted
Priority: 3
Submitted By: Josh Knowles (joshknowles)
Assigned to: David Chelimsky (dchelimsky)
Summary: Autotest support does not work w/o Rails Gem installed

Initial Comment:
Currently autotest support only works if you have the Rails gem installed due to a call to require 'active_support' in rails_spec.rb.  This causes problems for those of us who "vendor everything" and don't have any gems installed as ActiveSupport is not loaded until environment.rb is called.

Attached patch removes the call to require, which doesn't appear to even be used.

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

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-30 21:26

Message:
Applied 2nd patch to r2061

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

Comment By: Josh Knowles (joshknowles)
Date: 2007-05-30 20:23

Message:
So I played around with this a bit at lunch and I believe I
have a solution that works for both gems and vendor. 
Jean-Michel Garnier can you test the newly attached patch
please?

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

Comment By: Josh Knowles (joshknowles)
Date: 2007-05-30 18:47

Message:
Ok I see the problem... I'm not using fixtures thus didn't notice the call the singularize.

Initial soltion off top of head is to check for vendor/rails otherwise fall back to gems.  Any better solutions?  If not I'll patch.

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

Comment By: Jean-Michel Garnier (garnierjm)
Date: 2007-05-30 18:28

Message:
I have a project using rspec 1.0.4 + ZenTest 3.6.0 and rspec_on_rails + rspec installed in my vendor/plugins.

My list of gems is in http://rafb.net/p/212ywT51.html

This patch caused me the following failure:
$ autotest
loading autotest/rails_rspec
./vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb:33:in `initialize': undefined method `singularize' for ".svn/text-base/user":String (NoMethodError)
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:395:in `tests_for_file'
        from ./vendor/plugins/rspec/lib/autotest/rspec.rb:19:in `tests_for_file'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:319:in `find_files_to_test'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:318:in `find_files_to_test'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:373:in `reset'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:164:in `run'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:123:in `run'
        from /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/autotest:48
        from /usr/bin/autotest:16

 it could not find the method `singularize' in the following code:
 def initialize # :nodoc:
    super
    @spec_command = "script/spec"
    @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor\/rails|previous_failures.txt)%
    @test_mappings = {
      %r%^(test|spec)/fixtures/(.*).yml% => proc { |_, m|
        ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
      },

When I put back the require 'active_support', I got everything worked as a charm, including my hook defined in .autotest

The fact I have rails 1.2.1 installed in my gems might be the reason why it did work.

I'd love to write a spec for this bug but I haven't got enough exp with ruby & rspec ... 

Any thought?



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

Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-30 05:54

Message:
Applied to r2060.

Gotta love the one-liner patch. Thanks!

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

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


More information about the rspec-devel mailing list