gurke 2.0.0.dev.1.b20 → 2.0.0.dev.1.b22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2IyOGUyNzJiNTkzNTU2NzJmNjE0ZTMwZTVkOTI2ZTY1ZjMyMDE1YQ==
4
+ YWJlYzFiZWQxMTE4MTZmMjllZmM0YzU0MGQ1YzgyMDNiOTMyNGM4MQ==
5
5
  data.tar.gz: !binary |-
6
- MWJhZmU4M2U4ODZmNDYxMDRlMWFhZjgzZDU4Y2NjMGFlNTNjYjgzYQ==
6
+ YTAyNjdlOWM2YzU5ZDZlNWJiMDk2MzJiM2RkZDM4ZDE3NGRmOGZhMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Nzc2YzQ3OTlkYTAzNzk2MThlNjU1NGZhZWQ2NDM5ZDM0Y2I3YzM4ODFjODE2
10
- MTRiYjk0NjQxNzY5Yzk1YWE5YjdjNjVlODFjZWI0MWQ5MmRmMzRmNGUxZjRk
11
- NWYzN2FjMWMzZDg3NTk4NmQxODlmYjFjZTEyYmQxYjMxMzQzZjQ=
9
+ ODdhM2NkMjk4NmIwOTQ2Y2Y5NjkzMDdkMjlmMWMzNDJkMzEzOGY3NWUyZDZk
10
+ NmJmY2Y5MTA2ODk1NWM5MDY3OGE0ZDBhZmZlNGEwNTY1ODk0MDIyNTFhOTI4
11
+ ODc2YjVlZTZkZDE1MDU1ODU3OTQxMGQyN2FhYTlkMzJmNmIyZjM=
12
12
  data.tar.gz: !binary |-
13
- YjU1ZDI0NzlkM2FjZTllZjkzZjNiYjNkZmY2ZmFlNTQ0NTkwN2M4ZjJmYWY4
14
- OTFiMWMzYTlhNTE0ZjY4YWQ4MGYwMmMzZGMwOWRlYWFmMWIyNWVjNTY5NjVj
15
- ZThkNmQzMDMwYzEzYzFmMzQxNGU4MGZlMzkwYzZkYTlhNTEwMzE=
13
+ ODJjODY1NmJlZDIxOGUzNWVkY2YwMWQ2NjlmY2MwMjY5ZmJkZTEzNDNkOGMw
14
+ MjgzZDdjNzJkZGEzMmMxZWY2NDJkOGU5OGFjM2Q5N2E3MTQ5ZDljZGNjZTI2
15
+ NDc5YTJiN2Q5MmMzODcwZTI2MGZmNjVlNDIxMGEzYjZlODc2MTE=
@@ -47,4 +47,4 @@ module CLISteps
47
47
  end
48
48
  end
49
49
 
50
- Gurke.configure{|c| c.include CLISteps }
50
+ Gurke.config.include CLISteps
@@ -8,14 +8,21 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Gurke::VERSION
9
9
  spec.authors = ['Jan Graichen']
10
10
  spec.email = %w(jg@altimos.de)
11
- spec.description = %q{An alternative gherkin feature runner inspired by rspec and turnip.}
12
- spec.summary = %q{An alternative gherkin feature runner inspired by rspec and turnip.}
13
11
  spec.homepage = 'https://github.com/jgraichen/gurke'
14
12
  spec.license = 'MIT'
15
13
 
16
- spec.files = Dir['**/*'].grep(%r{^((bin|lib|test|spec|features)/|.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)})
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.description = \
15
+ %q(An alternative gherkin feature runner inspired by rspec and turnip.)
16
+ spec.summary = \
17
+ %q(An alternative gherkin feature runner inspired by rspec and turnip.)
18
+
19
+ spec.files = Dir['**/*'].grep %r{^(
20
+ (bin/|lib/|test/|spec/|features/)|
21
+ (\w*\.gemspec|LICENSE.*|README.*|CHANGELOG.*)$
22
+ )}x
23
+
24
+ spec.executables = spec.files.grep(/^bin\//) {|f| File.basename(f) }
25
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
26
  spec.require_paths = %w(lib)
20
27
 
21
28
  spec.add_dependency 'trollop'
@@ -24,6 +31,8 @@ Gem::Specification.new do |spec|
24
31
 
25
32
  spec.add_development_dependency 'bundler', '~> 1.3'
26
33
 
27
- # Append travis build number for auto-releases
28
- spec.version = "#{spec.version}.1.b#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS_BUILD_NUMBER']
34
+ if ENV['TRAVIS_BUILD_NUMBER']
35
+ # Append travis build number for auto-releases
36
+ spec.version = "#{spec.version}.1.b#{ENV['TRAVIS_BUILD_NUMBER']}"
37
+ end
29
38
  end
@@ -1,6 +1,5 @@
1
1
  require 'gurke/version'
2
2
 
3
- #
4
3
  module Gurke
5
4
  require 'gurke/feature'
6
5
  require 'gurke/background'
@@ -62,4 +61,4 @@ module Gurke
62
61
  end
63
62
  end
64
63
 
65
- ::Module.send(:include, Gurke::DSL)
64
+ ::Module.send :include, Gurke::DSL
@@ -1,9 +1,7 @@
1
1
  require 'gherkin'
2
2
 
3
3
  module Gurke
4
- #
5
4
  class Builder
6
- #
7
5
  attr_reader :features, :options
8
6
 
9
7
  def initialize(options)
@@ -1,7 +1,6 @@
1
1
  require 'trollop'
2
2
 
3
3
  module Gurke
4
- #
5
4
  class CLI
6
5
  #
7
6
  # Run CLI with given arguments.
@@ -45,6 +44,7 @@ module Gurke
45
44
  parser.educate($stdout)
46
45
  end
47
46
 
47
+ # rubocop:disable MethodLength
48
48
  def parser
49
49
  @parser ||= Trollop::Parser.new do
50
50
  opt :help, 'Print this help.'
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Configuration
4
3
  #
5
4
  # Define a before filter running before given action.
@@ -106,7 +105,7 @@ module Gurke
106
105
 
107
106
  def run(world, &block)
108
107
  @before.each{|hook| hook.run world }
109
- @around.reduce(block){|blk, hook| proc{ hook.run world, blk }}.call
108
+ @around.reduce(block){|a, e| proc{ e.run world, a }}.call
110
109
  ensure
111
110
  @after.each do |hook|
112
111
  begin
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  module DSL
4
3
  def step(pattern, method_name = nil, opts = {}, &block)
5
4
  if method_name.is_a?(Hash) && opts.empty?
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Feature
4
3
  #
5
4
  # Return path to file containing this feature.
@@ -1,12 +1,17 @@
1
1
  require 'colorize'
2
2
 
3
- # Colorize colors:
3
+ # Colors
4
4
  # :black, :red, :green, :yellow, :blue,
5
5
  # :magenta, :cyan, :white, :default, :light_black,
6
6
  # :light_red, :light_green, :light_yellow, :light_blue,
7
7
  # :light_magenta, :light_cyan, :light_white
8
-
8
+ #
9
9
  module Gurke::Reporters
10
+ #
11
+ # The {DefaultReporter} prints features, scenarios and
12
+ # steps while they are executed.
13
+ #
14
+ # That includes colorized step results reports etc.
10
15
  #
11
16
  class DefaultReporter < NullReporter
12
17
  def before_feature(feature)
@@ -37,21 +42,10 @@ module Gurke::Reporters
37
42
 
38
43
  def after_step(step, *)
39
44
  case step.state
40
- when :pending
41
- print_braces yellow('pending')
42
- when :failed
43
- print_braces red('failure')
44
- io.puts
45
- io.puts red(" #{step.exception.class}:")
46
-
47
- msg = step.exception.message.split("\n").join("\n ")
48
- io.puts red(" #{msg}")
49
-
50
- io.puts red(" #{step.exception.backtrace.join("\n ")}")
51
- when :success
52
- print_braces green('success')
53
- else
54
- print_braces cyan('skipped')
45
+ when :pending then print_braces yellow 'pending'
46
+ when :failed then print_failed step
47
+ when :success then print_braces green 'success'
48
+ else print_braces cyan 'skipped'
55
49
  end
56
50
  io.puts
57
51
  io.flush
@@ -68,8 +62,8 @@ module Gurke::Reporters
68
62
  def after_features(features)
69
63
  scenarios = features.map(&:scenarios).flatten
70
64
 
71
- io.puts " #{scenarios.size} scenarios: "\
72
- "#{scenarios.select(&:failed?).size} failing, "\
65
+ io.puts " #{scenarios.size} scenarios: " \
66
+ "#{scenarios.select(&:failed?).size} failing, " \
73
67
  "#{scenarios.select(&:pending?).size} pending"
74
68
  io.puts
75
69
  end
@@ -80,6 +74,16 @@ module Gurke::Reporters
80
74
  io.print " (#{str})"
81
75
  end
82
76
 
77
+ def print_failed(step)
78
+ print_braces red('failure')
79
+ io.puts
80
+ msg = step.exception.message.split("\n").join("\n ")
81
+
82
+ io.puts red(" #{step.exception.class}:")
83
+ io.puts red(" #{msg}")
84
+ io.puts red(" #{step.exception.backtrace.join("\n ")}")
85
+ end
86
+
83
87
  def io
84
88
  $stdout
85
89
  end
@@ -1,6 +1,6 @@
1
1
  module Gurke::Reporters
2
2
  #
3
- # The {NullReporter} does not output anything.
3
+ # The {NullReporter} does not do anything.
4
4
  #
5
5
  class NullReporter < Gurke::Reporter
6
6
  Gurke::Reporter::CALLBACKS.each do |cb|
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Runner
4
3
  attr_reader :builder
5
4
  attr_reader :files
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Scenario
4
3
  #
5
4
  # Return path to file containing this scenario.
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Step
4
3
  #
5
4
  # Return path to file containing this scenario.
@@ -55,28 +54,30 @@ module Gurke
55
54
  def run_step(runner, reporter, scenario, world)
56
55
  reporter.invoke :start_step, self, scenario
57
56
 
58
- result = nil
57
+ result = find_and_run_step runner, scenario, world
58
+ rescue StepPending => e
59
+ scenario.pending! e
60
+ result = StepResult.new self, :pending, e
61
+ rescue => e
62
+ scenario.failed! e
63
+ result = StepResult.new self, :failed, e
64
+ ensure
65
+ reporter.invoke :end_step, result, scenario
66
+ end
67
+
68
+ def find_and_run_step(runner, scenario, world)
59
69
  runner.with_filtered_backtrace do
60
70
  match = Steps.find_step self, world, type
61
71
 
62
72
  if scenario.pending? || scenario.failed?
63
- result = StepResult.new self, :skipped
64
- return result
73
+ return StepResult.new self, :skipped
65
74
  end
66
75
 
67
76
  m = world.method match.method_name
68
77
  world.send match.method_name, *(match.params + [self])[0...m.arity]
69
- end
70
78
 
71
- result = StepResult.new self, :success
72
- rescue StepPending => e
73
- scenario.pending! e
74
- result = StepResult.new self, :pending, e
75
- rescue => e
76
- scenario.failed! e
77
- result = StepResult.new self, :failed, e
78
- ensure
79
- reporter.invoke :end_step, result, scenario
79
+ StepResult.new self, :success
80
+ end
80
81
  end
81
82
 
82
83
  #
@@ -1,7 +1,5 @@
1
1
  module Gurke
2
- #
3
2
  class StepDefinition
4
- #
5
3
  attr_reader :pattern, :method_name, :opts
6
4
 
7
5
  def initialize(pattern, opts = {})
@@ -1,8 +1,7 @@
1
+ # rubocop:disable MethodName
2
+
1
3
  module Gurke
2
- #
3
4
  module Steps
4
- #
5
- # rubocop:disable MethodName
6
5
  def Given(step)
7
6
  rst = self.class.find_step(step, self, :given)
8
7
  send rst.method_name
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  class Tag
4
3
  #
5
4
  # Return path to file containing this feature.
@@ -1,5 +1,4 @@
1
1
  module Gurke
2
- #
3
2
  module VERSION
4
3
  MAJOR = 2
5
4
  MINOR = 0
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gurke::FeatureList do
4
+ let(:reporter) { Gurke::Reporters::NullReporter.new }
5
+ let(:runner) { double 'runner' }
6
+ let(:feature) { double 'feature' }
7
+
8
+ before do
9
+ features << feature
10
+
11
+ allow(runner).to receive(:hook) {|_, _, &block| block.call }
12
+ allow(feature).to receive(:failed?).and_return false
13
+ allow(feature).to receive(:pending?).and_return false
14
+ allow(feature).to receive(:run)
15
+ end
16
+
17
+ let(:features) { Gurke::FeatureList.new }
18
+
19
+ describe '#run' do
20
+ subject { features.run runner, reporter }
21
+
22
+ it 'should run all features' do
23
+ expect(feature).to receive(:run).with(runner, reporter)
24
+
25
+ subject
26
+ end
27
+
28
+ it 'should run hooks' do
29
+ expect(runner).to receive(:hook) do |scope, world|
30
+ expect(scope).to eq :features
31
+ expect(world).to eq nil
32
+ end
33
+
34
+ subject
35
+ end
36
+
37
+ it 'should run reporter callbacks in correct order' do
38
+ expect(reporter).to receive(:invoke).exactly(4).times do |*args|
39
+ @scopes ||= []
40
+ @scopes << args.first
41
+ end
42
+
43
+ subject
44
+
45
+ expect(@scopes).to eq [:before_features, :start_features,
46
+ :end_features, :after_features]
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gurke::RunList do
4
+ let(:reporter) { Gurke::Reporters::NullReporter.new }
5
+ let(:runner) { double 'runner' }
6
+ let(:object) { double 'object' }
7
+ let(:list) { Gurke::RunList.new }
8
+
9
+ before do
10
+ list << object
11
+ allow(object).to receive(:run)
12
+ end
13
+
14
+ describe '#run' do
15
+ subject { list.run runner, reporter }
16
+
17
+ it 'should run all objects' do
18
+ expect(object).to receive(:run).with(runner, reporter)
19
+ subject
20
+ end
21
+
22
+ context 'with additional args' do
23
+ subject { list.run runner, reporter, 0, :sym }
24
+
25
+ it 'should pass additional args' do
26
+ expect(object).to receive(:run).with(runner, reporter, 0, :sym)
27
+ subject
28
+ end
29
+ end
30
+ end
31
+ end
@@ -9,7 +9,7 @@ describe Gurke::Scenario do
9
9
  before do
10
10
  allow(feature).to receive(:backgrounds).ordered.and_return(backgrounds)
11
11
  allow(backgrounds).to receive(:run)
12
- allow(runner).to receive(:hook){|_,_,&block| block.call }
12
+ allow(runner).to receive(:hook) {|_, _, &block| block.call }
13
13
  end
14
14
 
15
15
  let(:scenario) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gurke
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.dev.1.b20
4
+ version: 2.0.0.dev.1.b22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
@@ -106,6 +106,8 @@ files:
106
106
  - lib/gurke/steps.rb
107
107
  - lib/gurke/tag.rb
108
108
  - lib/gurke/version.rb
109
+ - spec/gurke/feature_list_spec.rb
110
+ - spec/gurke/run_list_spec.rb
109
111
  - spec/gurke/scenario_spec.rb
110
112
  - spec/spec_helper.rb
111
113
  homepage: https://github.com/jgraichen/gurke
@@ -140,5 +142,7 @@ test_files:
140
142
  - features/gurke/step_specific_definitions.feature
141
143
  - features/support/steps/cli_steps.rb
142
144
  - features/support/steps/file_steps.rb
145
+ - spec/gurke/feature_list_spec.rb
146
+ - spec/gurke/run_list_spec.rb
143
147
  - spec/gurke/scenario_spec.rb
144
148
  - spec/spec_helper.rb