Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madwork committed Nov 21, 2018
1 parent 4fe865e commit c5e28eb
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 70 deletions.
25 changes: 16 additions & 9 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ driver:
name: vagrant

provisioner:
name: chef_solo
solo_rb:
ssl_verify_mode: verify_peer
name: chef_zero
install_strategy: always

platforms:
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: ubuntu-16.04-chef-12
- name: ubuntu-14.04-chef-13
driver:
box: bento/ubuntu-16.04
box: bento/ubuntu-14.04
provisioner:
require_chef_omnibus: 12.21.3
product_name: chef
product_version: 13
- name: ubuntu-18.04-chef-14
driver:
box: bento/ubuntu-18.04
provisioner:
product_name: chef
product_version: 14

suites:
- name: default
Expand Down Expand Up @@ -43,8 +49,9 @@ suites:
libyaml:
enable: false
rubies:
- id: "ruby-2.4.1"
url: "https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz"
- id: "ruby-2.4.5"
url: "https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.5.tar.gz"
checksum: "6737741ae6ffa61174c8a3dcdd8ba92bc38827827ab1d7ea1ec78bc3cefc5198"
gems:
- bundler
- bundler 1.17.1
- pry
60 changes: 27 additions & 33 deletions test/integration/rubies_attributes/serverspec/chruby_build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,65 +42,59 @@
it { is_expected.to be_installed }
end

describe file('/opt/rubies/ruby-2.4.1') do
describe file('/opt/rubies/ruby-2.4.5') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'root' }
end

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -r rbconfig -e \'print RbConfig::CONFIG["configure_args"]\'') do
its(:stdout) { is_expected.to eq " '--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.4.1'" }
end
describe "ruby-2.4.5" do
before { command('chruby ruby-2.4.5') }

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -e \'print RUBY_VERSION\'') do
its(:stdout) { is_expected.to eq "2.4.1" }
end
describe command('ruby -r rbconfig -e \'print RbConfig::CONFIG["configure_args"]\'') do
its(:stdout) { is_expected.to eq " '--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.4.5'" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -r yaml -e \'print Psych::LIBYAML_VERSION\''), if: os[:release] == '12.04' do
its(:stdout) { is_expected.to eq "0.1.4" }
end
describe command('ruby -e \'print RUBY_VERSION\'') do
its(:stdout) { is_expected.to eq "2.4.5" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -r yaml -e \'print Psych::LIBYAML_VERSION\''), if: os[:release] == '14.04' do
its(:stdout) { is_expected.to eq "0.1.4" }
end
if os[:release] == '18.04'
describe command('ruby -r yaml -e \'print Psych::LIBYAML_VERSION\'') do
its(:stdout) { is_expected.to eq "0.1.7" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -r yaml -e \'print Psych::LIBYAML_VERSION\''), if: os[:release] == '16.04' do
its(:stdout) { is_expected.to eq "0.1.6" }
end
describe command('ruby -r openssl -e \'print OpenSSL::OPENSSL_LIBRARY_VERSION\'') do
its(:stdout) { is_expected.to eq "OpenSSL 1.1.0g 2 Nov 2017" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '12.04' do
its(:stdout) { is_expected.to eq "6.2" }
end
describe command('ruby -r readline -e \'print Readline::VERSION\'') do
its(:stdout) { is_expected.to eq "7.0" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '14.04' do
its(:stdout) { is_expected.to eq "6.3" }
describe command('ruby -r zlib -e \'print Zlib::ZLIB_VERSION\'') do
its(:stdout) { is_expected.to eq "1.2.11" }
end
end
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '16.04' do
its(:stdout) { is_expected.to eq "6.3" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.4.1 -- ruby -r openssl -e \'print OpenSSL::VERSION\'') do
its(:stdout) { is_expected.to eq "2.0.3" }
end

describe file('/opt/rubies/ruby-2.4.1/etc/gemrc') do
describe file('/opt/rubies/ruby-2.4.5/etc/gemrc') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_mode 644 }
end

describe package('bundler') do
it { is_expected.to be_installed.by('gem') }
it { is_expected.to be_installed.by('gem').with_version('1.17.1') }
end

describe package('pry') do
it { is_expected.to be_installed.by('gem') }
end

describe command('which bundle') do
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.4.1/bin/bundle\n" }
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.4.5/bin/bundle\n" }
end

describe command('which pry') do
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.4.1/bin/pry\n" }
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.4.5/bin/pry\n" }
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'serverspec'

set :backend, :exec
set :path, '$PATH:/sbin:/usr/sbin:/opt/rubies/ruby-2.4.1/bin'
set :path, '$PATH:/sbin:/usr/sbin:/opt/rubies/ruby-2.4.5/bin'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "ruby-2.3.4",
"url": "https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.gz",
"checksum": "98e18f17c933318d0e32fed3aea67e304f174d03170a38fd920c4fbe49fec0c3",
"id": "ruby-2.5.3",
"url": "https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.gz",
"checksum": "9828d03852c37c20fa333a0264f2490f07338576734d910ee3fd538c9520846c",
"gems": ["bundler 1.17.1", "pry"],
"environment": {
"ARCHFLAGS": "-arch x86_64",
Expand Down
60 changes: 37 additions & 23 deletions test/integration/rubies_data_bags/serverspec/chruby_build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
it { is_expected.to be_installed }
end

describe package('libunwind8'), if: os[:release] == '18.04' do
it { is_expected.to be_installed }
end

describe package('g++') do
it { is_expected.to be_installed }
end
Expand Down Expand Up @@ -62,49 +66,59 @@
it { is_expected.to be_installed }
end

describe file('/opt/rubies/ruby-2.3.4') do
describe file('/opt/rubies/ruby-2.5.3') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'root' }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r rbconfig -e \'print RbConfig::CONFIG["configure_args"]\'') do
its(:stdout) { is_expected.to eq " '--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.3.4' 'CFLAGS=-g -O2' 'LIBS=-ltcmalloc_minimal -lyaml' 'CPPFLAGS=-I/usr/include -I/usr/local/include'" }
end
describe "ruby-2.5.3" do
before { command('chruby ruby-2.5.3') }

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -e \'print RUBY_VERSION\'') do
its(:stdout) { is_expected.to eq "2.3.4" }
end
describe command('ruby -r rbconfig -e \'print RbConfig::CONFIG["configure_args"]\'') do
its(:stdout) { is_expected.to eq " '--disable-install-doc' '--enable-shared' '--with-opt-dir=/usr/local' '--prefix=/opt/rubies/ruby-2.5.3' '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.3.4 -- ruby -r yaml -e \'print Psych::LIBYAML_VERSION\'') do
its(:stdout) { is_expected.to eq "0.1.7" }
end
describe command('ruby -e \'print RUBY_VERSION\'') do
its(:stdout) { is_expected.to eq "2.5.3" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '12.04' do
its(:stdout) { is_expected.to eq "6.2" }
end
if os[:release] == '18.04'
describe command('ruby -r yaml -e \'print Psych::LIBYAML_VERSION\'') do
its(:stdout) { is_expected.to eq "0.2.1" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '14.04' do
its(:stdout) { is_expected.to eq "6.3" }
end
describe command('ruby -r openssl -e \'print OpenSSL::OPENSSL_LIBRARY_VERSION\'') do
its(:stdout) { is_expected.to eq "OpenSSL 1.1.0g 2 Nov 2017" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r readline -e \'print Readline::VERSION\''), if: os[:release] == '16.04' do
its(:stdout) { is_expected.to eq "6.3" }
end
describe command('ruby -r readline -e \'print Readline::VERSION\'') do
its(:stdout) { is_expected.to eq "7.0" }
end

describe command('/usr/local/bin/chruby-exec ruby-2.3.4 -- ruby -r openssl -e \'print OpenSSL::VERSION\'') do
its(:stdout) { is_expected.to eq "1.1.0" }
describe command('ruby -r zlib -e \'print Zlib::ZLIB_VERSION\'') do
its(:stdout) { is_expected.to eq "1.2.11" }
end
end
end

describe file('/opt/rubies/ruby-2.3.4/etc/gemrc') do
describe file('/opt/rubies/ruby-2.5.3/etc/gemrc') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_mode 644 }
end

describe package('bundler') do
it { is_expected.to be_installed.by('gem').with_version('1.17.1') }
end

describe package('pry') do
it { is_expected.to be_installed.by('gem') }
end

describe command('which bundle') do
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.3.4/bin/bundle\n" }
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.5.3/bin/bundle\n" }
end

describe command('which pry') do
its(:stdout) { is_expected.to eq "/opt/rubies/ruby-2.5.3/bin/pry\n" }
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'serverspec'

set :backend, :exec
set :path, '$PATH:/sbin:/usr/sbin:/opt/rubies/ruby-2.3.4/bin'
set :path, '$PATH:/sbin:/usr/sbin:/opt/rubies/ruby-2.5.3/bin'

0 comments on commit c5e28eb

Please sign in to comment.