1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Allow ENV to change make, qmake, and spec options.

This commit is contained in:
Matthew Mongeau 2012-01-27 10:26:05 -05:00
parent 2fef844031
commit 4a6b766b18
3 changed files with 72 additions and 12 deletions

View file

@ -5,21 +5,30 @@ module CapybaraWebkitBuilder
extend self
def make_bin
make_binaries = ['gmake', 'make']
make_binaries.detect { |make| system("which #{make}") }
ENV['MAKE'] || 'make'
end
def qmake_bin
ENV['QMAKE'] || 'qmake'
end
def spec
ENV['SPEC'] || os_spec
end
def os_spec
case RbConfig::CONFIG['host_os']
when /linux/
"linux-g++"
when /freebsd/
"freebsd-g++"
else
"macx-g++"
end
end
def makefile
qmake_binaries = ['qmake', 'qmake-qt4']
qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
case RbConfig::CONFIG['host_os']
when /linux/
system("#{qmake} -spec linux-g++")
when /freebsd/
system("#{qmake} -spec freebsd-g++")
else
system("#{qmake} -spec macx-g++")
end
system("#{qmake_bin} -spec #{spec}")
end
def qmake

View file

@ -0,0 +1,37 @@
require 'spec_helper'
require 'capybara_webkit_builder'
describe CapybaraWebkitBuilder do
let(:builder) { CapybaraWebkitBuilder }
it "will use the env variable for #make_bin" do
with_env_vars("MAKE" => "fake_make") do
builder.make_bin.should == "fake_make"
end
end
it "will use the env variable for #qmake_bin" do
with_env_vars("QMAKE" => "fake_qmake") do
builder.qmake_bin.should == "fake_qmake"
end
end
it "will use the env variable for #os_spec" do
with_env_vars("SPEC" => "fake_os_spec") do
builder.spec.should == "fake_os_spec"
end
end
it "defaults the #make_bin" do
builder.make_bin.should == 'make'
end
it "defaults the #qmake_bin" do
builder.qmake_bin.should == 'qmake'
end
it "defaults #spec to the #os_specs" do
builder.spec.should == builder.os_spec
end
end

View file

@ -23,3 +23,17 @@ $webkit_browser = Capybara::Driver::Webkit::Browser.new(:socket_class => TCPSock
Capybara.register_driver :reusable_webkit do |app|
Capybara::Driver::Webkit.new(app, :browser => $webkit_browser)
end
def with_env_vars(vars)
old_env_variable = {}
vars.each do |key, value|
old_env_variables[key] = ENV[key]
ENV[key] = value
end
yield
old_env_variables.each do |key, value|
ENV[key] = value
end
end