cucumber-core 0.2.0 → 1.0.0.beta.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/cucumber-core.gemspec +1 -1
- data/lib/cucumber/core.rb +6 -6
- data/lib/cucumber/core/ast/data_table.rb +8 -0
- data/lib/cucumber/core/ast/describes_itself.rb +1 -1
- data/lib/cucumber/core/ast/examples_table.rb +8 -2
- data/lib/cucumber/core/ast/feature.rb +2 -3
- data/lib/cucumber/core/ast/location.rb +11 -6
- data/lib/cucumber/core/ast/names.rb +10 -1
- data/lib/cucumber/core/ast/outline_step.rb +6 -3
- data/lib/cucumber/core/ast/scenario.rb +0 -1
- data/lib/cucumber/core/ast/scenario_outline.rb +2 -3
- data/lib/cucumber/core/ast/step.rb +2 -2
- data/lib/cucumber/core/gherkin/ast_builder.rb +4 -1
- data/lib/cucumber/core/test/case.rb +10 -6
- data/lib/cucumber/core/test/filters/debug_filter.rb +28 -0
- data/lib/cucumber/core/test/filters/tag_filter.rb +1 -1
- data/lib/cucumber/core/test/hooks.rb +76 -0
- data/lib/cucumber/core/test/mapper.rb +101 -19
- data/lib/cucumber/core/test/mapping.rb +15 -4
- data/lib/cucumber/core/test/result.rb +39 -27
- data/lib/cucumber/core/test/runner.rb +76 -81
- data/lib/cucumber/core/test/step.rb +10 -18
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/cucumber/core/ast/data_table_spec.rb +12 -0
- data/spec/cucumber/core/ast/location_spec.rb +8 -1
- data/spec/cucumber/core/ast/outline_step_spec.rb +11 -4
- data/spec/cucumber/core/ast/step_spec.rb +2 -2
- data/spec/cucumber/core/compiler_spec.rb +6 -6
- data/spec/cucumber/core/gherkin/parser_spec.rb +31 -18
- data/spec/cucumber/core/test/case_spec.rb +24 -24
- data/spec/cucumber/core/test/hooks_spec.rb +30 -0
- data/spec/cucumber/core/test/mapper_spec.rb +115 -1
- data/spec/cucumber/core/test/mapping_spec.rb +22 -6
- data/spec/cucumber/core/test/result_spec.rb +0 -8
- data/spec/cucumber/core/test/runner_spec.rb +31 -97
- data/spec/cucumber/core/test/step_spec.rb +24 -16
- data/spec/cucumber/core_spec.rb +109 -16
- data/spec/report_api_spy.rb +24 -0
- metadata +32 -28
- data/lib/cucumber/core/test/hook_compiler.rb +0 -109
- data/spec/cucumber/core/test/hook_compiler_spec.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d388993761b2490490288cb0af4349a6688985
|
4
|
+
data.tar.gz: 483157a428ced0dfb4bbb69c31b2dba8247bde19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f676d49732572d9204ee72274dd3d2372a3b4e791281ca83057be310776a9878874d4c7e553ddd472a52c11db93e69eae2b94b87b9fc9a41fb616756ea5f7c5
|
7
|
+
data.tar.gz: 1d0948e3b3701c2bffe59253bd8167794700c20907e569e4dd2c2bcbbf8368ec8ba954067563906e81fbdc43ba1da8833826d1c00cfe5f1af6ac505b40f45159
|
data/.travis.yml
CHANGED
data/cucumber-core.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.add_development_dependency 'bundler', '>= 1.3.5'
|
20
20
|
s.add_development_dependency 'rake', '>= 0.9.2'
|
21
|
-
s.add_development_dependency 'rspec', '
|
21
|
+
s.add_development_dependency 'rspec', '~> 3'
|
22
22
|
s.add_development_dependency 'unindent', '>= 1.0'
|
23
23
|
|
24
24
|
# For coverage reports
|
data/lib/cucumber/core.rb
CHANGED
@@ -2,7 +2,7 @@ require 'cucumber/core/gherkin/parser'
|
|
2
2
|
require 'cucumber/core/compiler'
|
3
3
|
require 'cucumber/core/test/runner'
|
4
4
|
require 'cucumber/core/test/mapper'
|
5
|
-
require 'cucumber/core/test/
|
5
|
+
require 'cucumber/core/test/filters/debug_filter'
|
6
6
|
|
7
7
|
module Cucumber
|
8
8
|
module Core
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def compile(gherkin_documents, last_receiver, filters = [])
|
20
|
-
first_receiver = filters.reduce(last_receiver) do |receiver, (filter_type, args)|
|
20
|
+
first_receiver = filters.reverse.reduce(last_receiver) do |receiver, (filter_type, args)|
|
21
21
|
filter_type.new(*args + [receiver])
|
22
22
|
end
|
23
23
|
compiler = Compiler.new(first_receiver)
|
@@ -25,10 +25,10 @@ module Cucumber
|
|
25
25
|
self
|
26
26
|
end
|
27
27
|
|
28
|
-
def execute(gherkin_documents,
|
29
|
-
receiver = Test::Runner.new(report
|
30
|
-
filters << [Test::
|
31
|
-
filters << [Test::
|
28
|
+
def execute(gherkin_documents, mapping_definition, report, filters = [], run_options = {})
|
29
|
+
receiver = Test::Runner.new(report)
|
30
|
+
filters << [Test::Mapper, [mapping_definition]]
|
31
|
+
filters << [Test::DebugFilter, []] if run_options[:debug]
|
32
32
|
compile gherkin_documents, receiver, filters
|
33
33
|
self
|
34
34
|
end
|
@@ -204,6 +204,10 @@ module Cucumber
|
|
204
204
|
columns[col].__send__(:width)
|
205
205
|
end
|
206
206
|
|
207
|
+
def each_cell(&proc)
|
208
|
+
cell_matrix.each{ |row| row.each(&proc) }
|
209
|
+
end
|
210
|
+
|
207
211
|
def ==(other)
|
208
212
|
other.class == self.class && raw == other.raw
|
209
213
|
end
|
@@ -311,6 +315,10 @@ module Cucumber
|
|
311
315
|
@value = "(i) #{value.inspect}"
|
312
316
|
end
|
313
317
|
|
318
|
+
def ==(o)
|
319
|
+
value == o.value
|
320
|
+
end
|
321
|
+
|
314
322
|
# For testing only
|
315
323
|
def to_sexp #:nodoc:
|
316
324
|
[:cell, @value]
|
@@ -3,7 +3,7 @@ module Cucumber
|
|
3
3
|
module Ast
|
4
4
|
module DescribesItself
|
5
5
|
def describe_to(visitor, *args)
|
6
|
-
visitor.send(description_for_visitors, self, *args) do |child_visitor
|
6
|
+
visitor.send(description_for_visitors, self, *args) do |child_visitor|
|
7
7
|
children.each do |child|
|
8
8
|
child.describe_to(child_visitor, *args)
|
9
9
|
end
|
@@ -1,21 +1,27 @@
|
|
1
1
|
require 'cucumber/initializer'
|
2
2
|
require 'cucumber/core/ast/describes_itself'
|
3
3
|
require 'cucumber/core/ast/location'
|
4
|
+
require 'cucumber/core/ast/names'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module Core
|
7
8
|
module Ast
|
8
9
|
|
9
10
|
class ExamplesTable
|
11
|
+
include Names
|
10
12
|
include HasLocation
|
11
13
|
include DescribesItself
|
12
14
|
|
13
|
-
attr_reader :header, :keyword, :
|
15
|
+
attr_reader :header, :keyword, :tags, :comments, :location
|
14
16
|
|
15
17
|
include Cucumber.initializer(
|
16
|
-
:location, :comments, :tags, :keyword, :
|
18
|
+
:location, :comments, :tags, :keyword, :title, :description, :header, :example_rows
|
17
19
|
)
|
18
20
|
|
21
|
+
def gherkin_statement(node=nil)
|
22
|
+
@gherkin_statement ||= node
|
23
|
+
end
|
24
|
+
|
19
25
|
private
|
20
26
|
|
21
27
|
def description_for_visitors
|
@@ -19,11 +19,10 @@ module Cucumber
|
|
19
19
|
include Cucumber.initializer(:location, :background, :comments, :tags, :keyword, :title, :description, :feature_elements)
|
20
20
|
def initialize(*)
|
21
21
|
super
|
22
|
-
feature_elements.each { |e| e.feature = self }
|
23
22
|
end
|
24
23
|
|
25
|
-
def gherkin_statement(
|
26
|
-
@gherkin_statement ||=
|
24
|
+
def gherkin_statement(node = nil)
|
25
|
+
@gherkin_statement ||= node
|
27
26
|
end
|
28
27
|
|
29
28
|
def children
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require 'cucumber/core/platform'
|
2
3
|
module Cucumber
|
3
4
|
module Core
|
4
5
|
module Ast
|
@@ -26,6 +27,10 @@ module Cucumber
|
|
26
27
|
[filepath.to_s, lines.to_s].reject { |v| v == WILDCARD.to_s }.join(":")
|
27
28
|
end
|
28
29
|
|
30
|
+
def hash
|
31
|
+
self.class.hash ^ to_s.hash
|
32
|
+
end
|
33
|
+
|
29
34
|
def to_str
|
30
35
|
to_s
|
31
36
|
end
|
@@ -49,14 +54,16 @@ module Cucumber
|
|
49
54
|
end
|
50
55
|
|
51
56
|
require 'set'
|
52
|
-
class Lines
|
57
|
+
class Lines < Struct.new(:data)
|
58
|
+
protected :data
|
53
59
|
attr_reader :line
|
60
|
+
|
54
61
|
def initialize(line)
|
55
62
|
if Cucumber::JRUBY && line.is_a?(::Java::GherkinFormatterModel::Range)
|
56
63
|
line = Range.new(line.first, line.last)
|
57
64
|
end
|
58
65
|
@line = line
|
59
|
-
|
66
|
+
super Array(line).to_set
|
60
67
|
end
|
61
68
|
|
62
69
|
def include?(other)
|
@@ -68,14 +75,12 @@ module Cucumber
|
|
68
75
|
boundary.join('..')
|
69
76
|
end
|
70
77
|
|
71
|
-
def
|
72
|
-
|
78
|
+
def inspect
|
79
|
+
"<#{self.class}: #{to_s}>"
|
73
80
|
end
|
74
81
|
|
75
82
|
protected
|
76
83
|
|
77
|
-
attr_reader :data
|
78
|
-
|
79
84
|
def boundary
|
80
85
|
first_and_last(value).uniq
|
81
86
|
end
|
@@ -2,9 +2,18 @@ module Cucumber
|
|
2
2
|
module Core
|
3
3
|
module Ast
|
4
4
|
module Names
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :description
|
6
6
|
|
7
7
|
def name
|
8
|
+
title
|
9
|
+
end
|
10
|
+
|
11
|
+
def title
|
12
|
+
warn("deprecated. Use #name")
|
13
|
+
@title
|
14
|
+
end
|
15
|
+
|
16
|
+
def legacy_conflated_name_and_description
|
8
17
|
s = @title
|
9
18
|
s += "\n#{@description}" if @description != ""
|
10
19
|
s
|
@@ -15,14 +15,17 @@ module Cucumber
|
|
15
15
|
def initialize(language, location, keyword, name, multiline_arg)
|
16
16
|
@language, @location, @keyword, @name, @multiline_arg = language, location, keyword, name, multiline_arg
|
17
17
|
@language || raise("Language is required!")
|
18
|
+
@gherkin_statement = nil
|
18
19
|
end
|
19
20
|
|
20
|
-
def gherkin_statement(
|
21
|
-
@gherkin_statement ||=
|
21
|
+
def gherkin_statement(node = nil)
|
22
|
+
@gherkin_statement ||= node
|
22
23
|
end
|
23
24
|
|
24
25
|
def to_step(row)
|
25
|
-
Ast::Step.new(language, location, keyword, row.expand(name), replace_multiline_arg(row))
|
26
|
+
step = Ast::Step.new(language, location, keyword, row.expand(name), replace_multiline_arg(row))
|
27
|
+
step.gherkin_statement(@gherkin_statement)
|
28
|
+
step
|
26
29
|
end
|
27
30
|
|
28
31
|
private
|
@@ -13,7 +13,6 @@ module Cucumber
|
|
13
13
|
include DescribesItself
|
14
14
|
|
15
15
|
attr_reader :feature_tags
|
16
|
-
attr_accessor :feature
|
17
16
|
attr_reader :comments, :tags, :keyword, :background, :title, :location, :gherkin_statement
|
18
17
|
|
19
18
|
include Cucumber.initializer(:gherkin_statement, :language, :location, :background, :comments, :tags, :feature_tags, :keyword, :title, :description, :raw_steps)
|
@@ -13,7 +13,6 @@ module Cucumber
|
|
13
13
|
|
14
14
|
MissingExamples = Class.new(StandardError)
|
15
15
|
|
16
|
-
attr_accessor :feature
|
17
16
|
attr_reader :feature_tags
|
18
17
|
|
19
18
|
attr_reader :line
|
@@ -23,8 +22,8 @@ module Cucumber
|
|
23
22
|
|
24
23
|
attr_reader :comments, :tags, :keyword, :background, :location
|
25
24
|
|
26
|
-
def gherkin_statement(node)
|
27
|
-
@gherkin_statement
|
25
|
+
def gherkin_statement(node = nil)
|
26
|
+
@gherkin_statement ||= node
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -14,8 +14,8 @@ module Cucumber
|
|
14
14
|
@location, @keyword, @name, @multiline_arg = location, keyword, name, multiline_arg
|
15
15
|
end
|
16
16
|
|
17
|
-
def gherkin_statement(
|
18
|
-
@gherkin_statement ||=
|
17
|
+
def gherkin_statement(node = nil)
|
18
|
+
@gherkin_statement ||= node
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_sexp
|
@@ -224,6 +224,7 @@ module Cucumber
|
|
224
224
|
|
225
225
|
class ScenarioOutlineBuilder < Builder
|
226
226
|
def result(background, language, feature_tags)
|
227
|
+
raise ParseError.new("Missing Examples section for Scenario Outline at #{location}") if examples_tables.empty?
|
227
228
|
scenario_outline = Ast::ScenarioOutline.new(
|
228
229
|
language,
|
229
230
|
location,
|
@@ -266,7 +267,7 @@ module Cucumber
|
|
266
267
|
class ExamplesTableBuilder < Builder
|
267
268
|
|
268
269
|
def result
|
269
|
-
Ast::ExamplesTable.new(
|
270
|
+
examples_table = Ast::ExamplesTable.new(
|
270
271
|
location,
|
271
272
|
comments,
|
272
273
|
tags,
|
@@ -276,6 +277,8 @@ module Cucumber
|
|
276
277
|
header,
|
277
278
|
example_rows
|
278
279
|
)
|
280
|
+
examples_table.gherkin_statement(node)
|
281
|
+
examples_table
|
279
282
|
end
|
280
283
|
|
281
284
|
private
|
@@ -12,8 +12,12 @@ module Cucumber
|
|
12
12
|
super(test_steps, source, around_hooks)
|
13
13
|
end
|
14
14
|
|
15
|
+
def step_count
|
16
|
+
test_steps.count
|
17
|
+
end
|
18
|
+
|
15
19
|
def describe_to(visitor, *args)
|
16
|
-
visitor.test_case(self, *args) do |child_visitor
|
20
|
+
visitor.test_case(self, *args) do |child_visitor|
|
17
21
|
compose_around_hooks(child_visitor, *args) do
|
18
22
|
test_steps.each do |test_step|
|
19
23
|
test_step.describe_to(child_visitor, *args)
|
@@ -24,7 +28,7 @@ module Cucumber
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def describe_source_to(visitor, *args)
|
27
|
-
source.each do |node|
|
31
|
+
source.reverse.each do |node|
|
28
32
|
node.describe_to(visitor, *args)
|
29
33
|
end
|
30
34
|
self
|
@@ -101,19 +105,19 @@ module Cucumber
|
|
101
105
|
end
|
102
106
|
|
103
107
|
def scenario_outline(outline)
|
104
|
-
@result = "#{outline.keyword}: #{outline.name}"
|
108
|
+
@result = "#{outline.keyword}: #{outline.name}" + @result
|
105
109
|
self
|
106
110
|
end
|
107
111
|
|
108
112
|
def examples_table(table)
|
109
113
|
name = table.name.strip
|
110
114
|
name = table.keyword if name.length == 0
|
111
|
-
@result
|
115
|
+
@result = ", #{name}" + @result
|
112
116
|
self
|
113
117
|
end
|
114
118
|
|
115
119
|
def examples_table_row(row)
|
116
|
-
@result
|
120
|
+
@result = " (row #{row.number})"
|
117
121
|
self
|
118
122
|
end
|
119
123
|
end
|
@@ -128,7 +132,7 @@ module Cucumber
|
|
128
132
|
|
129
133
|
[:feature, :scenario, :scenario_outline, :examples_table].each do |node_name|
|
130
134
|
define_method(node_name) do |node|
|
131
|
-
@result
|
135
|
+
@result = node.tags + @result
|
132
136
|
self
|
133
137
|
end
|
134
138
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Core
|
3
|
+
module Test
|
4
|
+
class DebugFilter
|
5
|
+
def initialize(receiver)
|
6
|
+
@receiver = receiver
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_case(test_case, &descend)
|
10
|
+
p [:test_case, test_case.source.last.class, test_case.location.to_s]
|
11
|
+
descend.call(self)
|
12
|
+
test_case.describe_to @receiver
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_step(test_step)
|
17
|
+
p [:test_step, test_step.source.last.class, test_step.location.to_s]
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def done
|
22
|
+
@receiver.done
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -49,7 +49,7 @@ module Cucumber
|
|
49
49
|
class TagLimits
|
50
50
|
TAG_MATCHER = /^
|
51
51
|
(?:~)? #The tag negation symbol "~". This is optional and not captured.
|
52
|
-
(?<tag_name
|
52
|
+
(?<tag_name>\@\w+) #Captures the tag name including the "@" symbol.
|
53
53
|
\: #The seperator, ":", between the tag name and the limit.
|
54
54
|
(?<limit>\d+) #Caputres the limit number.
|
55
55
|
$/x
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'cucumber/initializer'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Core
|
5
|
+
module Test
|
6
|
+
module Hooks
|
7
|
+
|
8
|
+
class BeforeHook
|
9
|
+
include Cucumber.initializer(:location)
|
10
|
+
public :location
|
11
|
+
|
12
|
+
def name
|
13
|
+
"Before hook"
|
14
|
+
end
|
15
|
+
|
16
|
+
def match_locations?(queried_locations)
|
17
|
+
queried_locations.any? { |other_location| other_location.match?(location) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def describe_to(visitor, *args)
|
21
|
+
visitor.before_hook(self, *args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class AfterHook
|
26
|
+
include Cucumber.initializer(:location)
|
27
|
+
public :location
|
28
|
+
|
29
|
+
def name
|
30
|
+
"After hook"
|
31
|
+
end
|
32
|
+
|
33
|
+
def match_locations?(queried_locations)
|
34
|
+
queried_locations.any? { |other_location| other_location.match?(location) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def describe_to(visitor, *args)
|
38
|
+
visitor.after_hook(self, *args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class AroundHook
|
43
|
+
def initialize(&block)
|
44
|
+
@block = block
|
45
|
+
end
|
46
|
+
|
47
|
+
def describe_to(visitor, *args, &continue)
|
48
|
+
visitor.around_hook(self, *args, &continue)
|
49
|
+
end
|
50
|
+
|
51
|
+
def call(continue)
|
52
|
+
@block.call(continue)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class AfterStepHook
|
57
|
+
include Cucumber.initializer(:location)
|
58
|
+
public :location
|
59
|
+
|
60
|
+
def name
|
61
|
+
"AfterStep hook"
|
62
|
+
end
|
63
|
+
|
64
|
+
def match_locations?(queried_locations)
|
65
|
+
queried_locations.any? { |other_location| other_location.match?(location) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def describe_to(visitor, *args)
|
69
|
+
visitor.after_step_hook(self, *args)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|