学习ruby的测试例子:
http://www.sitepoint.com/minitest-shoulda/
代码在这:
https://github.com/JesseHerrick/minitest-with-shoulda
在iterm里面执行成功
➜ minitest-with-shoulda git:(master) ✗ pwd
/Users/qk/mygithub/minitest-with-shoulda
➜ minitest-with-shoulda git:(master) ✗ ruby -I test:lib test/test_calculator_basic.rb
Run options: --seed 21817
....
Finished in 0.002545s, 1571.7092 runs/s, 1571.7092 assertions/s.
4 runs, 4 assertions, 0 failures, 0 errors, 0 skips
/Users/qk/.rvm/rubies/ruby-2.0.0-p481/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/qk/mygithub/minitest-with-shoulda/test/test_calculator_basic.rb
Testing started at 上午10:50 ...
/Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:92:in block in materialize': Could not find ansi-1.4.3 in any of the sources (Bundler::GemNotFound)
map!'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in materialize'
specs'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:133:in
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:178:in specs_for'
requested_specs'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:167:in
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/environment.rb:18:in requested_specs'
setup'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:13:in
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler.rb:120:in setup'
<top (required)>'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/setup.rb:17:in
from /Users/qk/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require'
require'
from /Users/qk/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
Process finished with exit code 1
请问如何解决呢
1
hging 2015-05-18 11:00:08 +08:00
ruby版本跟iterm里选的不一致?
|
2
nuc093 OP ➜ minitest-with-shoulda git:(master) ✗ rvm list
rvm rubies =* ruby-2.0.0-p481 [ x86_64 ] # => - current # =* - current && default # * - default |
3
nuc093 OP |
4
nuc093 OP |
5
hging 2015-05-18 11:08:28 +08:00
试试在你Gemfile里面增加gem 'ansi'
另外你没AT我. 我看不到回复. 我只是刚刚好看到这个文章而已. |
8
nuc093 OP @hging
https://github.com/JesseHerrick/minitest-with-shoulda/blob/master/Gemfile.lock ##Gemfile加了:## source 'https://rubygems.org/' gem 'ansi-1.4.3' gem 'minitest' # optional as it's included by default in Ruby std lib gem 'minitest-reporters' gem 'shoulda-context' ##还是报同样的错。## ##你clone https://github.com/JesseHerrick/minitest-with-shoulda 用RubyMine右键run一下试一试.## |
9
nuc093 OP @hging
➜ minitest-with-shoulda git:(master) ✗ bundle install Fetching gem metadata from https://rubygems.org/......... Fetching version metadata from https://rubygems.org/.. Could not find gem 'ansi-1.4.3 (>= 0) ruby' in the gems available on this machine. ➜ minitest-with-shoulda git:(master) ✗ |
10
hging 2015-05-18 11:21:33 +08:00
|
12
nuc093 OP @hging
➜ minitest-with-shoulda git:(master) ✗ gem install ansi -v '1.4.3' Fetching: ansi-1.4.3.gem (100%) Successfully installed ansi-1.4.3 Parsing documentation for ansi-1.4.3 Installing ri documentation for ansi-1.4.3 1 gem installed ➜ minitest-with-shoulda git:(master) ✗ bundle update Fetching gem metadata from https://rubygems.org/......... Fetching version metadata from https://rubygems.org/.. Resolving dependencies... Gem::RemoteFetcher::FetchError: Errno::ECONNREFUSED: Connection refused - connect(2) (https://rubygems.org/gems/ansi-1.4.3.gem) An error occurred while installing ansi (1.4.3), and Bundler cannot continue. Make sure that `gem install ansi -v '1.4.3'` succeeds before bundling. ➜ minitest-with-shoulda git:(master) ✗ bundle install ansi ERROR: "bundle install" was called with arguments ["ansi"] Usage: "bundle install [OPTIONS]" ➜ minitest-with-shoulda git:(master) ✗ bundle install Fetching gem metadata from https://rubygems.org/......... Fetching version metadata from https://rubygems.org/.. Resolving dependencies... Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/ansi-1.4.3.gem) An error occurred while installing ansi (1.4.3), and Bundler cannot continue. Make sure that `gem install ansi -v '1.4.3'` succeeds before bundling. 我是没办法了。 |
14
nuc093 OP @hging 十分感谢确实是墙。改过就好了点了。还有个问题。
/Users/qk/.rvm/rubies/ruby-2.0.0-p481/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/qk/mygithub/minitest-with-shoulda/test/test_calculator_basic.rb Testing started at 上午9:46 ... /Users/qk/mygithub/minitest-with-shoulda/test/test_calculator_basic.rb:2:in `require': cannot load such file -- calculator (LoadError) from /Users/qk/mygithub/minitest-with-shoulda/test/test_calculator_basic.rb:2:in `<top (required)>' from -e:1:in `load' from -e:1:in `<main>' Process finished with exit code 1 代码都在这了: https://github.com/JesseHerrick/minitest-with-shoulda 初探ruby还忘指点 |