cucumber-core 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5c7dce2de4429c75212c41a7d68768df625b22e
4
- data.tar.gz: a1b973e289c386411ec84f27cc83db1b2ad4e147
3
+ metadata.gz: 5e74d19b9afa811f9bb89519680da05fb54e4f21
4
+ data.tar.gz: 51423664d262bb30d820712a52ff8c5dcbd2b43e
5
5
  SHA512:
6
- metadata.gz: 20196a25adcfb5fe2bba86beb60ac8d1e8472e89b280add560da96737cb2e1bdb8b0c6a60e9438dc981a74669629dbb0f9336c34fcb502a8b55b5cffdfa92e0c
7
- data.tar.gz: d01388ba71e8e2e09f7286d1425406db8f0d72b44805d49261eec7b6e0be2b934c10e6cc465f04a81893c2688f2293d7774bc9c330d1dcba26c9a174c79f132f
6
+ metadata.gz: 11c262271fe0041e39e9e0c6a400ea3d5de63c702ff528edae821dfba99fa7408c26a61ae6c4093be79ec596805465fbd2d9c31a9b7bc8eef1a8b2a9cad64a58
7
+ data.tar.gz: ea0a43a32a8566e51cae8d90c8831ca3af9e42fd48da76d12c586754973ede208a33df577e39b0afa98afedc3ad1dbe3aebc443669540a7132af09e1ce8e2fc2
data/HISTORY.md CHANGED
@@ -1,8 +1,22 @@
1
- ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.0...master)
1
+ ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.1...master)
2
2
 
3
- ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0...v1.1.0)
3
+ * Your change here?
4
4
 
5
- ### New features
5
+ ##
6
+ [v1.1.1](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.1...v1.1.1)
7
+
8
+
9
+ ### New Features
10
+
11
+ * Calculate actual keyword for snippets (@brasmusson)
12
+
13
+ ### Bugfixes
14
+
15
+ * Remove keyword from `Test::Case#name` [82](https://github.com/cucumber/cucumber-ruby-core/pull/82) (@richarda)
16
+
17
+ ## [v1.1.0](https://github.com/cucumber/cucumber-ruby-core/compare/v1.0.0...v1.1.0)
18
+
19
+ ### New features
6
20
 
7
21
  * LocationsFilter now sorts test cases as well as filtering them (@mattwynne)
8
22
 
@@ -11,7 +11,7 @@ module Cucumber
11
11
  attr_reader :keyword, :name, :language, :exception, :multiline_arg, :gherkin_statement
12
12
 
13
13
  def initialize(gherkin_statement, language, location, keyword, name, multiline_arg)
14
- @gherkin_statement, @location, @keyword, @name, @multiline_arg = gherkin_statement, location, keyword, name, multiline_arg
14
+ @gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = gherkin_statement, language, location, keyword, name, multiline_arg
15
15
  end
16
16
 
17
17
  def to_sexp
@@ -22,6 +22,18 @@ module Cucumber
22
22
  "#{location}:in `#{keyword}#{name}'"
23
23
  end
24
24
 
25
+ def actual_keyword(previous_step_keyword = nil)
26
+ if [language.keywords('and'), language.keywords('but')].flatten.uniq.include? keyword
27
+ if previous_step_keyword.nil?
28
+ language.keywords('given').reject{|kw| kw == '* '}[0]
29
+ else
30
+ previous_step_keyword
31
+ end
32
+ else
33
+ keyword
34
+ end
35
+ end
36
+
25
37
  private
26
38
 
27
39
  def children
@@ -36,7 +48,7 @@ module Cucumber
36
48
  class ExpandedOutlineStep < Step
37
49
 
38
50
  def initialize(outline_step, gherkin_statement, language, location, keyword, name, multiline_arg)
39
- @outline_step, @gherkin_statement, @location, @keyword, @name, @multiline_arg = outline_step, gherkin_statement, location, keyword, name, multiline_arg
51
+ @outline_step, @gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = outline_step, gherkin_statement, language, location, keyword, name, multiline_arg
40
52
  end
41
53
 
42
54
  alias :self_match_locations? :match_locations?
@@ -47,6 +47,10 @@ module Cucumber
47
47
  def name
48
48
  @name ||= NameBuilder.new(self).result
49
49
  end
50
+
51
+ def keyword
52
+ @keyword ||= NameBuilder.new(self).keyword
53
+ end
50
54
 
51
55
  def tags
52
56
  @tags ||= TagCollector.new(self).result
@@ -92,6 +96,7 @@ module Cucumber
92
96
 
93
97
  class NameBuilder
94
98
  attr_reader :result
99
+ attr_reader :keyword
95
100
 
96
101
  def initialize(test_case)
97
102
  test_case.describe_source_to self
@@ -102,12 +107,14 @@ module Cucumber
102
107
  end
103
108
 
104
109
  def scenario(scenario)
105
- @result = "#{scenario.keyword}: #{scenario.name}"
110
+ @result = scenario.name
111
+ @keyword = scenario.keyword
106
112
  self
107
113
  end
108
114
 
109
115
  def scenario_outline(outline)
110
- @result = "#{outline.keyword}: #{outline.name}" + @result
116
+ @result = outline.name + @result
117
+ @keyword = outline.keyword
111
118
  self
112
119
  end
113
120
 
@@ -2,7 +2,7 @@ module Cucumber
2
2
  module Core
3
3
  class Version
4
4
  def self.to_s
5
- "1.1.0"
5
+ "1.1.1"
6
6
  end
7
7
  end
8
8
  end
@@ -1,4 +1,5 @@
1
1
  require 'cucumber/core/ast/step'
2
+ require 'gherkin/i18n'
2
3
 
3
4
  module Cucumber
4
5
  module Core
@@ -47,6 +48,53 @@ module Cucumber
47
48
 
48
49
  end
49
50
 
51
+ describe "actual keyword" do
52
+ let(:language) { ::Gherkin::I18n.get('en') }
53
+
54
+ context "for keywords 'given', 'when' and 'then'" do
55
+ let(:given_step) { Step.new(double, language, double, "Given ", double, double) }
56
+ let(:when_step) { Step.new(double, language, double, "When ", double, double) }
57
+ let(:then_step) { Step.new(double, language, double, "Then ", double, double) }
58
+
59
+ it "returns the keyword itself" do
60
+ expect( given_step.actual_keyword(nil) ).to eq("Given ")
61
+ expect( when_step.actual_keyword(nil) ).to eq("When ")
62
+ expect( then_step.actual_keyword(nil) ).to eq("Then ")
63
+ end
64
+ end
65
+
66
+ context "for keyword 'and', 'but', and '*'" do
67
+ let(:and_step) { Step.new(double, language, double, "And ", double, double) }
68
+ let(:but_step) { Step.new(double, language, double, "But ", double, double) }
69
+ let(:asterisk_step) { Step.new(double, language, double, "* ", double, double) }
70
+
71
+ context "when the previous step keyword exist" do
72
+ it "returns the previous step keyword" do
73
+ expect( and_step.actual_keyword("Then ") ).to eq("Then ")
74
+ expect( but_step.actual_keyword("Then ") ).to eq("Then ")
75
+ expect( asterisk_step.actual_keyword("Then ") ).to eq("Then ")
76
+ end
77
+ end
78
+
79
+ context "when the previous step keyword does not exist" do
80
+ it "returns the 'given' keyword" do
81
+ expect( and_step.actual_keyword(nil) ).to eq("Given ")
82
+ expect( but_step.actual_keyword(nil) ).to eq("Given ")
83
+ expect( asterisk_step.actual_keyword(nil) ).to eq("Given ")
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ context "for i18n languages" do
90
+ let(:language) { ::Gherkin::I18n.get('en-lol') }
91
+ let(:and_step) { Step.new(double, language, double, "AN ", double, double) }
92
+
93
+ it "returns the keyword in the correct language" do
94
+ expect( and_step.actual_keyword(nil) ).to eq("I CAN HAZ ")
95
+ end
96
+ end
97
+ end
50
98
  end
51
99
 
52
100
  describe ExpandedOutlineStep do
@@ -68,7 +68,8 @@ module Cucumber
68
68
  receiver = double.as_null_object
69
69
 
70
70
  expect( receiver ).to receive(:test_case) do |test_case|
71
- expect( test_case.name ).to eq 'Scenario: Scenario name'
71
+ expect( test_case.name ).to eq 'Scenario name'
72
+ expect( test_case.keyword ).to eq 'Scenario'
72
73
  end
73
74
  compile([gherkin], receiver)
74
75
  end
@@ -96,13 +97,14 @@ module Cucumber
96
97
  end
97
98
  receiver = double.as_null_object
98
99
  expect( receiver ).to receive(:test_case) do |test_case|
99
- expect( test_case.name ).to eq 'Scenario Outline: outline name, examples name (row 1)'
100
+ expect( test_case.name ).to eq 'outline name, examples name (row 1)'
101
+ expect( test_case.keyword ).to eq 'Scenario Outline'
100
102
  end.once.ordered
101
103
  expect( receiver ).to receive(:test_case) do |test_case|
102
- expect( test_case.name ).to eq 'Scenario Outline: outline name, examples name (row 2)'
104
+ expect( test_case.name ).to eq 'outline name, examples name (row 2)'
103
105
  end.once.ordered
104
106
  expect( receiver ).to receive(:test_case) do |test_case|
105
- expect( test_case.name ).to eq 'Scenario Outline: outline name, Examples (row 1)'
107
+ expect( test_case.name ).to eq 'outline name, Examples (row 1)'
106
108
  end.once.ordered
107
109
  compile [gherkin], receiver
108
110
  end
@@ -273,7 +275,7 @@ module Cucumber
273
275
  end
274
276
 
275
277
  let(:test_case) do
276
- test_cases.find { |c| c.name == 'Scenario: two' }
278
+ test_cases.find { |c| c.name == 'two' }
277
279
  end
278
280
 
279
281
  it 'matches the precise location of the scenario' do
@@ -282,7 +284,7 @@ module Cucumber
282
284
  end
283
285
 
284
286
  it 'matches the precise location of an empty scenario' do
285
- empty_scenario_test_case = test_cases.find { |c| c.name == 'Scenario: empty' }
287
+ empty_scenario_test_case = test_cases.find { |c| c.name == 'empty' }
286
288
  location = Ast::Location.new(file, 26)
287
289
  expect( empty_scenario_test_case.match_locations?([location]) ).to be_truthy
288
290
  end
@@ -320,7 +322,7 @@ module Cucumber
320
322
 
321
323
  context "with a docstring" do
322
324
  let(:test_case) do
323
- test_cases.find { |c| c.name == 'Scenario: with docstring' }
325
+ test_cases.find { |c| c.name == 'with docstring' }
324
326
  end
325
327
 
326
328
  it "matches a location at the start the docstring" do
@@ -336,7 +338,7 @@ module Cucumber
336
338
 
337
339
  context "with a table" do
338
340
  let(:test_case) do
339
- test_cases.find { |c| c.name == 'Scenario: with a table' }
341
+ test_cases.find { |c| c.name == 'with a table' }
340
342
  end
341
343
 
342
344
  it "matches a location on the first table row" do
@@ -349,7 +351,7 @@ module Cucumber
349
351
  context "for a scenario outline" do
350
352
  let(:source) do
351
353
  Gherkin::Document.new(file, <<-END.unindent)
352
- Feature:
354
+ Feature:
353
355
 
354
356
  Scenario: one
355
357
  Given one a
@@ -376,7 +378,7 @@ module Cucumber
376
378
  end
377
379
 
378
380
  let(:test_case) do
379
- test_cases.find { |c| c.name == "Scenario Outline: two, x1 (row 1)" }
381
+ test_cases.find { |c| c.name == "two, x1 (row 1)" }
380
382
  end
381
383
 
382
384
  it 'matches the precise location of the scenario outline examples table row' do
@@ -48,7 +48,7 @@ module Cucumber
48
48
  it "filters out test cases based on a tag expression" do
49
49
  visitor = double.as_null_object
50
50
  expect( visitor ).to receive(:test_case) do |test_case|
51
- expect( test_case.name ).to eq 'Scenario Outline: foo, bar (row 1)'
51
+ expect( test_case.name ).to eq 'foo, bar (row 1)'
52
52
  end.exactly(1).times
53
53
 
54
54
  gherkin = gherkin do
@@ -283,10 +283,10 @@ module Cucumber
283
283
  expect( report.test_cases.total_passed ).to eq 1
284
284
  expect( report.test_cases.total_failed ).to eq 0
285
285
  expect( logger ).to eq [
286
- :before_all,
287
- :step,
288
- :middle,
289
- :step,
286
+ :before_all,
287
+ :step,
288
+ :middle,
289
+ :step,
290
290
  :after_all
291
291
  ]
292
292
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-02-08 00:00:00.000000000 Z
15
+ date: 2015-02-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
@@ -213,10 +213,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.4.5
216
+ rubygems_version: 2.2.2
217
217
  signing_key:
218
218
  specification_version: 4
219
- summary: cucumber-core-1.1.0
219
+ summary: cucumber-core-1.1.1
220
220
  test_files:
221
221
  - spec/capture_warnings.rb
222
222
  - spec/coverage.rb
@@ -241,4 +241,3 @@ test_files:
241
241
  - spec/cucumber/core_spec.rb
242
242
  - spec/readme_spec.rb
243
243
  - spec/report_api_spy.rb
244
- has_rdoc: