minitest RubyMine 里面运行失败

2015-05-18 10:52:05 +08:00
 nuc093

学习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

Running:

....

Finished in 0.002545s, 1571.7092 runs/s, 1571.7092 assertions/s.

4 runs, 4 assertions, 0 failures, 0 errors, 0 skips

在RubyMine里面点击按钮测试直接报错##:

/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)
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in
map!'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in materialize'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:133:in
specs'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:178:in specs_for'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/definition.rb:167:in
requested_specs'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/environment.rb:18:in requested_specs'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:13:in
setup'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler.rb:120:in setup'
from /Users/qk/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/setup.rb:17:in
<top (required)>'
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'
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'

Process finished with exit code 1

请问如何解决呢

4443 次点击
所在节点    Ruby
19 条回复
hging
2015-05-18 11:00:08 +08:00
ruby版本跟iterm里选的不一致?
nuc093
2015-05-18 11:02:48 +08:00
➜ minitest-with-shoulda git:(master) ✗ rvm list

rvm rubies

=* ruby-2.0.0-p481 [ x86_64 ]

# => - current
# =* - current && default
# * - default
nuc093
2015-05-18 11:05:47 +08:00
nuc093
2015-05-18 11:06:29 +08:00
hging
2015-05-18 11:08:28 +08:00
试试在你Gemfile里面增加gem 'ansi'
另外你没AT我. 我看不到回复. 我只是刚刚好看到这个文章而已.
nuc093
2015-05-18 11:08:41 +08:00
@hging 是一样的
hging
2015-05-18 11:13:14 +08:00
@nuc093 增加然后bundle啊.
nuc093
2015-05-18 11:14:39 +08:00
@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一下试一试.##
nuc093
2015-05-18 11:18:32 +08:00
@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) ✗
hging
2015-05-18 11:21:33 +08:00
nuc093
2015-05-18 11:28:20 +08:00
@hging 嗯。我仔细看看。
nuc093
2015-05-18 13:58:11 +08:00
@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.

我是没办法了。
hging
2015-05-18 15:12:48 +08:00
@nuc093 这是墙啊. 把Gemfile里面最上面的source改成https://ruby.taobao.org就行了.
nuc093
2015-05-19 09:51:10 +08:00
@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还忘指点
hging
2015-05-19 10:22:25 +08:00
@nuc093 有兴趣可以留Q或者微信什么的. 我加你. 一起交流交流
nuc093
2015-05-19 10:32:22 +08:00
@hging 29892729
hging
2015-05-19 10:57:28 +08:00
@nuc093 =.= 然后验证答案是你真实名字......
nuc093
2015-05-19 12:17:44 +08:00
@hging 秦焜
nuc093
2015-05-19 14:26:01 +08:00
@hging 你QQ多少

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/191840

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX