Class: Cucumber::Rake::Task::ForkedCucumberRunner

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/cucumber/rake/task.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files) ⇒ ForkedCucumberRunner

Returns a new instance of ForkedCucumberRunner.



56
57
58
59
60
61
62
# File 'lib/cucumber/rake/task.rb', line 56

def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
  @libs          = libs
  @cucumber_bin  = cucumber_bin
  @cucumber_opts = cucumber_opts
  @bundler       = bundler
  @feature_files = feature_files
end

Instance Method Details

#bundler_gem_available?Boolean

Returns:

  • (Boolean)


76
77
78
79
80
# File 'lib/cucumber/rake/task.rb', line 76

def bundler_gem_available?
  Gem::Specification.find_by_name('bundler')
rescue Gem::LoadError
  false
end

#cmdObject



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cucumber/rake/task.rb', line 82

def cmd
  if use_bundler
    [
      Cucumber::RUBY_BINARY,'-S', 'bundle', 'exec', 'cucumber',
      @cucumber_opts, @feature_files
    ].flatten
  else
    [
      Cucumber::RUBY_BINARY, '-I', load_path,
      quoted_binary(@cucumber_bin), @cucumber_opts, @feature_files
    ].flatten
  end
end

#load_pathObject



64
65
66
# File 'lib/cucumber/rake/task.rb', line 64

def load_path
  [format('"%s"', @libs.join(File::PATH_SEPARATOR))]
end

#quoted_binary(cucumber_bin) ⇒ Object



68
69
70
# File 'lib/cucumber/rake/task.rb', line 68

def quoted_binary(cucumber_bin)
  [format('"%s"', cucumber_bin)]
end

#runObject



96
97
98
99
100
101
102
# File 'lib/cucumber/rake/task.rb', line 96

def run
  sh cmd.join(' ') do |ok, res|
    if !ok
      exit res.exitstatus
    end
  end
end

#use_bundlerObject



72
73
74
# File 'lib/cucumber/rake/task.rb', line 72

def use_bundler
  @bundler.nil? ? File.exist?('./Gemfile') && bundler_gem_available? : @bundler
end