Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #27 from hedgehog/binstubs

guard cucumber binstubs option (matches guard-rspec behavior).
  • Loading branch information...
commit 88ac4da0f5b27db967a344dd68079cf13b1918b0 2 parents fa340b3 + 82ab90b
@netzpirat netzpirat authored
View
3  README.md
@@ -70,6 +70,9 @@ Former `:color`, `:drb`, `:port` and `:profile` options are thus deprecated and
:bundler => false # Don't use "bundle exec" to run the Cucumber command
# default: true
+:binstubs => true # use "bin/cucumber" to run the Cucumber command (implies :bundler => true)
+ # default: false
+
:rvm => ['1.8.7', '1.9.2'] # Directly run your features on multiple ruby versions
# default: nil
View
15 lib/guard/cucumber/runner.rb
@@ -18,7 +18,7 @@ class << self
def run(paths, options = { })
return false if paths.empty?
- message = options[:message] || (paths == ['features'] ? 'Run all Cucumber features' : "Run Cucumber features #{ paths.join(' ') }")
+ message = options[:message] || (paths == ['features'] ? "Running all Cucumber features: #{ cucumber_command(paths, options) }" : "Running Cucumber features: #{ cucumber_command(paths, options) }")
UI.info message, :reset => true
system(cucumber_command(paths, options))
@@ -38,9 +38,8 @@ def run(paths, options = { })
def cucumber_command(paths, options)
cmd = []
cmd << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
- cmd << 'bundle exec' if bundler? && options[:bundler] != false
-
- cmd << 'cucumber'
+ cmd << 'bundle exec' if (bundler? && options[:bundler] != false) || (bundler? && options[:binstubs].is_a?(TrueClass))
+ cmd << cucumber_exec(options)
cmd << options[:cli] if options[:cli]
if options[:notification] != false
@@ -54,6 +53,14 @@ def cucumber_command(paths, options)
(cmd + paths).join(' ')
end
+ # Simple test if binstubs prefix should be used.
+ #
+ # @return [String] Cucumber executable
+ #
+ def cucumber_exec(options = {})
+ options[:binstubs] == true && ( bundler? || options[:bundler] != false ) ? "bin/cucumber" : "cucumber"
+ end
+
# Simple test if bundler should be used. it just checks for the `Gemfile`.
#
# @return [Boolean] bundler exists
View
39 spec/guard/cucumber/runner_spec.rb
@@ -29,6 +29,45 @@
end
end
+ describe ":binstubs" do
+ it "runs without Bundler with binstubs option to true and bundler option to false" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :bundler => false, :binstubs => true)
+ end
+ it "runs with Bundler and binstubs with bundler option to true and binstubs option to true" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :bundler => true, :binstubs => true)
+ end
+ it "runs with Bundler and binstubs with bundler option unset and binstubs option to true" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :binstubs => true)
+ end
+ it "runs with Bundler and binstubs with bundler option unset, binstubs option to true and all_after_pass option to true" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :binstubs => true, :all_after_pass => true)
+ end
+ it "runs with Bundler and binstubs with bundler option unset, binstubs option to true and all_on_start option to true" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :binstubs => true, :all_on_start => true)
+ end
+ it "runs with Bundler and binstubs with bundler option unset, binstubs option to true, all_on_start option to true and all_after_pass option to true" do
+ subject.should_receive(:system).with(
+ "bundle exec bin/cucumber --require #{ @lib_path.join('guard/cucumber/notification_formatter.rb') } --format Guard::Cucumber::NotificationFormatter --out #{ null_device } --require features features"
+ ).and_return(true)
+ subject.run(["features"], :binstubs => true, :all_after_pass => true, :all_on_start => true)
+ end
+ end
+
context 'with a :cli option' do
it 'appends the cli arguments when calling cucumber' do
runner.should_receive(:system).with(
Please sign in to comment.
Something went wrong with that request. Please try again.