2016-02-23 47 views
1

我试图使用Circleci持续集成和运行成为一个问题。我正在部署使用ruby 2.2.2和rspec的rails 4应用程序。circleci持续集成Rails应用程序错误需要条纹

当我试图通过circleci把我的第一次构建,我得到一个错误,当它试图运行我的代码行测试套件在我的“spec_helper”我在哪里需要带宝石。我用条纹在该应用中,用“条纹模拟”

测试它下面的错误是。所以失败是我在spec_helper中的require "stripe"行。要清楚rspec运行并通过本地,但我在circleci上得到这个错误。我加倍检查,并设置了circleci上的所有环境变量。我听说有时候宝石需要在circleci上设置的二进制文件才能工作。这可能是问题吗?我将如何做到这一点?

rspec 
/home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- stripe (LoadError) 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/propel/spec/spec_helper.rb:20:in `block in <top (required)>' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core.rb:97:in `configure' 
from /home/ubuntu/propel/spec/spec_helper.rb:18:in `<top (required)>' 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires=' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires=' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>' 
from /home/ubuntu/.rvm/gems/[email protected]/bin/rspec:23:in `load' 

from /home/ubuntu/.rvm/gems/[email protected]/bin/rspec:23:in `<main>' rspec returned exit code 1 

我也应该注意到,我有带我的Gemfile,你可以在这里看到:

gem 'stripe' 

而且你能看到我在rspec的spec_helper要求条纹在这里:

RSpec.configure do |config| 

require 'stripe' 
require 'stripe_mock' 
require 'thin' 

尽管在我的gemfile中有条纹,但我决定尝试将sudo gem install stripe添加到我的circle.yml文件中,以确保它包含在测试中,但出现以下错误:

sudo gem install stripe 
ERROR: Error installing stripe: 

sudo gem install stripe returned exit code 1 

mime-types requires Ruby version >= 1.9.2. Action failed: sudo gem install stripe 

当我指定我circle.yml文件红宝石版本2.2.2

+0

你有一个的Gemfile?它是条纹宝石吗?最好能够证明这一点。也最好显示spec_helper的相关位。 –

+0

哎@DaveSchweisguth - 我的gemfile里有条纹宝石。我已经使用该信息和相关的spec_helper代码更新了我的答案。 –

回答

0

而不是增加sudo gem install stripecircle.yml文件,这甚至,你应该添加gem stripeGemfile

CircleCI documentation说:

In all likelihood, you'll have a list of libraries and dependencies that your app requires. CircleCI automatically detects Ruby's Gemfile, … and then runs the appropriate commands to install the dependencies.

如果您还没有一个Gemfile,您可以:

  1. 运行gem install bundler
  2. 创建Gemfile列出你的应用程序需要运行,包括stripe RubyGems的。它应该是这个样子:

    source "https://rubygems.org" 
    gem "stripe" 
    
  3. 运行bundle命令。这应该创建一个Gemfile.lock文件,列出您使用的相互兼容的宝石的特定版本。

  4. 提交机器人的GemfileGemfile.lock你的版本控制系统。

Bundler Web site还有很多information about Gemfiles

+0

感谢您伸出@georgebrock - 我有一个带有条纹的宝石文件。我用一些格式更新了我的答案,并添加了一些更相关的代码。 –

相关问题