spec/backend/exec/build_command_spec.rb in specinfra-1.11.0 vs spec/backend/exec/build_command_spec.rb in specinfra-1.12.0
- old
+ new
@@ -33,58 +33,63 @@
describe 'check_os' do
context 'test ubuntu with lsb_release command' do
subject { backend.check_os }
it do
- mock_success_response = double(
- :run_command_response,
- :success? => true,
- :stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
- )
- mock_failure_response = double :run_command_response, :success? => false
backend.should_receive(:run_command).at_least(1).times do |args|
if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
- mock_success_response
+ double(
+ :run_command_response,
+ :success? => true,
+ :stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
+ )
+ elsif args == 'uname -m'
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
else
- mock_failure_response
+ double :run_command_response, :success? => false
end
end
- should eq({:family => 'Ubuntu', :release => '12.04'})
+ should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
end
end
context 'test ubuntu with /etc/lsb-release' do
subject { backend.check_os }
it do
- mock_success_response = double(
- :run_command_response,
- :success? => true,
- :stdout => %Q(DISTRIB_ID=Ubuntu
+ backend.should_receive(:run_command).at_least(1).times do |args|
+ if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
+ double(
+ :run_command_response,
+ :success? => true,
+ :stdout => <<-EOF
+DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
-)
- )
- mock_failure_response = double :run_command_response, :success? => false
- backend.should_receive(:run_command).at_least(1).times do |args|
- if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
- mock_success_response
+EOF
+ )
+ elsif args == 'uname -m'
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
else
- mock_failure_response
+ double :run_command_response, :success? => false
end
end
- should eq({:family => 'Ubuntu', :release => '12.04'})
+ should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
end
end
context 'test debian (no lsb_release or lsb-release)' do
subject { backend.check_os }
it do
- mock_success_response = double :run_command_response, :success? => true
- mock_failure_response = double :run_command_response, :success? => false
backend.should_receive(:run_command).at_least(1).times do |args|
- args == 'ls /etc/debian_version' ? mock_success_response : mock_failure_response
+ if args == 'ls /etc/debian_version'
+ double :run_command_response, :success? => true
+ elsif args == 'uname -m'
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
+ else
+ double :run_command_response, :success? => false
+ end
end
- should eq({:family => 'Debian', :release => nil})
+ should eq({:family => 'Debian', :release => nil, :arch => 'x86_64' })
end
end
end