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.



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

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)


74
75
76
77
78
# File 'lib/cucumber/rake/task.rb', line 74

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

#cmdObject



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

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



62
63
64
# File 'lib/cucumber/rake/task.rb', line 62

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

#quoted_binary(cucumber_bin) ⇒ Object



66
67
68
# File 'lib/cucumber/rake/task.rb', line 66

def quoted_binary(cucumber_bin)
  [format('"%<path>s"', path: cucumber_bin)]
end

#runObject



94
95
96
97
98
# File 'lib/cucumber/rake/task.rb', line 94

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

#use_bundlerObject



70
71
72
# File 'lib/cucumber/rake/task.rb', line 70

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