cucumber-core 1.1.3 → 1.2.0

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: d0a8905410eaa2520b979eefe561fdd066e0c703
4
- data.tar.gz: 882b6415e6c942bce875cbef62c3afadd5964dcc
3
+ metadata.gz: 53a124c933b4697ed6128b46c307617ea4399559
4
+ data.tar.gz: e80a381d06f95b5416035f91a004d00cbd68057e
5
5
  SHA512:
6
- metadata.gz: b3f6a53c774b90832b8f6e86245a7107e4ebab450b8c7aa5d714309a7e3c367c60cbff5e06bbbfb67a6b2b8e853e2b32efbfef64f81dfe48b99d18ead9864132
7
- data.tar.gz: 6e3c7953c11347def64e8fd184f3a2f11514ae24d1204c2ae9d52bb48518ab7a1fb1e6d15c3305e549c9c683af390b155d6c3888546dba970212499800ef5142
6
+ metadata.gz: 0b1e3a4359e8ccaeef234bfa1492e678145bf1f07320ffbf1e01814b2efd405da9ae10abb31347ac10642e49935183032b1f7a094631219c48d7a4b984c5e6cf
7
+ data.tar.gz: e7d0c05ae5e57937e6858c91485157175e69d32332457db403a69d1e8b44e9a99bf95cc68e2bdb1b265ad5decaa69086fbca3a0d48e6cf97ca6cf64b4b54e855
data/HISTORY.md CHANGED
@@ -1,6 +1,20 @@
1
- ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.3...master)
1
+ ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.2.0...master)
2
2
 
3
- ## [v1.1.3](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.2...v1.1.2)
3
+ ...
4
+
5
+ ## [v1.2.0](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.3...v1.2.0)
6
+
7
+ ### New Features
8
+
9
+ * Enable the location of actions to be the step or hook location (@brasmusson)
10
+ * Add the comments to the Steps, Examples tables and Examples table rows Ast classes (@brasmusson)
11
+ * Expose name, description and examples_rows attributes of `Ast::ExamplesTable` (@mattwynne)
12
+ * Add #to_sym to Cucumber::Core::Test::Result classes ([#89](https://github.com/cucumber/cucumber-ruby-core/pull/89) @pdswan)
13
+ * Add #ok? to Cucumber::Core::Test::Result classes ([#92](https://github.com/cucumber/cucumber-ruby-core/pull/92) @brasmusson)
14
+
15
+ ### Bugfixes
16
+
17
+ ## [v1.1.3](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.2...v1.1.3)
4
18
 
5
19
  ### New Features
6
20
 
@@ -10,23 +10,22 @@ module Cucumber
10
10
  include HasLocation
11
11
  include DescribesItself
12
12
 
13
- def initialize(gherkin_statement, language, location, comments, keyword, title, description, raw_steps)
13
+ def initialize(gherkin_statement, language, location, comments, keyword, name, description, raw_steps)
14
14
  @gherkin_statement = gherkin_statement
15
15
  @language = language
16
16
  @location = location
17
17
  @comments = comments
18
18
  @keyword = keyword
19
- @title = title
19
+ @name = name
20
20
  @description = description
21
21
  @raw_steps = raw_steps
22
22
  end
23
23
 
24
- attr_reader :language, :title, :description, :raw_steps
25
- private :language, :title, :description, :raw_steps
24
+ attr_reader :language, :description, :raw_steps
25
+ private :language, :raw_steps
26
26
 
27
- attr_accessor :feature
28
- attr_accessor :comments, :keyword, :location
29
- attr_reader :gherkin_statement
27
+ attr_reader :comments, :keyword, :location
28
+ attr_reader :gherkin_statement
30
29
 
31
30
  def children
32
31
  raw_steps
@@ -7,7 +7,7 @@ module Cucumber
7
7
  include HasLocation
8
8
 
9
9
  attr_reader :location, :value
10
- private :location, :value
10
+ private :value
11
11
 
12
12
  def initialize(location, value)
13
13
  @location = location
@@ -22,7 +22,6 @@ module Cucumber
22
22
  class DocString < SimpleDelegator
23
23
  include HasLocation
24
24
  include DescribesItself
25
- attr_accessor :file
26
25
 
27
26
  attr_reader :content_type, :content
28
27
 
@@ -11,21 +11,20 @@ module Cucumber
11
11
  include HasLocation
12
12
  include DescribesItself
13
13
 
14
- def initialize(gherkin_statement, location, comments, tags, keyword, title, description, header, example_rows)
14
+ def initialize(gherkin_statement, location, comments, tags, keyword, name, description, header, example_rows)
15
15
  @gherkin_statement = gherkin_statement
16
16
  @location = location
17
17
  @comments = comments
18
18
  @tags = tags
19
19
  @keyword = keyword
20
- @title = title
20
+ @name = name
21
21
  @description = description
22
22
  @header = header
23
23
  @example_rows = example_rows
24
24
  end
25
25
 
26
26
  attr_reader :gherkin_statement, :location, :comments, :tags, :keyword,
27
- :title, :description, :header, :example_rows
28
- private :title, :description, :example_rows
27
+ :header, :example_rows
29
28
 
30
29
  private
31
30
 
@@ -40,17 +39,20 @@ module Cucumber
40
39
  class Header
41
40
  include HasLocation
42
41
 
43
- def initialize(cells, location)
42
+ attr_reader :comments
43
+
44
+ def initialize(cells, location, comments)
44
45
  @cells = cells
45
46
  @location = location
47
+ @comments = comments
46
48
  end
47
49
 
48
50
  def values
49
51
  @cells
50
52
  end
51
53
 
52
- def build_row(row_cells, number, location, language)
53
- Row.new(Hash[@cells.zip(row_cells)], number, location, language)
54
+ def build_row(row_cells, number, location, language, comments)
55
+ Row.new(Hash[@cells.zip(row_cells)], number, location, language, comments)
54
56
  end
55
57
 
56
58
  def inspect
@@ -62,14 +64,15 @@ module Cucumber
62
64
  include DescribesItself
63
65
  include HasLocation
64
66
 
65
- attr_reader :number, :language
67
+ attr_reader :number, :language, :comments
66
68
 
67
- def initialize(data, number, location, language)
69
+ def initialize(data, number, location, language, comments)
68
70
  raise ArgumentError, data.to_s unless data.is_a?(Hash)
69
71
  @data = data
70
72
  @number = number
71
73
  @location = location
72
74
  @language = language
75
+ @comments = comments
73
76
  end
74
77
 
75
78
  def ==(other)
@@ -12,11 +12,10 @@ module Cucumber
12
12
  include DescribesItself
13
13
 
14
14
  attr_reader :gherkin_statement, :language, :location, :background,
15
- :comments, :tags, :keyword, :title, :description,
15
+ :comments, :tags, :keyword, :description,
16
16
  :feature_elements
17
- private :description
18
17
 
19
- def initialize(gherkin_statement, language, location, background, comments, tags, keyword, title, description, feature_elements)
18
+ def initialize(gherkin_statement, language, location, background, comments, tags, keyword, name, description, feature_elements)
20
19
  @gherkin_statement = gherkin_statement
21
20
  @language = language
22
21
  @location = location
@@ -24,7 +23,7 @@ module Cucumber
24
23
  @comments = comments
25
24
  @tags = tags
26
25
  @keyword = keyword
27
- @title = title
26
+ @name = name
28
27
  @description = description
29
28
  @feature_elements = feature_elements
30
29
  end
@@ -2,25 +2,21 @@ module Cucumber
2
2
  module Core
3
3
  module Ast
4
4
  module Names
5
- attr_reader :description
6
-
7
- def name
8
- title
9
- end
5
+ attr_reader :description, :name
10
6
 
11
7
  def title
12
8
  warn("deprecated. Use #name")
13
- @title
9
+ name
14
10
  end
15
11
 
16
12
  def legacy_conflated_name_and_description
17
- s = @title
13
+ s = name
18
14
  s += "\n#{@description}" if @description != ""
19
15
  s
20
16
  end
21
17
 
22
18
  def to_s
23
- @title
19
+ name
24
20
  end
25
21
 
26
22
  def inspect
@@ -10,15 +10,15 @@ module Cucumber
10
10
  include HasLocation
11
11
  include DescribesItself
12
12
 
13
- attr_reader :gherkin_statement, :language, :location, :keyword, :name, :multiline_arg
13
+ attr_reader :gherkin_statement, :language, :location, :comments, :keyword, :name, :multiline_arg
14
14
 
15
- def initialize(gherkin_statement, language, location, keyword, name, multiline_arg)
16
- @gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = gherkin_statement, language, location, keyword, name, multiline_arg
15
+ def initialize(gherkin_statement, language, location, comments, keyword, name, multiline_arg)
16
+ @gherkin_statement, @language, @location, @comments, @keyword, @name, @multiline_arg = gherkin_statement, language, location, comments, keyword, name, multiline_arg
17
17
  @language || raise("Language is required!")
18
18
  end
19
19
 
20
20
  def to_step(row)
21
- Ast::ExpandedOutlineStep.new(self, gherkin_statement, language, row.location, keyword, row.expand(name), replace_multiline_arg(row))
21
+ Ast::ExpandedOutlineStep.new(self, gherkin_statement, language, row.location, comments, keyword, row.expand(name), replace_multiline_arg(row))
22
22
  end
23
23
 
24
24
  def inspect
@@ -12,11 +12,11 @@ module Cucumber
12
12
  include DescribesItself
13
13
 
14
14
  attr_reader :gherkin_statement, :language, :location, :background,
15
- :comments, :tags, :feature_tags, :keyword, :title,
15
+ :comments, :tags, :feature_tags, :keyword,
16
16
  :description, :raw_steps
17
- private :raw_steps, :description
17
+ private :raw_steps
18
18
 
19
- def initialize(gherkin_statement, language, location, background, comments, tags, feature_tags, keyword, title, description, raw_steps)
19
+ def initialize(gherkin_statement, language, location, background, comments, tags, feature_tags, keyword, name, description, raw_steps)
20
20
  @gherkin_statement = gherkin_statement
21
21
  @language = language
22
22
  @location = location
@@ -25,7 +25,7 @@ module Cucumber
25
25
  @tags = tags
26
26
  @feature_tags = feature_tags
27
27
  @keyword = keyword
28
- @title = title
28
+ @name = name
29
29
  @description = description
30
30
  @raw_steps = raw_steps
31
31
  end
@@ -14,12 +14,11 @@ module Cucumber
14
14
  MissingExamples = Class.new(StandardError)
15
15
 
16
16
  attr_reader :gherkin_statement, :language, :background, :comments,
17
- :tags, :feature_tags, :keyword, :title, :description,
17
+ :tags, :feature_tags, :keyword,
18
18
  :steps, :examples_tables, :line
19
- private :language, :background, :comments, :feature_tags,
20
- :line
19
+ private :language, :background, :feature_tags, :line
21
20
 
22
- def initialize(gherkin_statement, language, location, background, comments, tags, feature_tags, keyword, title, description, steps, examples_tables)
21
+ def initialize(gherkin_statement, language, location, background, comments, tags, feature_tags, keyword, name, description, steps, examples_tables)
23
22
  @gherkin_statement = gherkin_statement
24
23
  @language = language
25
24
  @location = location
@@ -28,7 +27,7 @@ module Cucumber
28
27
  @tags = tags
29
28
  @feature_tags = feature_tags
30
29
  @keyword = keyword
31
- @title = title
30
+ @name = name
32
31
  @description = description
33
32
  @steps = steps
34
33
  @examples_tables = examples_tables
@@ -8,10 +8,10 @@ module Cucumber
8
8
  include HasLocation
9
9
  include DescribesItself
10
10
 
11
- attr_reader :keyword, :name, :language, :exception, :multiline_arg, :gherkin_statement
11
+ attr_reader :keyword, :name, :language, :comments, :exception, :multiline_arg, :gherkin_statement
12
12
 
13
- def initialize(gherkin_statement, language, location, keyword, name, multiline_arg)
14
- @gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = gherkin_statement, language, location, keyword, name, multiline_arg
13
+ def initialize(gherkin_statement, language, location, comments, keyword, name, multiline_arg)
14
+ @gherkin_statement, @language, @location, @comments, @keyword, @name, @multiline_arg = gherkin_statement, language, location, comments, keyword, name, multiline_arg
15
15
  end
16
16
 
17
17
  def to_sexp
@@ -52,8 +52,8 @@ module Cucumber
52
52
 
53
53
  class ExpandedOutlineStep < Step
54
54
 
55
- def initialize(outline_step, gherkin_statement, language, location, keyword, name, multiline_arg)
56
- @outline_step, @gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = outline_step, gherkin_statement, language, location, keyword, name, multiline_arg
55
+ def initialize(outline_step, gherkin_statement, language, location, comments, keyword, name, multiline_arg)
56
+ @outline_step, @gherkin_statement, @language, @location, @comments, @keyword, @name, @multiline_arg = outline_step, gherkin_statement, language, location, comments, keyword, name, multiline_arg
57
57
  end
58
58
 
59
59
  alias :self_match_locations? :match_locations?
@@ -215,6 +215,7 @@ module Cucumber
215
215
  node,
216
216
  language,
217
217
  location,
218
+ comments,
218
219
  node.keyword,
219
220
  node.name,
220
221
 
@@ -289,16 +290,24 @@ module Cucumber
289
290
 
290
291
  def header
291
292
  row = node.rows[0]
292
- Ast::ExamplesTable::Header.new(row.cells, location)
293
+ Ast::ExamplesTable::Header.new(row.cells, location, row_comments(row))
293
294
  end
294
295
 
295
296
  def example_rows(language)
296
297
  _, *raw_examples = *node.rows
297
298
  raw_examples.each_with_index.map do |row, index|
298
- header.build_row(row.cells, index + 1, location.on_line(row.line), language)
299
+ header.build_row(row.cells, index + 1, location.on_line(row.line), language, row_comments(row))
299
300
  end
300
301
  end
301
302
 
303
+ def row_comments(row)
304
+ row.comments.map do |comment|
305
+ Ast::Comment.new(
306
+ Ast::Location.new(file, comment.line),
307
+ comment.value
308
+ )
309
+ end
310
+ end
302
311
  end
303
312
 
304
313
  class StepBuilder < Builder
@@ -307,6 +316,7 @@ module Cucumber
307
316
  node,
308
317
  language,
309
318
  location,
319
+ comments,
310
320
  node.keyword,
311
321
  node.name,
312
322
  MultilineArgument.from(node.doc_string || node.rows, location)
@@ -7,8 +7,9 @@ module Cucumber
7
7
  module Core
8
8
  module Test
9
9
  class Action
10
- def initialize(&block)
10
+ def initialize(location = nil, &block)
11
11
  raise ArgumentError, "Passing a block to execute the action is mandatory." unless block
12
+ @location = location ? location : Ast::Location.new(*block.source_location)
12
13
  @block = block
13
14
  @timer = Timer.new
14
15
  end
@@ -28,7 +29,7 @@ module Cucumber
28
29
  end
29
30
 
30
31
  def location
31
- Ast::Location.new(*@block.source_location)
32
+ @location
32
33
  end
33
34
 
34
35
  def inspect
@@ -57,6 +58,12 @@ module Cucumber
57
58
  end
58
59
 
59
60
  class UndefinedAction
61
+ attr_reader :location
62
+
63
+ def initialize(source_location)
64
+ @location = source_location
65
+ end
66
+
60
67
  def execute(*)
61
68
  undefined
62
69
  end
@@ -5,13 +5,19 @@ module Cucumber
5
5
  module Test
6
6
  module Result
7
7
 
8
+ # Defines to_sym on a result class for the given result type
9
+ #
8
10
  # Defines predicate methods on a result class with only the given one
9
11
  # returning true
10
- def self.status_queries(status)
12
+ def self.query_methods(result_type)
11
13
  Module.new do
12
- [:passed, :failed, :undefined, :unknown, :skipped, :pending].each do |possible_status|
13
- define_method("#{possible_status}?") do
14
- possible_status == status
14
+ define_method :to_sym do
15
+ result_type
16
+ end
17
+
18
+ [:passed, :failed, :undefined, :unknown, :skipped, :pending].each do |possible_result_type|
19
+ define_method("#{possible_result_type}?") do
20
+ possible_result_type == to_sym
15
21
  end
16
22
  end
17
23
  end
@@ -19,7 +25,7 @@ module Cucumber
19
25
 
20
26
  # Null object for results. Represents the state where we haven't run anything yet
21
27
  class Unknown
22
- include Result.status_queries :unknown
28
+ include Result.query_methods :unknown
23
29
 
24
30
  def describe_to(visitor, *args)
25
31
  self
@@ -27,7 +33,7 @@ module Cucumber
27
33
  end
28
34
 
29
35
  class Passed
30
- include Result.status_queries(:passed)
36
+ include Result.query_methods :passed
31
37
  attr_accessor :duration
32
38
 
33
39
  def initialize(duration)
@@ -44,14 +50,26 @@ module Cucumber
44
50
  def to_s
45
51
  "✓"
46
52
  end
53
+
54
+ def ok?(be_strict = false)
55
+ true
56
+ end
57
+
58
+ def with_appended_backtrace(step)
59
+ self
60
+ end
61
+
62
+ def with_filtered_backtrace(filter)
63
+ self
64
+ end
47
65
  end
48
66
 
49
67
  class Failed
50
- include Result.status_queries(:failed)
68
+ include Result.query_methods :failed
51
69
  attr_reader :duration, :exception
52
70
 
53
71
  def initialize(duration, exception)
54
- raise ArgumentError unless duration
72
+ raise ArgumentError unless duration
55
73
  raise ArgumentError unless exception
56
74
  @duration = duration
57
75
  @exception = exception
@@ -68,13 +86,25 @@ module Cucumber
68
86
  "✗"
69
87
  end
70
88
 
89
+ def ok?(be_strict = false)
90
+ false
91
+ end
92
+
71
93
  def with_duration(new_duration)
72
94
  self.class.new(new_duration, exception)
73
95
  end
74
96
 
97
+ def with_appended_backtrace(step)
98
+ exception.backtrace << step.backtrace_line if step.respond_to?(:backtrace_line)
99
+ self
100
+ end
101
+
102
+ def with_filtered_backtrace(filter)
103
+ self.class.new(duration, filter.new(exception.dup).exception)
104
+ end
75
105
  end
76
106
 
77
- # Base class for exceptions that can be raised in a step defintion causing
107
+ # Base class for exceptions that can be raised in a step defintion causing
78
108
  # the step to have that result.
79
109
  class Raisable < StandardError
80
110
  attr_reader :message, :duration
@@ -92,10 +122,22 @@ module Cucumber
92
122
  def with_duration(new_duration)
93
123
  self.class.new(message, new_duration, backtrace)
94
124
  end
125
+
126
+ def with_appended_backtrace(step)
127
+ return self unless step.respond_to?(:backtrace_line)
128
+ set_backtrace([]) unless backtrace
129
+ backtrace << step.backtrace_line
130
+ self
131
+ end
132
+
133
+ def with_filtered_backtrace(filter)
134
+ return self unless backtrace
135
+ filter.new(dup).exception
136
+ end
95
137
  end
96
138
 
97
139
  class Undefined < Raisable
98
- include Result.status_queries :undefined
140
+ include Result.query_methods :undefined
99
141
 
100
142
  def describe_to(visitor, *args)
101
143
  visitor.undefined(*args)
@@ -107,10 +149,13 @@ module Cucumber
107
149
  "?"
108
150
  end
109
151
 
152
+ def ok?(be_strict = false)
153
+ !be_strict
154
+ end
110
155
  end
111
156
 
112
157
  class Skipped < Raisable
113
- include Result.status_queries :skipped
158
+ include Result.query_methods :skipped
114
159
 
115
160
  def describe_to(visitor, *args)
116
161
  visitor.skipped(*args)
@@ -122,10 +167,13 @@ module Cucumber
122
167
  "-"
123
168
  end
124
169
 
170
+ def ok?(be_strict = false)
171
+ true
172
+ end
125
173
  end
126
174
 
127
175
  class Pending < Raisable
128
- include Result.status_queries :pending
176
+ include Result.query_methods :pending
129
177
 
130
178
  def describe_to(visitor, *args)
131
179
  visitor.pending(self, *args)
@@ -136,13 +184,17 @@ module Cucumber
136
184
  def to_s
137
185
  "P"
138
186
  end
187
+
188
+ def ok?(be_strict = false)
189
+ !be_strict
190
+ end
139
191
  end
140
192
 
141
193
  #
142
194
  # An object that responds to the description protocol from the results
143
195
  # and collects summary information.
144
196
  #
145
- # e.g.
197
+ # e.g.
146
198
  # summary = Result::Summary.new
147
199
  # Result::Passed.new(0).describe_to(summary)
148
200
  # puts summary.total_passed