简体   繁体   中英

Testing forked ruby gems/plugins on GitHub

This seems like a simple question but I haven't found an answer anywhere.

I forked this gem on GitHub: https://github.com/kjvarga/sitemap_generator and git cloned the fork to my local machine.

I haven't made any changes to it yet, but want to figure out how to run the tests on it so when I do change it I can make sure they still pass.

It looks like it uses rspec and there are some rspec files in spec/sitemap_generator. So I tried running rspec spec/sitemap_generator/* but I get this:

barmstrong:sitemap_generator$ rspec spec/sitemap_generator/*
/Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require': no such file to load -- rspec/core/mocking/with_mocha (MissingSourceFile)
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:164:in `mock_framework='
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:123:in `mock_with'
    from /Users/barmstrong/NetBeansProjects/sitemap_generator/spec/spec_helper.rb:22
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core.rb:56:in `configure'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/backward_compatibility.rb:29:in `configure'
    from /Users/barmstrong/NetBeansProjects/sitemap_generator/spec/spec_helper.rb:21
    from /Users/barmstrong/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
    from /Users/barmstrong/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
    from /Users/barmstrong/NetBeansProjects/sitemap_generator/spec/sitemap_generator/interpreter_spec.rb:1
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `autorun'
    from /Users/barmstrong/.rvm/gems/ruby-1.8.7-p334/bin/rspec:19
barmstrong:sitemap_generator$

Running bundle install or gem install mocha didn't seem to help.

I'm not very familiar with rspec (normally just use rake test to test rails apps with ActiveSupport::TestCase). Any suggestions?

The comment Jörg posted above led to the right answer. Simply running rake test did what I wanted. Whoops!

Make sure to use bundle exec to run Rspec. It looks like just doing rspec runs version 2.5.1 installed on your system, whereas doing bundle exec rspec... should run the 1.3.0 version of Rspec that the gem's Gemfile requires.

bundle exec rspec spec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM