Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 4a6b766b1840ddd04a053762b779fdcfd5d10592 1 parent 2fef844
Matthew Mongeau halogenandtoast authored
25 lib/capybara_webkit_builder.rb
View
@@ -5,23 +5,32 @@ module CapybaraWebkitBuilder
extend self
def make_bin
- make_binaries = ['gmake', 'make']
- make_binaries.detect { |make| system("which #{make}") }
+ ENV['MAKE'] || 'make'
end
- def makefile
- qmake_binaries = ['qmake', 'qmake-qt4']
- qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
+ def qmake_bin
+ ENV['QMAKE'] || 'qmake'
+ end
+
+ def spec
+ ENV['SPEC'] || os_spec
+ end
+
+ def os_spec
case RbConfig::CONFIG['host_os']
when /linux/
- system("#{qmake} -spec linux-g++")
+ "linux-g++"
when /freebsd/
- system("#{qmake} -spec freebsd-g++")
+ "freebsd-g++"
else
- system("#{qmake} -spec macx-g++")
+ "macx-g++"
end
end
+ def makefile
+ system("#{qmake_bin} -spec #{spec}")
+ end
+
def qmake
system("#{make_bin} qmake")
end
37 spec/capybara_webkit_builder_spec.rb
View
@@ -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
+
14 spec/spec_helper.rb
View
@@ -23,3 +23,17 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.