2011-07-18 14:52:57 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'qt/qmake'
|
|
|
|
require 'rbconfig'
|
2011-07-30 01:33:19 +00:00
|
|
|
require 'rubygems/version'
|
2011-07-18 14:52:57 +00:00
|
|
|
|
|
|
|
describe Qt::Qmake do
|
|
|
|
describe '.make_installed?' do
|
|
|
|
subject { described_class }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Qt::Qmake.stubs(:make_path).returns(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'not installed' do
|
|
|
|
let(:path) { nil }
|
|
|
|
|
|
|
|
it { should_not be_make_installed }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'installed' do
|
|
|
|
let(:path) { '/here/there/make' }
|
|
|
|
|
|
|
|
it { should be_make_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.installed?' do
|
|
|
|
subject { described_class }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Qt::Qmake.stubs(:path).returns(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'not installed' do
|
|
|
|
let(:path) { nil }
|
|
|
|
|
|
|
|
it { should_not be_installed }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'installed' do
|
|
|
|
let(:path) { '/here/there/qmake' }
|
|
|
|
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.command' do
|
|
|
|
subject { described_class.command }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Qt::Qmake.stubs(:platform).returns(platform)
|
|
|
|
Qt::Qmake.stubs(:path).returns("qmake")
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'linux' do
|
|
|
|
let(:platform) { :linux }
|
|
|
|
|
2011-08-26 15:18:04 +00:00
|
|
|
it { should =~ /^qmake/ }
|
|
|
|
it { should =~ /-spec linux-g\+\+$/ }
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'mac os x' do
|
|
|
|
let(:platform) { :mac_os_x }
|
|
|
|
|
2011-08-26 15:18:04 +00:00
|
|
|
it { should =~ /^qmake/ }
|
|
|
|
it { should =~ /-spec macx-g\+\+$/ }
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
describe '.best_qmake' do
|
2011-07-18 14:52:57 +00:00
|
|
|
before do
|
2011-07-30 01:33:19 +00:00
|
|
|
Qt::Qmake.stubs(:get_exe_path).with('qmake-qt4').returns(path_one)
|
|
|
|
Qt::Qmake.stubs(:get_exe_path).with('qmake').returns(path_two)
|
|
|
|
|
|
|
|
Qt::Qmake.stubs(:qt_version_of).with(path_one).returns(Gem::Version.create(version_one))
|
|
|
|
Qt::Qmake.stubs(:qt_version_of).with(path_two).returns(Gem::Version.create(version_two))
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
subject { described_class.best_qmake }
|
|
|
|
|
|
|
|
let(:path_one) { nil }
|
|
|
|
let(:path_two) { nil }
|
|
|
|
let(:version_one) { nil }
|
|
|
|
let(:version_two) { nil }
|
|
|
|
|
|
|
|
context 'nothing found' do
|
|
|
|
it { should be_nil }
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
context 'one found' do
|
|
|
|
let(:path_one) { 'one' }
|
|
|
|
|
|
|
|
context 'not good' do
|
|
|
|
let(:version_one) { '4.5' }
|
|
|
|
|
|
|
|
it { should be_nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'good' do
|
|
|
|
let(:version_one) { '4.7' }
|
2011-07-18 14:52:57 +00:00
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
it { should == path_one }
|
|
|
|
end
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
context 'two found' do
|
|
|
|
let(:path_one) { 'one' }
|
|
|
|
let(:path_two) { 'two' }
|
|
|
|
|
|
|
|
context 'neither good' do
|
|
|
|
let(:version_one) { '4.5' }
|
|
|
|
let(:version_two) { '4.5' }
|
|
|
|
|
|
|
|
it { should be_nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'one good' do
|
|
|
|
let(:version_one) { '4.7' }
|
|
|
|
let(:version_two) { '4.5' }
|
|
|
|
|
|
|
|
it { should == path_one }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'both good' do
|
|
|
|
context 'one better' do
|
|
|
|
let(:version_one) { '4.7' }
|
|
|
|
let(:version_two) { '4.8' }
|
|
|
|
|
|
|
|
it { should == path_two }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'both same' do
|
|
|
|
let(:version_one) { '4.7' }
|
|
|
|
let(:version_two) { '4.7' }
|
2011-07-18 14:52:57 +00:00
|
|
|
|
2011-07-30 01:33:19 +00:00
|
|
|
it { should == path_one }
|
|
|
|
end
|
|
|
|
end
|
2011-07-18 14:52:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|