Forum: RSpec rspec, rspec-rails 1.1.99-12 and script/spec 'no such file to load -- spec'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fad90847c8c55cd4e61513fbfc9bc227?d=identicon&s=25 rockrep (Guest)
on 2009-03-07 15:41
(Received via mailing list)
Hi David, all:

I just recently upgraded to Rails 2.3.1RC2 (Mac OS.X 10.5.6, ruby
1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9])  and have been
dilligently following the instructions for upgrading rspec and rspec-
rails according to:
http://wiki.github.com/dchelimsky/rspec/rails-with....
I have successfully built the rspec and rspec-rails gems, installed
and unpacked them, and ran script/generate rspec successfully.

'rake spec' works fine, however 'script/spec' fails with error:
$ script/spec spec
script/spec:3:in `require': no such file to load -- spec (LoadError)

script/spec looks like:
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../
vendor/plugins/rspec/lib"))
require 'spec'
exit ::Spec::Runner::CommandLine.run

and 'rake gems RAILS_ENV=test' returns:
 - [R] rspec >= 1.1.99.12
 - [F] rspec-rails >= 1.1.99.12
    - [R] rspec = 1.1.99.12
    - [F] rack = 0.9.1
    - [ ] cucumber >= 0.1.13
    - [ ] hoe >= 1.9.0

I = Installed
F = Frozen
R = Framework (loaded before rails starts)

rspec does not exist in vendor/gems, but rspec-rails does.  It seems
it's marked as 'R' which (1) I'm not certain I understand why, and (2)
seems to prevent unpacking into vendor/gems.   In any case, I would
like to resolve the issue with script/spec.

Since rspec is also not installed in vendor/plugins the LOAD_PATH line
in script/spec looks odd, but I'm not sure it's the cause.

Any pointers greatly appreciated.  Thanks,

Michael
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-03-07 16:40
(Received via mailing list)
On Fri, Mar 6, 2009 at 4:02 PM, rockrep <rockrep@gmail.com> wrote:
> $ script/spec spec
> script/spec:3:in `require': no such file to load -- spec (LoadError)
>
> script/spec looks like:
> #!/usr/bin/env ruby
> $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../
> vendor/plugins/rspec/lib"))

This bit is a bug that I plan to fix (today), but that's not the only
problem here.

>
> I = Installed
> F = Frozen
> R = Framework (loaded before rails starts)
>
> rspec does not exist in vendor/gems, but rspec-rails does.  It seems
> it's marked as 'R' which (1) I'm not certain I understand why, and (2)
> seems to prevent unpacking into vendor/gems.   In any case, I would
> like to resolve the issue with script/spec.

I've seen this with older versions of lib/tasks/rspec.rake that
required 'spec'. Basically, when you run any rake task in rails, rake
loads up the Rakefile in the project root *and* all of the .rake files
in lib/tasks before executing anything. So if any of those files
require 'spec', then the rails/gems framework will consider rspec to
be loaded already, and won't let you unpack it.

Try this:

rm lib/tasks/rspec.rake
rake gems RAILS_ENV='test'

If that changes rspec to [I], then you can unpack it and you should be
good to go.
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-03-07 18:38
(Received via mailing list)
On Sat, Mar 7, 2009 at 8:50 AM, David Chelimsky <dchelimsky@gmail.com>
wrote:
>> 'rake spec' works fine, however 'script/spec' fails with error:
>> $ script/spec spec
>> script/spec:3:in `require': no such file to load -- spec (LoadError)
>>
>> script/spec looks like:
>> #!/usr/bin/env ruby
>> $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../
>> vendor/plugins/rspec/lib"))
>
> This bit is a bug that I plan to fix (today), but that's not the only
> problem here.

This fixed and pushed to github

http://github.com/dchelimsky/rspec-rails/commit/cd...

>>    - [ ] hoe >= 1.9.0
Just an FYI about the listed dependencies - cucumber and hoe are
developer dependencies of rspec, so you don't need them to run rspec.
It looks like rails gem management system doesn't make that
distinction, and shows all dependencies regardless of type.
Fad90847c8c55cd4e61513fbfc9bc227?d=identicon&s=25 Michael K (Guest)
on 2009-03-08 21:49
(Received via mailing list)
Hi David,

Thanks for the quick reply, info, and patch.

>
> This fixed and pushed to github
>
> http://github.com/dchelimsky/rspec-rails/commit/cd......
>
>

> > rake gems RAILS_ENV='test'
>
> > If that changes rspec to [I], then you can unpack it and you should be
> > good to go.
>

I tried removing rspec.rake again as suggested, but it did not help,
and rspec would still not unpack using 'rake gems:unpack
RAILS_ENV=test'.   The rspec dependency of rspec-rails was marked as
'I', but it still had an 'R' next to the top-level rspec.  I also
tried removing uuidtools (and searched all the other .rake files in my
source tree for references to require 'spec') to see if that had any
effect since it lists a dependency on rspec, but that also did not
help.  I'm showing the full list of my RAILS_ENV=test gem dependencies
here in case the additional info helps.

 - [F] uuidtools
    - [I] rake = 0.8.3
    - [I] rspec = 1.1.99.12
 - [F] faker
 - [F] populator
 - [F] mislav-will_paginate ~> 2.3.7
 - [R] hpricot = 0.6.164
 - [R] rspec >= 1.1.99.12
 - [F] rspec-rails >= 1.1.99.12
    - [I] rspec = 1.1.99.12
    - [F] rack = 0.9.1
    - [ ] cucumber >= 0.1.13
    - [ ] hoe >= 1.9.0

On a positive note, I managed to resolve this issue by manually
unpacking rspec using 'gem unpack' instead of 'rails gem:unpack'.
Here are the steps I took.  Maybe this will help someone else who runs
into this issue.   Note: config/environments/test.rb already is
configured for rspec and rspec-rails as gem dependencies.

* sudo gem uninstall rspec -v 1.1.99.12
* sudo gem uninstall rspec-rails -v 1.1.99.12
* re-cloned, re-built, and re-installed both rspec-1.1.99.12 and rspec-
rails-1.1.99.12 to pick up your patch as described in
http://wiki.github.com/dchelimsky/rspec/edge
* cd RAILS_ROOT
* rm lib/tasks/rspec.rake
* rm -rf vendor/gems/rspec-1.1.99.12
* rm -rf vendor/gems/rspec-rails-1.1.99.12
* cd vendor/gems
* sudo gem unpack rspec -v 1.1.99.12
* sudo chown -R michael:staff rspec-1.1.99.12
* cd RAILS_ROOT
* rake gems:refresh_specs RAILS_ENV=test   # this because gem unpack
does not create a .specification file
* sudo rake gems:unpack RAILS_ENV=test    # unpacks rspec-rails
* sudo rake gems:unpack:dependencies RAILS_ENV=test    # I had already
done this previously, so didn't need this step, but listed here in
case someone following this hasn't yet
* script/generate rspec

And voila!,  'script/spec' works again!     'rake gems RAILS_ENV=test'
still doesn't show rspec as 'F' which makes me slightly nervous, but
everything is functional again.

-Michael
Fef49788625661984ef674d84086abf0?d=identicon&s=25 geetarista (Guest)
on 2009-03-15 05:58
(Received via mailing list)
I'm having similar issues, but when I run the CMD + R command in
Textmate:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such
file to load -- spec (LoadError) from /System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/
custom_require.rb:27:in `require' from /Users/robbyc/Library/
Application Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/
mate.rb:14 from /tmp/textmate-command-5945.rb:2:in `require' from /tmp/
textmate-command-5945.rb:2
This topic is locked and can not be replied to.