Module: CukeTest::Helpers

Defined in:
lib/cuke-test/helpers.rb

Instance Method Summary collapse

Instance Method Details

#feature(feature_file, scenario = nil) ⇒ Object

Runs the feature file (and optionally just one scenario therein) through Cucumber. Returns Cucumber’s output as a string.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cuke-test/helpers.rb', line 5

def feature(feature_file, scenario = nil)
  out = StringIO.new
  errors = StringIO.new
  if features_path = CukeTest.config.features_path
    feature_file = File.join(features_path, feature_file)
  end
  cli_args = [feature_file, '--no-color']
  if scenario
    cli_args += ['--name', '"' + scenario + '"']
  end
  `cucumber #{cli_args.join(' ')}` # This works
end

#scenario(feature_file, scenario) ⇒ Object

Runs the one scenario in the feature file through Cucumber. Returns Cucumber’s output as a string.



20
21
22
# File 'lib/cuke-test/helpers.rb', line 20

def scenario(feature_file, scenario)
  feature(feature_file, scenario)
end