minitest RubyMine 里面运行失败 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nuc093
V2EX    Ruby

minitest RubyMine 里面运行失败

  •  
  •   nuc093 2015-05-18 10:52:05 +08:00 4991 次点击
    这是一个创建于 3865 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    请问如何解决呢

    19 条回复    2015-05-19 14:26:01 +08:00
    hging
        1
    hging  
       2015-05-18 11:00:08 +08:00
    ruby版本跟iterm里选的不一致?
    nuc093
        2
    nuc093  
    OP
       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
        3
    nuc093  
    OP
       2015-05-18 11:05:47 +08:00
    hging
        5
    hging  
       2015-05-18 11:08:28 +08:00
    试试在你Gemfile里面增加gem 'ansi'
    另外你没AT我. 我看不到回复. 我只是刚刚好看到这个文章而已.
    nuc093
        6
    nuc093  
    OP
       2015-05-18 11:08:41 +08:00
    @hging 是一样的
    hging
        7
    hging  
       2015-05-18 11:13:14 +08:00
    @nuc093 增加然后bundle啊.
    nuc093
        8
    nuc093  
    OP
       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
        9
    nuc093  
    OP
       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
        10
    hging  
       2015-05-18 11:21:33 +08:00
    nuc093
        11
    nuc093  
    OP
       2015-05-18 1128:20 +08:00
    @hging 嗯。我仔细看看。
    nuc093
        12
    nuc093  
    OP
       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
        13
    hging  
       2015-05-18 15:12:48 +08:00
    @nuc093 这是墙啊. 把Gemfile里面最上面的source改成https://ruby.taobao.org就行了.
    nuc093
        14
    nuc093  
    OP
       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
        15
    hging  
       2015-05-19 10:22:25 +08:00
    @nuc093 有兴趣可以留Q或者微信什么的. 我加你. 一起交流交流
    nuc093
        16
    nuc093  
    OP
       2015-05-1 10:32:22 +08:00
    @hging 29892729
    hging
        17
    hging  
       2015-05-19 10:57:28 +08:00
    @nuc093 =.= 然后验证答案是你真实名字......
    nuc093
        18
    nuc093  
    OP
       2015-05-19 12:17:44 +08:00
    @hging
    nuc093
        19
    nuc093  
    OP
       2015-05-19 14:26:01 +08:00
    @hging 你QQ多少
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     899 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 21:49 PVG 05:49 LAX 13:49 JFK 16:49
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86