V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nuc093
V2EX  ›  Ruby

minitest RubyMine 里面运行失败

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

    学习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 11:28: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-19 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   ·   我们的愿景   ·   实用小工具   ·   2784 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:46 · PVG 17:46 · LAX 02:46 · JFK 05:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.