How are you declaring the 'mocha' gem in the Gemfile?
Have you remembered to use ':require => false' ?
group :test do
gem 'mocha', :require => false
end
f.
--
Fernando Guillén
Freelance Web Developer
http://www.fernandoguillen.info
http://spainrb.org/fernando-guillen
I haven't tried using Mocha as a plugin for ages.
Is there a particular reason you want to use it as a plugin rather than a gem?
I'll have a quick look into why it might not be working.
Cheers, James.
----
http://jamesmead.org/
> --
> You received this message because you are subscribed to the Google Groups "mocha-developer" group.
> To post to this group, send email to mocha-d...@googlegroups.com.
> To unsubscribe from this group, send email to mocha-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mocha-developer?hl=en.
>
Thanks for the reply.
The bloke I am working for at the moment doesn't want me to use any gems
on the project.
He cites a reluctance to be dependent on 3rd party code as a reason.
He will however sanction the use of plugins as they are somewhat more
'contained', i.e. local to the project as opposed to being accessible
system-wide.
As you can imagine, this doesn't make my life easier, but c'est la vie!
Anyway, I would be really grateful if you could look into this for me.
As I wrote, it seems that Rails is loading
vendor/plugins/mocha/lib/mocha.rb before its own test framework.
Thanks very much for your help
Jack
In Rails 3, I can't think of any advantage of using Mocha as a plugin rather than a gem. To avoid a dependency on system-wide gems (an understandable requirement), I think the best solution is to use Bundler and specify a path local to the project e.g. `bundle install --path vendor/bundle`. This will keep gems for the project installed separately from system-wide gems and subsequent calls to Bundler commands will remember the chosen path. See [1].
I hope this helps. I'll try to find some time to investigate whether Mocha can still work as a plugin, but I'm pretty busy at the moment and to be honest it's not going to be a high priority.
Regards, James.
[1] http://gembundler.com/bundle_install.html
`bundle install --path vendor/bundle`
will install all of the projects gems to vendor/bundle.
I'll have to keep on reading/researching to see if there is a way to
install only one gem to the vendor folder, using bundler.
Thanks for your help so far.
I would still be grateful if you let me know if you manage to make Mocha
work as a plugin.
Cheers,
Jack
Carl
@captproton
> Thanks for the link. I have just been reading through it. However, it seems to me that running
>
> `bundle install --path vendor/bundle`
>
> will install all of the projects gems to vendor/bundle.
You are correct. It will indeed install *all* of the project's gems to the specified directory, but since the bloke you are working for doesn't want to rely on "system-wide" gems, I thought it would be preferable to install all of them locally within the project. Since it sounds like you have other gems in the Gemfile, why is it ok for them to be "system-wide"? What is so special about Mocha that is must not be "system-wide" when other gems can be?
I may be missing something, but it seems to me that the bloke you are working for is being a bit unreasonable.
> I'll have to keep on reading/researching to see if there is a way to install only one gem to the vendor folder, using bundler.
I don't think there is a way to do that - at least not in a way that would be at all simple.
> Thanks for your help so far.
> I would still be grateful if you let me know if you manage to make Mocha work as a plugin.
I'll try to find some time to look into this, but if it turns out it's difficult to make it work, I think I'm more likely to withdraw the ability to use Mocha as a plugin, since I don't see that there are any real advantages versus using it as a gem.
> If you use bundler and rvm, the gem will not be system wide, but they will just apply to the project. On the other hand, more difficulty mean more work, means , more money.
>
> Carl
> @captproton
I think using RVM is a red herring. You could use an RVM gemset, but to my mind using Bundler with a local path for gems is a simpler solution. Especially when you start to think about deploying the app.
> I may be missing something, but it seems to me that the bloke you are working for is being a bit unreasonable.
No, you're not missing anything. :-)
> I'll try to find some time to look into this, but if it turns out it's difficult to make it work, I think I'm more likely to withdraw the ability to use Mocha as a plugin, since I don't see that there are any real advantages versus using it as a gem.
I appreciate that. Even a "Sorry, it doesn't work as a plugin" would
help, as then I would have a case for being able to use it as a gem
after all.
Other than that, I have installed Mocha as a gem and am enjoying using it.
Thanks for a great tool!
Jack