Skip to content

Commit

Permalink
Fix tests and specs with data bag ruby-2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
madwork committed Aug 12, 2014
1 parent 76a39f9 commit c16ddf3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
10 changes: 5 additions & 5 deletions spec/rubies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
describe "chruby-build::rubies" do
let(:chef_run) { ChefSpec::Runner.new }

let(:rubies) { JSON.parse File.read("test/integration/rubies_data_bags/data_bags/rubies/ruby-2.1.1.json") }
let(:rubies) { JSON.parse File.read("test/integration/rubies_data_bags/data_bags/rubies/ruby-2.1.2.json") }

before do
stub_data_bag('rubies').and_return(['ruby-2.1.1'])
stub_data_bag_item('rubies', 'ruby-2.1.1').and_return(rubies)
stub_data_bag('rubies').and_return(['ruby-2.1.2'])
stub_data_bag_item('rubies', 'ruby-2.1.2').and_return(rubies)
chef_run.converge(described_recipe)
end

it { expect(chef_run).to include_recipe("chruby-build::default") }
it { expect(chef_run).to include_recipe("apt") }
it { expect(chef_run).to install_with_make_ark("ruby") }
it { expect(chef_run).to create_directory('/opt/rubies/ruby-2.1.1/etc') }
it { expect(chef_run).to create_template("/opt/rubies/ruby-2.1.1/etc/gemrc") }
it { expect(chef_run).to create_directory('/opt/rubies/ruby-2.1.2/etc') }
it { expect(chef_run).to create_template("/opt/rubies/ruby-2.1.2/etc/gemrc") }
it { expect(chef_run).to install_gem_package("bundler") }

describe "rubies_libs attribute" do
Expand Down
11 changes: 0 additions & 11 deletions test/integration/rubies_data_bags/data_bags/rubies/ruby-2.1.1.json

This file was deleted.

11 changes: 11 additions & 0 deletions test/integration/rubies_data_bags/data_bags/rubies/ruby-2.1.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "ruby-2.1.2",
"url": "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz",
"checksum": "f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb425589e6635",
"gems": ["bundler"],
"environment": {
"ARCHFLAGS": "-arch x86_64",
"CFLAGS": "-g -O2",
"CPPFLAGS": "-I/usr/include -I/usr/local/include"
}
}
30 changes: 19 additions & 11 deletions test/integration/rubies_data_bags/serverspec/chruby_build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,36 @@
it { should be_installed }
end

describe file('/opt/rubies/ruby-2.1.1') do
describe file('/opt/rubies/ruby-2.1.2') do
it { should be_directory }
it { should be_owned_by 'root' }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.1 -- "ruby -r rbconfig -e \'print RbConfig::CONFIG[\"configure_args\"]\'"'), if: os[:release] == '12.04' do
it { should return_stdout "'--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.1.1' 'CFLAGS=-g -O2' 'LIBS=-ltcmalloc_minimal -lyaml' 'CPPFLAGS=-I/usr/include -I/usr/local/include'" }
describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -r rbconfig -e \'print RbConfig::CONFIG[\"configure_args\"]\'"') do
it { should return_stdout "'--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.1.2' 'CFLAGS=-g -O2' 'LIBS=-ltcmalloc_minimal -lyaml' 'CPPFLAGS=-I/usr/include -I/usr/local/include'" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.1 -- "ruby -r rbconfig -e \'print RbConfig::CONFIG[\"configure_args\"]\'"'), if: os[:release] == '14.04' do
it { should return_stdout "'--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.1.1' '--with-readline-dir=/usr/lib/x86_64-linux-gnu/libreadline.so' 'CFLAGS=-g -O2' 'LIBS=-ltcmalloc_minimal -lyaml' 'CPPFLAGS=-I/usr/include -I/usr/local/include'" }
describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -e \'print RUBY_VERSION\'"') do
it { should return_stdout "2.1.2" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.1 -- "ruby -e \'print RUBY_VERSION\'"') do
it { should return_stdout "2.1.1" }
describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -r yaml -e \'print Psych::LIBYAML_VERSION\'"') do
it { should return_stdout "0.1.6" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.1 -- "ruby -r yaml -e \'print Psych::LIBYAML_VERSION\'"') do
it { should return_stdout "0.1.6" }
describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -r readline -e \'print Readline::VERSION\'"'), if: os[:release] == '12.04' do
it { should return_stdout "6.2" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -r readline -e \'print Readline::VERSION\'"'), if: os[:release] == '14.04' do
it { should return_stdout "6.3" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.1.2 -- "ruby -r openssl -e \'print OpenSSL::VERSION\'"') do
it { should return_stdout "1.1.0" }
end

describe file('/opt/rubies/ruby-2.1.1/etc/gemrc') do
describe file('/opt/rubies/ruby-2.1.2/etc/gemrc') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_mode 644 }
Expand All @@ -90,5 +98,5 @@
end

describe command('which bundle') do
it { should return_stdout "/opt/rubies/ruby-2.1.1/bin/bundle" }
it { should return_stdout "/opt/rubies/ruby-2.1.2/bin/bundle" }
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
RSpec.configure do |c|
c.before :all do
c.os = backend(Serverspec::Commands::Base).check_os
c.path = '/sbin:/usr/sbin:/opt/rubies/ruby-2.1.1/bin'
c.path = '/sbin:/usr/sbin:/opt/rubies/ruby-2.1.2/bin'
end
end

0 comments on commit c16ddf3

Please sign in to comment.