diff options
author | Luis Lavena <luislavena@gmail.com> | 2009-03-21 23:08:14 -0300 |
---|---|---|
committer | Luis Lavena <luislavena@gmail.com> | 2009-03-21 23:08:14 -0300 |
commit | 2a83029f54be9b8803658afb515b62bd6fa8b9e9 (patch) | |
tree | 018f56445f9717f54b2c77e41cd4e105406e6954 /spec | |
parent | 18c73cc0e91ced20f7de453bf02eec6867376b62 (diff) | |
download | rake-compiler-2a83029f54be9b8803658afb515b62bd6fa8b9e9.tar.gz |
Implement Ruby version faker.
During cross compilation, rake-compiler will create a fake.rb
file to mimic a different version than the one used to execute
the build process.
Yet still, there are some changes between 1.9 and 1.8 not yet
ironed.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/rake/extensiontask_spec.rb | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/spec/lib/rake/extensiontask_spec.rb b/spec/lib/rake/extensiontask_spec.rb index e0d7eae..eb385b6 100644 --- a/spec/lib/rake/extensiontask_spec.rb +++ b/spec/lib/rake/extensiontask_spec.rb @@ -261,6 +261,8 @@ describe Rake::ExtensionTask do @config_file = File.expand_path("~/.rake-compiler/config.yml") @ruby_ver = RUBY_VERSION @config_path = mock_config_yml["rbconfig-#{@ruby_ver}"] + + File.stub!(:open).and_yield(mock_fake_rb) end it 'should not generate an error if no rake-compiler configuration exist' do @@ -294,16 +296,17 @@ describe Rake::ExtensionTask do config = mock(Hash) config.should_receive(:[]).with("rbconfig-1.9.1").and_return('/path/to/ruby/1.9.1/rbconfig.rb') YAML.stub!(:load_file).and_return(config) - begin - ENV['RUBY_CC_VERSION'] = '1.9.1' - Rake::ExtensionTask.new('extension_one') do |ext| - ext.cross_compile = true - end - ensure - ENV.delete('RUBY_CC_VERSION') + + ENV['RUBY_CC_VERSION'] = '1.9.1' + Rake::ExtensionTask.new('extension_one') do |ext| + ext.cross_compile = true end end + after :each do + ENV.delete('RUBY_CC_VERSION') + end + describe "(cross for 'universal-unknown' platform)" do before :each do @ext = Rake::ExtensionTask.new('extension_one', @spec) do |ext| @@ -312,6 +315,12 @@ describe Rake::ExtensionTask do end end + describe 'fake' do + it 'should chain fake task to Makefile generation' do + Rake::Task['tmp/universal-unknown/extension_one/Makefile'].prerequisites.should include('tmp/universal-unknown/extension_one/fake.rb') + end + end + describe 'rbconfig' do it 'should chain rbconfig tasks to Makefile generation' do Rake::Task['tmp/universal-unknown/extension_one/Makefile'].prerequisites.should include('tmp/universal-unknown/extension_one/rbconfig.rb') @@ -359,7 +368,12 @@ describe Rake::ExtensionTask do def mock_config_yml { 'rbconfig-1.8.6' => '/some/path/version/1.8/to/rbconfig.rb', - 'rbconfig-1.9.1' => '/some/path/version/1.9.1/to/rbconfig.rb' + 'rbconfig-1.9.1' => '/some/path/version/1.9.1/to/rbconfig.rb', + 'rbconfig-3.0.0' => '/some/fake/version/3.0.0/to/rbconfig.rb' } end + + def mock_fake_rb + mock(File, :write => 45) + end end |