Issue w/ rspec-rails

Running OS X Snow Leopard

I installed JRuby to /opt/local/jruby

I put /opt/local/jruby/bin on my path ahead of /opt/local/bin which has
my
Ruby 1.8.7 installed via MacPorts (or is that the base install?).

jruby gem install rails
jruby gem install rspec
jruby gem install rspec-rails

All of those work just fine and dandy. Now I get to the point in the
instructions for installing rspec-rails (
GitHub - rspec/rspec-rails: RSpec for Rails 5+) that says:

Install

gem install rspec-rails

This installs the following gems:

rspec

rspec-core

rspec-expectations

rspec-mocks

rspec-rails

Configure:

Add rspec-rails to the :test and :development groups in the Gemfile:

group :test, :development do

gem “rspec-rails”, “~> 2.4”

end

It needs to be in the :development group to expose generators and rake
tasks without having to type RAILS_ENV=test.

Now you can run:

script/rails generate rspec:install

This adds the spec directory and some skeleton files, including the
“rake
spec” task.

Issue #1 - When it says “Add rspec-rails to the :test and :development
groups in the Gemfile:” to which Gemfile is it referring? I’m assuming
that
it means rspec-rails and not one of the Gemfiles from the other gems
(rspec,
rspec-core, rspec-expectations, etc.) although it could mean the rspec
gem
but the “gem install” was for rspec-rails so I’m going with that one.
Let me
know if I’m wrong there please.

Issue #2 - When I run “which script” I get /usr/bin rather than in the
JRuby
directory so I’m a bit worried about that. Is “script” a generic command
or
is it a Ruby and/or Rails specific command and that indicates that I
have
either a path or installation problem?

Issue #3 - To be safe I run “jruby script/rails generate rspec:install”
and
I get

Macintosh-2:gems wobbet$ jruby script/rails rspec:install
Error opening script file:
/opt/local/jruby/lib/ruby/gems/1.8/gems/script/rails (No such file or
directory)

I’m hoping that means I’m not having an issue with my path by explicitly
invoking jruby at the front although I’m not certain. Either way I have
an
error that I don’t understand.

Any help is appreciated.

Many thanks!!!

rjsjr

Hey Robert,
On [Monday, January 24] at 5:50 AM, Robert Sanford wrote:

jruby gem install rspec
jruby gem install rspec-rails

All of those work just fine and dandy. Now I get to the point in the
instructions for installing rspec-rails
(GitHub - rspec/rspec-rails: RSpec for Rails 5+) that says:

Ruby 1.8.7 is the base install on Snow Leopard. If you’re moving into
using JRuby, I can’t recommend using RVM enough, especially on Snow
Leopard, as it is just dead simple. RVM allows you to switch between
versions of Ruby and it manages your gems along the way, without you
having to worry about path problems.

rspec-core

script/rails generate rspec:install

Gemfile is actually a file inside of your generated rails project that
is used by Bundler in order to manage your gems, their dependencies, and
to keep your executables within the context of the project.

Issue #2 - When I run “which script” I get /usr/bin rather than in the JRuby
directory so I’m a bit worried about that. Is “script” a generic command or is it
a Ruby and/or Rails specific command and that indicates that I have either a path
or installation problem?

script is a rails command that doesn’t get used anymore with Rails 3.
In order to run the equivalent of generate these days, it is: rails g,
or for jruby, jruby -S rails g. The -S is really nice there, as it is a
flag that tells jruby to look for the script in bin or using PATH
environment variable.

The fixes up above should help with this. Once again, I can’t recommend
RVM enough. Once you have it installed, you can use: rvm install
jruby-1.6.0.rc1 (to grab the latest release candidate) or just rvm
install jruby and it will properly install jruby on your system. At that
point, you can just type rvm use jruby(or jruby-1.6.0.rc1) in order to
switch to that version of ruby.

Information is here: http://rvm.beginrescueend.com/

Also, information on Bundler can be found here: http://gembundler.com/