黄瓜性能&铁路4 - 宝石版冲突?

时间:2013-12-04 07:47:43

标签: ruby-on-rails ruby ruby-on-rails-4 cucumber

我第一次使用Rails 4(4.0.0)。

我对Cucumber的速度感到不满意。

我做了以下事情:

  1. 使用rails new MyApp -T创建了应用。

  2. 添加了rspec-rails,cucumber-rails,database_cleaner&对Gemfile进行therubyracer,然后运行bundle install

  3. 启用rails generate rspec:installrails generate cucumber:install

  4. 我没有创建任何模型,控制器,视图,规格或功能。我正在进行双周期TDD并且针对没有功能运行cucumber,期望它花费不到几秒钟。然后我使用rakebundle exec调用它并比较结果(如下所示)。

    bundle exec cucumber

        noel@noel-U36JC:~/commons/MyApp$ time bundle exec cucumber
        Using the default profile...
        0 scenarios
        0 steps
        0m0.000s
    
        real    0m22.017s
        user    0m20.749s
        sys     0m1.044s
    

    rake cucumber

        noel@noel-U36JC:~/commons/MyApp$ time rake cucumber
        /home/noel/commons/MyApp/db/schema.rb doesn't exist yet. Run `rake db:migrate` 
        to create it, then try again. If you do not intend to use a database, you 
        should instead alter /home/noel/commons/MyApp/config/application.rb to limit 
        the frameworks that will be loaded.
    
        real    0m18.556s
        user    0m17.329s
        sys     0m1.064s
    

    cucumber

        noel@noel-U36JC:~/commons/MyApp$ time cucumber
        WARN: Unresolved specs during Gem::Specification.reset:
              rake (>= 0.8.7)
              hike (~> 1.2)
              tilt (!= 1.3.0, ~> 1.1)
        WARN: Clearing out unresolved specs.
        Please report a bug if this causes problems.
        Using the default profile...
        0 scenarios
        0 steps
        0m0.000s
    
        real    0m19.862s
        user    0m18.681s
        sys     0m1.028s
    

    Gemfile.lock

        ...
        hike (1.2.3)
        ...
        rake (10.1.0)
        ...
        tilt (1.4.1)
        ...
    

    我无法找到Gem :: Specification.reset从哪里获取信息。我已经运行了gem cleanupgem uninstall gemname 而且没有获得任何地方。

    非常感谢任何帮助。

    更新:忘了提,我在RVM上运行ruby 1.9.3-p484。我正在开发的lappy是2.5岁,ubuntu和amp; RVM一直在加载,所以RVM cruff也是一个因素。

    更新(评论2后一小时):

    我尝试设置一个新的项目特定的RVM gemset,认为全局getset中的cruff可能是问题。

    设置似乎有效。

    bundle install期间,rake的gem安装失败。没有快乐!

        noel@noel-U36JC:~/commons/MyApp$ rvm 1.9.3-p484
    
        noel@noel-U36JC:~/commons/MyApp$ rvm gemset create MyApp
        gemset created MyApp    => /home/noel/.rvm/gems/ruby-1.9.3-p484@MyApp
    
        noel@noel-U36JC:~/commons/MyApp$ rvm --ruby-version use 1.9.3-p484@MyApp
        Using /home/noel/.rvm/gems/ruby-1.9.3-p484 with gemset MyApp
    
        noel@noel-U36JC:~/commons/MyApp$ bundle install
        Fetching gem metadata from https://rubygems.org/.........
        Fetching gem metadata from https://rubygems.org/..
    
        NoMethodError: private method `open' called for Gem::Package:Class
        An error occured while installing rake (10.1.0), and Bundler cannot continue.
        Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.
    
        noel@noel-U36JC:~/commons/MyApp$ gem install rake -v '10.1.0'
        Successfully installed rake-10.1.0
        Installing ri documentation for rake-10.1.0
        1 gem installed
    
        noel@noel-U36JC:~/commons/MyApp$ bundle install
        Fetching gem metadata from https://rubygems.org/.........
        Fetching gem metadata from https://rubygems.org/..
    
        NoMethodError: private method `open' called for Gem::Package:Class
        An error occured while installing rake (10.1.0), and Bundler cannot continue.
        Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.
    
        noel@noel-U36JC:~/commons/MyApp$ time cucumber
        The program 'cucumber' is currently not installed.  You can install it by typing:
        sudo apt-get install cucumber
    
        real    0m0.126s
        user    0m0.064s        
        sys     0m0.056s
    

    更新

    看起来是Bundler版本问题。

    Bundler版本是1.1.3。

    现在是1.3.5。

        noel@noel-U36JC:~/commons/MyApp$ time cucumber
        Using the default profile...
        0 scenarios
        0 steps
        0m0.000s
    
        real    0m6.926s
        user    0m6.592s
        sys 0m0.280s
    

    那似乎有效。 :)

1 个答案:

答案 0 :(得分:0)

原来是Bunder版本问题

所以解决方案是:

gem install bundler
bundle install

最终黄瓜时间为6到7秒,低于最初的60秒加上。