gurke 3.3.3 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,110 +1,100 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable MissingCopEnableDirective
4
- # rubocop:disable Style/Semicolon
3
+ # rubocop:disable Lint/MissingCopEnableDirective
5
4
 
6
5
  require 'spec_helper'
7
6
 
8
7
  RSpec.describe Gurke::Reporters::TeamCityReporter do
9
- let(:output) { StringIO.new }
10
- let(:reporter) { described_class.new(output) }
8
+ subject(:statements) do
9
+ reporter = described_class.new(StringIO.new)
10
+ reporter.send(*action)
11
+ reporter.io.string.scan(/##teamcity\[.*\]/)
12
+ end
11
13
 
12
- subject { output.string.scan(/##teamcity\[.*\]/) }
14
+ let(:feature) { instance_double(Gurke::Feature) }
15
+ let(:scenario) { instance_double(Gurke::Scenario) }
16
+ let(:step) { instance_double(Gurke::Step) }
13
17
 
14
18
  describe '#before_feature' do
15
- let(:feature) { double('feature') }
19
+ let(:action) { [:before_feature, feature] }
16
20
 
17
21
  before do
18
- allow(feature).to receive(:name).and_return 'Demo feature'
19
- allow(feature).to receive(:file).and_return \
20
- File.join(Dir.getwd, 'features', 'file.feature')
21
- allow(feature).to receive(:line).and_return 1
22
- allow(feature).to receive(:description).and_return \
23
- "As a developer\nI would like have this spec passed\nIn order to work on"
22
+ allow(feature).to receive_messages(name: 'Demo feature', file: File.join(Dir.getwd, 'features', 'file.feature'),
23
+ line: 1, description: <<~DESC.strip,)
24
+ As a developer
25
+ I would like have this spec passed
26
+ In order to work on
27
+ DESC
24
28
  end
25
29
 
26
- subject { reporter.before_feature(feature); super() }
27
-
28
30
  it 'include a testSuiteStarted command' do
29
- is_expected.to eq [
30
- "##teamcity[testSuiteStarted name='Demo feature']"
31
+ expect(statements).to eq [
32
+ "##teamcity[testSuiteStarted name='Demo feature']",
31
33
  ]
32
34
  end
33
35
  end
34
36
 
35
37
  describe '#before_scenario' do
36
- let(:scenario) { double('scenario') }
38
+ let(:action) { [:before_scenario, scenario] }
37
39
 
38
40
  before do
39
- allow(scenario).to receive(:name).and_return 'Running the scenario'
40
- allow(scenario).to receive(:file).and_return \
41
- File.join(Dir.getwd, 'features', 'file.feature')
42
- allow(scenario).to receive(:line).and_return 5
41
+ allow(scenario).to receive_messages(name: 'Running the scenario',
42
+ file: File.join(Dir.getwd, 'features', 'file.feature'), line: 5,)
43
43
  end
44
44
 
45
- subject { reporter.before_scenario(scenario); super() }
46
-
47
45
  it do
48
- is_expected.to eq [
49
- "##teamcity[testStarted name='Running the scenario']"
46
+ expect(statements).to eq [
47
+ "##teamcity[testStarted name='Running the scenario']",
50
48
  ]
51
49
  end
52
50
  end
53
51
 
54
52
  describe '#after_scenario' do
55
- let(:scenario) { double('scenario') }
53
+ let(:action) { [:after_scenario, scenario] }
56
54
 
57
55
  before do
58
- allow(scenario).to receive(:name).and_return 'Running the scenario'
59
- allow(scenario).to receive(:passed?).and_return(true)
60
- allow(scenario).to receive(:failed?).and_return(false)
61
- allow(scenario).to receive(:pending?).and_return(false)
62
- allow(scenario).to receive(:aborted?).and_return(false)
56
+ allow(scenario).to receive_messages(name: 'Running the scenario', passed?: true, failed?: false, pending?: false,
57
+ aborted?: false,)
63
58
  end
64
59
 
65
- subject { reporter.after_scenario(scenario); super() }
66
-
67
60
  it do
68
- is_expected.to eq [
69
- "##teamcity[testFinished name='Running the scenario']"
61
+ expect(statements).to eq [
62
+ "##teamcity[testFinished name='Running the scenario']",
70
63
  ]
71
64
  end
72
65
 
73
66
  context '<failed>' do
74
- let(:exception) do
75
- begin
76
- raise RuntimeError.new
77
- rescue RuntimeError => e
78
- e
79
- end
80
- end
81
-
82
67
  before do
83
- allow(scenario).to receive(:failed?).and_return(true)
84
- allow(scenario).to receive(:exception).and_return(exception)
68
+ error = RuntimeError.new 'An error occurred'
69
+ allow(error).to receive(:backtrace).and_return([
70
+ '/path/to/file.rb:5:in `block (4 levels) in <top (required)>\'',
71
+ '/path/to/file.rb:24:in in `fail_with\'',
72
+ ])
73
+
74
+ allow(scenario).to receive_messages(failed?: true, exception: error)
85
75
  end
86
76
 
87
77
  it do
88
- is_expected.to match [
89
- match(/##teamcity\[testFailed name='.*' message='.*' backtrace='.*'\]/),
90
- "##teamcity[testFinished name='Running the scenario']"
78
+ # rubocop:disable Layout/LineLength
79
+ expect(statements).to eq [
80
+ "##teamcity[testFailed name='Running the scenario' message='#<RuntimeError: An error occurred>' backtrace='/path/to/file.rb:5:in `block (4 levels) in <top (required)>|$1\\n/path/to/file.rb:24:in in `fail_with|$1']",
81
+ "##teamcity[testFinished name='Running the scenario']",
91
82
  ]
83
+ # rubocop:enable Layout/LineLength
92
84
  end
93
85
  end
94
86
  end
95
87
 
96
88
  describe '#after_feature' do
97
- let(:feature) { double('feature') }
89
+ let(:action) { [:after_feature, feature] }
98
90
 
99
91
  before do
100
92
  allow(feature).to receive(:name).and_return 'Demo feature'
101
93
  end
102
94
 
103
- subject { reporter.after_feature(feature); super() }
104
-
105
95
  it do
106
- is_expected.to eq [
107
- "##teamcity[testSuiteFinished name='Demo feature']"
96
+ expect(statements).to eq [
97
+ "##teamcity[testSuiteFinished name='Demo feature']",
108
98
  ]
109
99
  end
110
100
  end
@@ -3,10 +3,10 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gurke::RunList do
6
- let(:reporter) { Gurke::Reporters::NullReporter.new }
7
- let(:runner) { double 'runner' }
8
- let(:object) { double 'object' }
9
- let(:list) { Gurke::RunList.new }
6
+ let(:reporter) { instance_double Gurke::Reporters::NullReporter }
7
+ let(:runner) { instance_double Gurke::Runner }
8
+ let(:object) { double 'runnable' } # rubocop:disable RSpec/VerifiedDoubles
9
+ let(:list) { described_class.new }
10
10
 
11
11
  before do
12
12
  list << object
@@ -14,19 +14,17 @@ describe Gurke::RunList do
14
14
  end
15
15
 
16
16
  describe '#run' do
17
- subject { list.run runner, reporter }
17
+ before { list.run runner, reporter }
18
18
 
19
- it 'should run all objects' do
20
- expect(object).to receive(:run).with(runner, reporter)
21
- subject
19
+ it 'runs all objects' do
20
+ expect(object).to have_received(:run).with(runner, reporter)
22
21
  end
23
22
 
24
23
  context 'with additional args' do
25
- subject { list.run runner, reporter, 0, :sym }
24
+ before { list.run runner, reporter, 0, :sym }
26
25
 
27
- it 'should pass additional args' do
28
- expect(object).to receive(:run).with(runner, reporter, 0, :sym)
29
- subject
26
+ it 'passes additional args' do
27
+ expect(object).to have_received(:run).with(runner, reporter, 0, :sym)
30
28
  end
31
29
  end
32
30
  end
@@ -3,65 +3,68 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gurke::Scenario do
6
- let(:reporter) { Gurke::Reporters::NullReporter.new }
7
- let(:runner) { double 'runner' }
8
- let(:feature) { double 'feature' }
9
- let(:backgrounds) { double('backgrounds') }
6
+ let(:scenario) do
7
+ described_class.new(feature, nil, nil, tags, nil)
8
+ end
9
+
10
+ let(:reporter) { instance_double Gurke::Reporters::NullReporter }
11
+ let(:runner) { instance_double Gurke::Runner }
12
+ let(:feature) { instance_double Gurke::Feature }
13
+ let(:backgrounds) { instance_double Gurke::RunList }
10
14
  let(:tags) { [] }
11
15
 
12
16
  before do
13
- allow(feature).to receive(:backgrounds).and_return(backgrounds)
17
+ allow(reporter).to receive(:invoke)
14
18
  allow(backgrounds).to receive(:run)
19
+ allow(feature).to receive(:backgrounds).and_return(backgrounds)
15
20
  allow(runner).to receive(:hook) {|_, _, &block| block.call }
16
21
  end
17
22
 
18
- let(:scenario) do
19
- Gurke::Scenario.new(feature, nil, nil, tags, nil)
20
- end
21
-
22
23
  describe '#run' do
23
- subject { scenario.run(runner, reporter) }
24
+ subject(:run) { scenario.run(runner, reporter) }
24
25
 
25
- it 'runs all backgrounds' do
26
- expect(backgrounds).to receive(:run)
27
- .with(runner, reporter, scenario, scenario.send(:world))
26
+ context 'when running' do
27
+ before { run }
28
28
 
29
- subject
30
- end
31
-
32
- it 'runs hook in scenario world' do
33
- expect(runner).to receive(:hook) do |scope, context, world|
34
- expect(scope).to eq :scenario
35
- expect(context).to eq scenario
36
- expect(world).to eq scenario.send(:world)
29
+ it 'has run all backgrounds' do
30
+ expect(backgrounds).to have_received(:run)
31
+ .with(runner, reporter, scenario, scenario.send(:world))
37
32
  end
38
33
 
39
- subject
40
- end
41
-
42
- it 'runs reporter callbacks in correct order' do
43
- expect(reporter).to receive(:invoke).exactly(4).times do |*args|
44
- @scopes ||= []
45
- @scopes << args.first
34
+ it 'has hooked in the scenario world' do
35
+ expect(runner).to have_received(:hook) do |scope, context, world|
36
+ expect(scope).to eq :scenario
37
+ expect(context).to eq scenario
38
+ expect(world).to eq scenario.send(:world)
39
+ end
46
40
  end
47
41
 
48
- subject
42
+ it 'has invoked reporter callbacks in correct order' do
43
+ scopes = []
44
+ expect(reporter).to have_received(:invoke).exactly(4).times do |*args|
45
+ scopes << args.first
46
+ end
49
47
 
50
- expect(@scopes).to eq %i[before_scenario start_scenario
51
- end_scenario after_scenario]
48
+ expect(scopes).to eq %i[
49
+ before_scenario
50
+ start_scenario
51
+ end_scenario
52
+ after_scenario
53
+ ]
54
+ end
52
55
  end
53
56
 
54
57
  context 'with retries' do
55
- let(:step) { double('step') }
58
+ let(:step) { instance_double(Gurke::Step) }
56
59
  let(:worlds) { Set.new }
57
60
 
58
- before { scenario.steps << step }
59
-
60
61
  before do
62
+ scenario.steps << step
61
63
  allow(runner).to receive(:retries).with(scenario).and_return(1)
62
64
  end
63
65
 
64
66
  it 'resets the world' do
67
+ # rubocop:disable RSpec/MessageSpies
65
68
  expect(step).to receive(:run) do |_, _, scenario, world|
66
69
  worlds << world
67
70
  scenario.failed!
@@ -72,10 +75,12 @@ describe Gurke::Scenario do
72
75
  scenario.passed!
73
76
  end
74
77
 
75
- subject
78
+ run
76
79
 
77
80
  # Expect to have two *different* worlds collected
78
81
  expect(worlds.size).to eq 2
82
+
83
+ # rubocop:enable RSpec/MessageSpies
79
84
  end
80
85
  end
81
86
  end
@@ -2,28 +2,28 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- require 'spec_helper'
6
-
7
5
  describe Gurke::StepDefinition do
6
+ subject(:sd) { step_definition }
7
+
8
8
  let(:pattern) { nil }
9
9
  let(:step_definition) { described_class.new pattern }
10
- subject { step_definition }
10
+ let(:m) { Gurke::StepDefinition::Match }
11
11
 
12
- context '#match' do
12
+ describe '#match' do
13
13
  context 'with regex' do
14
14
  let(:pattern) { /dies ist (ein|zwei) regex/ }
15
15
 
16
- it { expect(subject.match('dies ist ein regex')).to be_a(Gurke::StepDefinition::Match) }
17
- it { expect(subject.match('dies ist zwei regex')).to be_a(Gurke::StepDefinition::Match) }
16
+ it { expect(sd.match('dies ist ein regex')).to be_a(m) }
17
+ it { expect(sd.match('dies ist zwei regex')).to be_a(m) }
18
18
  end
19
19
 
20
20
  context 'with string' do
21
21
  let(:pattern) { 'a string' }
22
22
 
23
- it { expect(subject.match('a string')).to be_a(Gurke::StepDefinition::Match) }
24
- it { expect(subject.match(' a string')).to be_nil }
25
- it { expect(subject.match('a string ')).to be_nil }
26
- it { expect(subject.match(' a string ')).to be_nil }
23
+ it { expect(sd.match('a string')).to be_a(m) }
24
+ it { expect(sd.match(' a string')).to be_nil }
25
+ it { expect(sd.match('a string ')).to be_nil }
26
+ it { expect(sd.match(' a string ')).to be_nil }
27
27
  end
28
28
  end
29
29
  end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
4
- require 'coveralls'
5
- Coveralls.wear! do
6
- add_filter 'spec'
7
- end
8
- end
3
+ require 'rspec'
4
+ require 'simplecov'
5
+ SimpleCov.start
9
6
 
10
- require 'bundler'
11
- Bundler.require
7
+ if ENV['CI']
8
+ require 'codecov'
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
+ end
12
11
 
13
12
  require 'gurke'
14
13
 
15
- Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
14
+ Dir[File.expand_path('spec/support/**/*.rb')].sort.each {|f| require f }
16
15
 
17
16
  module Helper
18
17
  def unindent(str)
@@ -23,4 +22,8 @@ end
23
22
  RSpec.configure do |config|
24
23
  config.order = 'random'
25
24
  config.include Helper
25
+
26
+ config.mock_with :rspec do |mocks|
27
+ mocks.verify_doubled_constant_names = true
28
+ end
26
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gurke
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -39,36 +39,22 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: trollop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
42
+ name: optimist
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.3'
62
- type: :development
47
+ version: '3.0'
48
+ type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.3'
69
- description: An alternative gherkin feature runner inspired by rspec and turnip.
54
+ version: '3.0'
55
+ description:
70
56
  email:
71
- - jg@altimos.de
57
+ - jgraichen@altimos.de
72
58
  executables:
73
59
  - gurke
74
60
  extensions: []
@@ -128,7 +114,8 @@ files:
128
114
  homepage: https://github.com/jgraichen/gurke
129
115
  licenses:
130
116
  - MIT
131
- metadata: {}
117
+ metadata:
118
+ rubygems_mfa_required: 'true'
132
119
  post_install_message:
133
120
  rdoc_options: []
134
121
  require_paths:
@@ -137,39 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
124
  requirements:
138
125
  - - ">="
139
126
  - !ruby/object:Gem::Version
140
- version: '0'
127
+ version: 2.7.0
141
128
  required_rubygems_version: !ruby/object:Gem::Requirement
142
129
  requirements:
143
130
  - - ">="
144
131
  - !ruby/object:Gem::Version
145
132
  version: '0'
146
133
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.7.7
134
+ rubygems_version: 3.4.21
149
135
  signing_key:
150
136
  specification_version: 4
151
137
  summary: An alternative gherkin feature runner inspired by rspec and turnip.
152
- test_files:
153
- - features/gurke.feature
154
- - features/gurke.rb
155
- - features/gurke/backtrace_filtering.feature
156
- - features/gurke/context_in_hooks.feature
157
- - features/gurke/filter_by_tags.feature
158
- - features/gurke/include_by_tags.feature
159
- - features/gurke/other_reporter.feature
160
- - features/gurke/pending_steps.feature
161
- - features/gurke/retry_flaky_scenario.feature
162
- - features/gurke/retry_scenario.feature
163
- - features/gurke/run_specific_directories.feature
164
- - features/gurke/run_specific_scenarios.feature
165
- - features/gurke/step_specific_definitions.feature
166
- - features/support/steps/cli_steps.rb
167
- - features/support/steps/file_steps.rb
168
- - spec/gurke/feature_list_spec.rb
169
- - spec/gurke/reporters/compact_reporter_spec.rb
170
- - spec/gurke/reporters/default_reporter_spec.rb
171
- - spec/gurke/reporters/team_city_reporter_spec.rb
172
- - spec/gurke/run_list_spec.rb
173
- - spec/gurke/scenario_spec.rb
174
- - spec/gurke/step_definition_spec.rb
175
- - spec/spec_helper.rb
138
+ test_files: []