Forum: RSpec Difference between gem and plugin

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.
Donald F. (Guest)
on 2008-10-04 00:47
(Received via mailing list)
Can someone tell me the difference ins the gem versions and the plugin
versions? do they work together? need both?

Don F.
Zach D. (Guest)
on 2008-10-04 00:58
(Received via mailing list)
On Fri, Oct 3, 2008 at 4:46 PM, Donald F. <removed_email_address@domain.invalid> 
wrote:
> Can someone tell me the difference ins the gem versions and the plugin
> versions? do they work together? need both?
>

You do not need both. The plugin versions are for Ruby on Rails
projects. Rails had a way of loading plugins from the vendor/plugins/
directory. This will most likely deprecate (or become less and less
used)  as Rails has added support for bundling gems with the project
in the vendor/gems/ directory.

The gem versions of rspec are the ones that are intended for everyday
use. I would go with those unless you are supporting a Rails
application in the 1.2.x family or earlier.


Zach D.
http://www.continuousthinking.com
http://www.mutuallyhuman.com
Pat M. (Guest)
on 2008-10-04 01:04
(Received via mailing list)
"Zach D." <removed_email_address@domain.invalid> writes:

> On Fri, Oct 3, 2008 at 4:46 PM, Donald F. <removed_email_address@domain.invalid> wrote:
>> Can someone tell me the difference ins the gem versions and the plugin
>> versions? do they work together? need both?
>>
>
> You do not need both. The plugin versions are for Ruby on Rails
> projects. Rails had a way of loading plugins from the vendor/plugins/
> directory. This will most likely deprecate (or become less and less
> used)  as Rails has added support for bundling gems with the project
> in the vendor/gems/ directory.

rspec-rails is now published as a gem as well.

I am 100% plugin free when it comes to RSpec.

Pat
Fernando P. (Guest)
on 2008-10-04 20:54
How do you go plugin-less for RSpec? The plugins require you to generate
some files, so how do you do that without a plugin? Is there still a
rake task in the gem to generate the required files?
David C. (Guest)
on 2008-10-04 20:58
(Received via mailing list)
On Sat, Oct 4, 2008 at 11:54 AM, Fernando P. 
<removed_email_address@domain.invalid>
wrote:
> How do you go plugin-less for RSpec? The plugins require you to generate
> some files, so how do you do that without a plugin? Is there still a
> rake task in the gem to generate the required files?

I'll post this up on the wiki, but the steps are:

[sudo] gem install rspec-rails
script/generate rspec

That's it.

rspec is a dependency of rspec-rails, so installing the rspec-rails
gem will also install the rspec gem.

Once installed, if you type 'script/generate' with no arguments,
you'll see all the rspec generators listed. 'script/generate rspec'
generates the files necessary to work with rspec without having to
install the plugins in your app.

Cheers,
David
Fernando P. (Guest)
on 2008-10-04 21:01
Cool.

However what happens when my app is currently using the plugin version,
is it easy to migrate to the gem? Should I regenerate the files? I guess
there is somewhere a line that says to rspec "look into vendor/plugins"?
David C. (Guest)
on 2008-10-04 21:14
(Received via mailing list)
On Sat, Oct 4, 2008 at 12:01 PM, Fernando P. 
<removed_email_address@domain.invalid>
wrote:
> Cool.
>
> However what happens when my app is currently using the plugin version,
> is it easy to migrate to the gem? Should I regenerate the files? I guess
> there is somewhere a line that says to rspec "look into vendor/plugins"?

Just delete the plugin directories.

http://github.com/dchelimsky/rspec-rails/wikis/home

Cheers,
David
Luis L. (Guest)
on 2008-10-04 22:34
(Received via mailing list)
On Sat, Oct 4, 2008 at 2:58 PM, David C. <removed_email_address@domain.invalid>
wrote:
> That's it.
>
> rspec is a dependency of rspec-rails, so installing the rspec-rails
> gem will also install the rspec gem.
>
> Once installed, if you type 'script/generate' with no arguments,
> you'll see all the rspec generators listed. 'script/generate rspec'
> generates the files necessary to work with rspec without having to
> install the plugins in your app.
>

It doesn't :-P

Just tried that on a fresh application, and when call script/generate
rspec it just not find it and don't execute it :-P

Also, going to the gem version instead of the plugin requires a new
set of script files, since they try to look for vendor/plugins/
instead of doing:

require 'rubygems'
require 'spec'

Last, but not least, you need to do

config.gem 'rspec-rails', :lib => 'spec/rails' since Rails will try by
default to load 'rspec-rails' module instead.

Wow, lot of details :-P

Cheers,
--
Luis L.
AREA 17
-
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams
David C. (Guest)
on 2008-10-04 22:40
(Received via mailing list)
On Sat, Oct 4, 2008 at 1:06 PM, Luis L. <removed_email_address@domain.invalid>
wrote:
>>
>
> require 'spec'
>
> Last, but not least, you need to do
>
> config.gem 'rspec-rails', :lib => 'spec/rails' since Rails will try by
> default to load 'rspec-rails' module instead.
>
> Wow, lot of details :-P

Hmmm. Wonder if this is a windows thing. Or maybe you have an older
version of rubygems? It works as I prescribed for me with the
following:

$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ gem -v
1.3.0
$ rails -v
Rails 2.1.1
$ spec --version
rspec 1.1.8

Besides the OS, what's different in your system?
David C. (Guest)
on 2008-10-04 22:41
(Received via mailing list)
On Sat, Oct 4, 2008 at 1:38 PM, David C. <removed_email_address@domain.invalid>
wrote:
>>> script/generate rspec
>>>
>> require 'rubygems'
> version of rubygems? It works as I prescribed for me with the
>
> Besides the OS, what's different in your system?

Also - the script files prepend vendor/plugins/rspec/lib to the path,
but if they are not there, there shouldn't be a problem. That just
ensures that if you DO have the plugin installed it takes precedence
over the gem.
Luis L. (Guest)
on 2008-10-04 22:43
(Received via mailing list)
On Sat, Oct 4, 2008 at 4:41 PM, David C. <removed_email_address@domain.invalid>
wrote:
> ...
>
> Also - the script files prepend vendor/plugins/rspec/lib to the path,
> but if they are not there, there shouldn't be a problem. That just
> ensures that if you DO have the plugin installed it takes precedence
> over the gem.
>

But require 'rubygems' on top is missing, ending with LoadError due
missing 'spec' :-P

Will get back to you with facts and all the details, 1.3.0 was
released with a bug on Windows so I need to cook a sandboxed ruby with
trunk version instead.

--
Luis L.
AREA 17
-
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams
David C. (Guest)
on 2008-10-04 22:48
(Received via mailing list)
On Sat, Oct 4, 2008 at 1:43 PM, Luis L. <removed_email_address@domain.invalid>
wrote:
> missing 'spec' :-P
I've added that to script/spec:

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

> Will get back to you with facts and all the details, 1.3.0 was
> released with a bug on Windows so I need to cook a sandboxed ruby with
> trunk version instead.

Thanks for your help!

Cheers,
David
Fernando P. (Guest)
on 2008-10-05 19:45
Hi,

Going plugin-less for RSpec went 99% smoothly, here is the only error
message I got:

$ ./script/generate rspec
Gem::SourceIndex#search support for Regexp patterns is deprecated
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/rails_generator/lookup.rb:211:in
`each' is outdated
Fernando P. (Guest)
on 2008-10-05 19:51
By the way for a RoR application, can I also go plugin-less for Webrat
and Cucumber? From what I understand I still need to install these two
as plugins.
David C. (Guest)
on 2008-10-05 20:09
(Received via mailing list)
On Sun, Oct 5, 2008 at 10:51 AM, Fernando P. 
<removed_email_address@domain.invalid>
wrote:
> By the way for a RoR application, can I also go plugin-less for Webrat
> and Cucumber? From what I understand I still need to install these two
> as plugins.

Why ask us when you can ask rubygems?

$ gem q -drn cucumber
$ gem q -drn webrat

Cheers,
David
David C. (Guest)
on 2008-10-05 20:09
(Received via mailing list)
On Sun, Oct 5, 2008 at 10:45 AM, Fernando P. 
<removed_email_address@domain.invalid>
wrote:
> Hi,
>
> Going plugin-less for RSpec went 99% smoothly, here is the only error
> message I got:
>
> $ ./script/generate rspec
> Gem::SourceIndex#search support for Regexp patterns is deprecated
> /usr/local/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/rails_generator/lookup.rb:211:in
> `each' is outdated

That's actually not related to rspec.

The deprecation notice is coming from Rubygems-1.3, and is referencing
rails code, not rspec code.
Fernando P. (Guest)
on 2008-10-05 20:20
> Why ask us when you can ask rubygems?
>
Well I prefer to ask (and sound stupid 5 minutes) than not ask (and be
stupid all my life), that's the way I work. From the cucumber github
wiki located at: http://github.com/aslakhellesoy/cucumber/wikis

--
Installation

(Rails people – see Ruby on Rails).

After you have installed Ruby or JRuby – install Cucumber with the
following command:
Ruby:

gem install cucumber
--

When I go to the Ruby on Rails wiki page, Aslak says to install Cucumber
as a plugin. Therefore I was wondering if for a Rails app, installing
Cucumber as a gem was okay.

In the past, even though the RSpec gem existed, it was recommended to
install the plugin version of rspec if it was going to be used with a
Rails app.
Fernando P. (Guest)
on 2008-10-05 21:29
I have removed the plugins for both cucumber and webrat. Now I am having
the following error message when running rake features or
./script/generate cucumber:
--
/usr/local/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.6/lib/cucumber/cli.rb:83:in
`read': No such file or directory - cucumber.yml (Errno::ENOENT)
        from
/usr/local/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.6/lib/cucumber/cli.rb:83:in
`parse_args_from_profile'
--
David C. (Guest)
on 2008-10-05 22:01
(Received via mailing list)
On Sun, Oct 5, 2008 at 11:20 AM, Fernando P. 
<removed_email_address@domain.invalid>
wrote:
>
>
> In the past, even though the RSpec gem existed, it was recommended to
> install the plugin version of rspec if it was going to be used with a
> Rails app.

Didn't mean to make you feel bad or stupid. Was just offering you a
way to answer at least part of your question. Teach a man to fish, and
all.

That said, here's some fish:

As of 1.1.5, rspec-rails is now released as a gem. If you're using
rails >= 2.0, you can use rspec/rspec-rails gems because the rspec
generator (script/generate rspec) is visible, and the generated files
are all you need in the rails app.

Cucumber and webrat are both released as gems.

My recommendation is to use gems for all these tools, except in cases
where  you need functionality that is in git, but not in the latest
gem. Even then, I'd recommend downloading
source from git and building the gem locally rather than adding the
code to your repo.

Of course, this all assumes just a local build on your development
machine. If you've got a build machine running scenarios and code
examples, you might find it easier to keep unreleased code in your
app.

Another option would be to use gems by default, and then store them in
vendor/gems instead of vendor/plugins when you need functionality
between releases.

HTH,
David
This topic is locked and can not be replied to.