这似乎是一个简单的问题,但我没有在任何地方找到答案。
我在GitHub上分享了这个gem:https://github.com/kjvarga/sitemap_generator并且git将fork克隆到我的本地机器上。
我还没有对它进行任何更改,但是想知道如何对它进行测试,所以当我更改它时,我可以确保它们仍然通过。
看起来它使用rspec并且spec / sitemap_generator中有一些rspec文件。所以我尝试了rspec spec/sitemap_generator/*
,但我得到了这个:
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$
正在运行bundle install
或gem install mocha
似乎无济于事。
我对rspec不是很熟悉(通常只使用rake test
来测试使用ActiveSupport :: TestCase的rails应用程序)。有什么建议吗?
答案 0 :(得分:2)
Jörg上面发表的评论引出了正确的答案。只需运行rake test
即可。糟糕!
答案 1 :(得分:1)
确保使用bundle exec
运行Rspec。看起来只是在您的系统上安装rspec
运行版本2.5.1,而执行bundle exec rspec...
应运行gem Gemfile
所需的1.3.0版本的Rspec。
bundle exec rspec spec