[rspec-users] Error when mocking a method in a class

Juanma Cervera lists at ruby-forum.com
Tue Dec 30 05:24:47 EST 2008


Josh Knowles wrote:
>There are forks out on github which have specs and have
> fixed the problem with validate_uniqueness_of.

I have test a plugin with that fixed (from negonicrac) and it still has 
the same problem for me.

I see that this plugin already has specs, and want to try them.
But I don't know how to run specs in a plugin.

I use rake spec:plugins but fails

jmcervera at jmcervera-laptop:~/aaa/vendor$ rake spec:plugins
(in /home/jmcervera/aaa)
./vendor/plugins/rspec-on-rails-matchers/spec/spec_helper.rb:2:in 
`require': no such file to load -- activerecord (LoadError)
  from ./vendor/plugins/rspec-on-rails-matchers/spec/spec_helper.rb:2
  from 
./vendor/plugins/rspec-on-rails-matchers/spec/observers_spec.rb:1:in 
`require'
  from ./vendor/plugins/rspec-on-rails-matchers/spec/observers_spec.rb:1
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in 
`load'
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:14:in 
`load_files'
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in 
`each'
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:13:in 
`load_files'
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in 
`run_examples'
  from 
/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in 
`run'
  from /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4
rake aborted!
Command /usr/bin/ruby1.8 
-I"/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib" 
"/usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec" 
"vendor/plugins/rspec-on-rails-matchers/spec/observers_spec.rb" 
"vendor/plugins/rspec-on-rails-matchers/spec/validations_spec.rb" 
"vendor/plugins/rspec-on-rails-matchers/spec/associations_spec.rb" 
"vendor/plugins/rspec-on-rails-matchers/spec/views_spec.rb" --options 
"/home/jmcervera/aaa/spec/spec.opts" failed

(See full trace by running task with --trace)

this is the spec_helper.rb file that is failing in line 2
============================
require 'spec'
require 'activerecord'

Dir.glob(File.dirname(__FILE__) + 
'/../lib/spec/rails/matchers/*.rb').each do |f|
  require f
end

include Spec::Rails::Matchers
==================

How should I require 'activerecord'?
Or how I have to do the setup for testing/specing plugins?
Any URL for that?

Thanks
Juanma Cervera


-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list