Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix ruby engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Apr 10, 2016
1 parent 92c8cfe commit abd9cf8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/capsulecd/ruby/ruby_engine.rb
Expand Up @@ -14,7 +14,7 @@ def build_step
# check for/create required VERSION file
gemspec_data = CapsuleCD::Ruby::RubyHelper.load_gemspec_data(gemspec_path)

unless File.exist?(CapsuleCD::Ruby::RubyHelper.version_filepath(@source_git_local_path, gemspec_data.name))
if !gemspec_data || !File.exist?(CapsuleCD::Ruby::RubyHelper.version_filepath(@source_git_local_path, gemspec_data.name))
fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is required to process Ruby gem'
end

Expand Down
10 changes: 9 additions & 1 deletion spec/lib/capsulecd/base/configuration_spec.rb
Expand Up @@ -18,14 +18,18 @@
expect(subject.source).to eql(:github)
end

it 'should correctly base64 decode chef supermarket key' do
expect(subject.chef_supermarket_key).to eql("-----BEGIN RSA PRIVATE KEY-----\nsample_supermarket_key\n-----END RSA PRIVATE KEY-----\n")
end

it 'should have correct defaults' do
expect(subject.engine_version_bump_type).to eql(:patch)
expect(subject.chef_supermarket_type).to eql('Other')
end
end

describe 'with an incorrect configuration file' do
let(:config_file_path) { 'spec/fixtures/sample_configuration.yml' }
let(:config_file_path) { 'spec/fixtures/incorrect_configuration.yml' }
subject { CapsuleCD::Configuration.new(config_file:config_file_path, source: :github, package_type: :node) }

it 'should populate github_access_token' do
Expand All @@ -39,6 +43,10 @@
it 'should use cli specified source' do
expect(subject.source).to eql(:github)
end

it 'should have a nil chef supermarket key' do
expect(subject.chef_supermarket_key).to eql(nil)
end
end

describe 'when overriding sample configuration file' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/capsulecd/python/python_engine_spec.rb
Expand Up @@ -25,7 +25,7 @@
FileUtils.copy_entry('spec/fixtures/python/pip_analogj_test', test_directory)
engine.instance_variable_set(:@source_git_local_path, test_directory)

VCR.use_cassette('pip_build_step',:tag => :chef) do
VCR.use_cassette('pip_build_step',:tag => :ruby) do
engine.build_step
end

Expand Down
14 changes: 13 additions & 1 deletion spec/lib/capsulecd/ruby/ruby_engine_spec.rb
Expand Up @@ -23,14 +23,26 @@
end
it 'should create a .gitignore file and spec folder' do
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)

engine.instance_variable_set(:@source_git_local_path, test_directory)

VCR.use_cassette('gem_build_step',:tag => :chef) do
VCR.use_cassette('gem_build_step',:tag => :ruby) do
engine.build_step
end

expect(File.exist?(test_directory+'/.gitignore')).to eql(true)
end

it 'should raise an error if version.rb is missing' do
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
engine.instance_variable_set(:@source_git_local_path, test_directory)

VCR.use_cassette('gem_build_step_without_version.rb',:tag => :ruby) do
expect{engine.build_step}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
end

end
end
end

Expand Down

0 comments on commit abd9cf8

Please sign in to comment.