Skip to content

Commit

Permalink
Refactor command_line tests to share before/after hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrous26 committed May 6, 2011
1 parent 4470c58 commit ff0cdc5
Showing 1 changed file with 50 additions and 47 deletions.
97 changes: 50 additions & 47 deletions spec/macruby/command_line/ruby_deploy_spec.rb
Expand Up @@ -42,7 +42,7 @@ def binaries
end
end

describe "The ruby_deploy --compile option" do
describe "ruby_deploy command line options:" do
extend DeploySpecHelper

before do
Expand All @@ -59,62 +59,65 @@ def binaries
rm_rf @dir
end

it "compiles the ruby source files in the app's Resources directory" do
deploy('--compile')
rbos.should_not be_empty
rbos.each do |rbo|
file(rbo).should include('Mach-O')
require rbo
describe "the --compile option" do
it "compiles the ruby source files in the app's Resources directory" do
deploy('--compile')
rbos.should_not be_empty
rbos.each do |rbo|
file(rbo).should include('Mach-O')
require rbo
end
# check that the classes defined in the rbos actually work
defined?(DummyModel).should == "constant"
defined?(DummyController).should == "constant"
end
# check that the classes defined in the rbos actually work
defined?(DummyModel).should == "constant"
defined?(DummyController).should == "constant"
end

it "does not compile the rb_main.rb file, because this name is hardcoded in the function that starts MacRuby" do
deploy('--compile')
rbos.map { |f| File.basename(f) }.should_not include('rb_main.rbo')
rbs.map { |f| File.basename(f) }.should include('rb_main.rb')
end
it "does not compile the rb_main.rb file, because this name is hardcoded in the function that starts MacRuby" do
deploy('--compile')
rbos.map { |f| File.basename(f) }.should_not include('rb_main.rbo')
rbs.map { |f| File.basename(f) }.should include('rb_main.rb')
end

it "removes the original source files after compilation" do
deploy('--compile')
rbs.map { |f| File.basename(f) }.should == %w{ rb_main.rb }
end
it "removes the original source files after compilation" do
deploy('--compile')
rbs.map { |f| File.basename(f) }.should == %w{ rb_main.rb }
end

it "does not change the install_name of binaries if the MacRuby framework is not embedded" do
deploy('--compile')
binaries.each do |bin|
install_name(bin).should_not include(DeploySpecHelper::EMBEDDED_FRAMEWORK)
it "does not change the install_name of binaries if the MacRuby framework is not embedded" do
deploy('--compile')
binaries.each do |bin|
install_name(bin).should_not include(DeploySpecHelper::EMBEDDED_FRAMEWORK)
end
end
end

it "changes the install_name of binaries to the embedded MacRuby framework" do
mkdir_p File.join(@app_bundle, 'Contents/Frameworks/MacRuby.framework')
deploy('--compile')
binaries.each do |bin|
install_name(bin).should include(DeploySpecHelper::EMBEDDED_FRAMEWORK)
it "changes the install_name of binaries to the embedded MacRuby framework" do
mkdir_p File.join(@app_bundle, 'Contents/Frameworks/MacRuby.framework')
deploy('--compile')
binaries.each do |bin|
install_name(bin).should include(DeploySpecHelper::EMBEDDED_FRAMEWORK)
end
end
end

# TODO is it safe to use `ppc7400' here?
it "retrieves the archs that the ruby files should be compiled for from ENV['ARCHS'] and aborts if that leaves no options" do
before, ENV['ARCHS'] = ENV['ARCHS'], 'ppc7400'
begin
deploy('--compile').should =~ /Can't build for.+?ppc7400/
$?.success?.should == false
ensure
ENV['ARCHS'] = before
# TODO is it safe to use `ppc7400' here?
it "retrieves the archs that the ruby files should be compiled for from ENV['ARCHS'] and aborts if that leaves no options" do
before, ENV['ARCHS'] = ENV['ARCHS'], 'ppc7400'
begin
deploy('--compile').should =~ /Can't build for.+?ppc7400/
$?.success?.should == false
ensure
ENV['ARCHS'] = before
end
end
end

# TODO is it safe to use `ppc' here?
it "retrieves the arch that the ruby files should be compiled for from the app binary and skips those that can't be used" do
# copy the system ruby binary which, amongst others, contains `ppc'
rm File.join(@app_bundle, 'Contents/MacOS/Dummy')
cp '/usr/bin/ruby', File.join(@app_bundle, 'Contents/MacOS/Dummy')
# TODO is it safe to use `ppc' here?
it "retrieves the arch that the ruby files should be compiled for from the app binary and skips those that can't be used" do
# copy the system ruby binary which, amongst others, contains `ppc'
rm File.join(@app_bundle, 'Contents/MacOS/Dummy')
cp '/usr/bin/ruby', File.join(@app_bundle, 'Contents/MacOS/Dummy')

deploy('--compile').should =~ /Can't build for.+?ppc7400/
$?.success?.should == true
deploy('--compile').should =~ /Can't build for.+?ppc7400/
$?.success?.should == true
end
end

end

0 comments on commit ff0cdc5

Please sign in to comment.