cucumber_analytics 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/History.rdoc +13 -2
- data/features/modeling/background_modeling.feature +5 -0
- data/features/modeling/example_modeling.feature +16 -8
- data/features/modeling/feature_modeling.feature +4 -1
- data/features/modeling/outline_modeling.feature +4 -0
- data/features/modeling/row_modeling.feature +67 -0
- data/features/modeling/scenario_modeling.feature +4 -0
- data/features/modeling/step_modeling.feature +6 -0
- data/features/modeling/table_modeling.feature +1 -1
- data/features/step_definitions/outline_steps.rb +35 -7
- data/features/step_definitions/step_steps.rb +11 -0
- data/lib/cucumber_analytics/example.rb +32 -7
- data/lib/cucumber_analytics/feature_element.rb +4 -0
- data/lib/cucumber_analytics/row.rb +58 -0
- data/lib/cucumber_analytics/sourceable.rb +20 -0
- data/lib/cucumber_analytics/step.rb +2 -1
- data/lib/cucumber_analytics/version.rb +1 -1
- data/lib/cucumber_analytics/world.rb +5 -0
- data/lib/cucumber_analytics.rb +2 -0
- data/spec/integration/example_integration_spec.rb +20 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/background_unit_spec.rb +1 -0
- data/spec/unit/example_unit_spec.rb +23 -0
- data/spec/unit/feature_unit_spec.rb +1 -0
- data/spec/unit/outline_unit_spec.rb +1 -0
- data/spec/unit/row_unit_spec.rb +39 -0
- data/spec/unit/scenario_unit_spec.rb +1 -0
- data/spec/unit/sourceable_unit_spec.rb +17 -0
- data/spec/unit/sourced_element_unit_specs.rb +18 -0
- data/spec/unit/step_unit_spec.rb +1 -1
- data/spec/unit/world_unit_spec.rb +13 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTZmMTk1NmM2NDY0M2RlMGUyMjhlOTIyMjQ0MzlhOTliYzU5ZGNmNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGVkYTM0YzUxZDFjYWI5OGE3OTMzZDViYzQyYmZjMWQyYjg5MDhjYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Nzg4NTJkMWYxOTE4ZGFkMTJmMDIxYmU3ZmIxZTVhY2VkNmI2YWM5MDVlZjBl
|
10
|
+
ZDdiZjFmNjViNDFkY2Q1Yzk4MGE5NDYwMzRmNmE0OWQ3MTc5ZGJiNzEyNDE1
|
11
|
+
MzZjYWVkZTNlY2UyMzJhM2QyMTMyZjNhZmQ1NGNhOGM5ZThlYTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTc0MzBmOGFmYTE1YTM2NzkyNTg0NTI1YWY0NGM5M2EwOTgyNGE2N2FiMzhk
|
14
|
+
ZTE3NDJmMWM2YmRhZDNjNzE5NjYyY2UxNTQ2NDY5Y2YyZDk3YzU1ZDM4YmMx
|
15
|
+
ZThmM2JiNTYyNjdlNWMyOTllY2NhYzU5N2VjOGEzMzIyZDJhNDc=
|
data/History.rdoc
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
+
=== Version 1.1.0 / 2013-08-03
|
2
|
+
|
3
|
+
* Version bumped due to publishing wrong code for version 1.1.0.
|
4
|
+
|
5
|
+
=== Version 1.1.0 / 2013-08-01
|
6
|
+
|
7
|
+
* Outline example rows are now modeled.
|
8
|
+
* Some elements now keep track of which source code line number they started on.
|
9
|
+
* Step definition patterns that have been loaded in the World can now be cleared.
|
10
|
+
|
11
|
+
|
1
12
|
=== Version 1.0.0 / 2013-06-30
|
2
13
|
|
3
14
|
* Bug fix: Step definitions are now detected whether or not parenthesis are
|
4
15
|
used in the declararion.
|
5
16
|
* Now using the gherkin gem to parse feature files. This should eliminate most
|
6
17
|
parsing related bugs.
|
7
|
-
* Empty outline example blocks can
|
8
|
-
can likewise not handle them).
|
18
|
+
* Empty outline example blocks can no longer be handeled (since the gherkin gem
|
19
|
+
can, likewise, not handle them).
|
9
20
|
* Source code snippets can now be analyzed (rather than needing an entire feature
|
10
21
|
file to parse).
|
11
22
|
* Logging has been removed from the gem due to its significant negative impact
|
@@ -7,6 +7,7 @@ Feature: Background elements can be modeled.
|
|
7
7
|
1. the background's name
|
8
8
|
2. the background's description
|
9
9
|
3. the background's steps
|
10
|
+
4. the background's source line
|
10
11
|
|
11
12
|
Background: Test file setup.
|
12
13
|
Given the following feature file:
|
@@ -25,6 +26,10 @@ Feature: Background elements can be modeled.
|
|
25
26
|
When the file is read
|
26
27
|
|
27
28
|
|
29
|
+
Scenario: The background source line is modeled.
|
30
|
+
Then the background is found to have the following properties:
|
31
|
+
| source_line | 3 |
|
32
|
+
|
28
33
|
Scenario: The background name is modeled.
|
29
34
|
Then the background is found to have the following properties:
|
30
35
|
| name | Some general test setup stuff. |
|
@@ -4,12 +4,13 @@ Feature: Example elements can be modeled.
|
|
4
4
|
Acceptance criteria
|
5
5
|
|
6
6
|
All conceptual pieces of an Examples block can be modeled:
|
7
|
-
1. the
|
8
|
-
2. the
|
9
|
-
3. the
|
10
|
-
4. the
|
11
|
-
5. the
|
12
|
-
6. the
|
7
|
+
1. the example's name
|
8
|
+
2. the example's description
|
9
|
+
3. the example's parameters
|
10
|
+
4. the example's rows
|
11
|
+
5. the example's tags
|
12
|
+
6. the example's applied tags
|
13
|
+
7. the example's source line
|
13
14
|
|
14
15
|
|
15
16
|
Background: Test file setup.
|
@@ -38,6 +39,12 @@ Feature: Example elements can be modeled.
|
|
38
39
|
When the file is read
|
39
40
|
|
40
41
|
|
42
|
+
Scenario: The example's source line is modeled.
|
43
|
+
Then the test example block "1" is found to have the following properties:
|
44
|
+
| source_line | 8 |
|
45
|
+
And the test example block "2" is found to have the following properties:
|
46
|
+
| source_line | 15 |
|
47
|
+
|
41
48
|
Scenario: The examples' name is modeled.
|
42
49
|
Then the test example block "1" is found to have the following properties:
|
43
50
|
| name | text describing the significance of the examples |
|
@@ -83,5 +90,6 @@ Feature: Example elements can be modeled.
|
|
83
90
|
When the corresponding unit tests are run
|
84
91
|
Then all of those specifications are met
|
85
92
|
Examples:
|
86
|
-
| additional specifications
|
87
|
-
| example_unit_spec.rb
|
93
|
+
| additional specifications |
|
94
|
+
| example_unit_spec.rb |
|
95
|
+
| example_integration_spec.rb |
|
@@ -12,7 +12,7 @@ Feature: Features can be modeled.
|
|
12
12
|
6. the feature's background
|
13
13
|
7. the feature's total number of tests
|
14
14
|
8. the feature's total number of test cases
|
15
|
-
|
15
|
+
9. the feature's source line
|
16
16
|
|
17
17
|
Background: Test file setup.
|
18
18
|
Given the following feature file "much_stuff.feature":
|
@@ -67,15 +67,18 @@ Feature: Features can be modeled.
|
|
67
67
|
| name | The test feature name. |
|
68
68
|
| test_count | 3 |
|
69
69
|
| test_case_count | 5 |
|
70
|
+
| source_line | 3 |
|
70
71
|
And feature "2" is found to have the following properties:
|
71
72
|
| name | |
|
72
73
|
| test_count | 2 |
|
73
74
|
| test_case_count | 1 |
|
75
|
+
| source_line | 1 |
|
74
76
|
|
75
77
|
And feature "3" is found to have the following properties:
|
76
78
|
| name | |
|
77
79
|
| test_count | 0 |
|
78
80
|
| test_case_count | 0 |
|
81
|
+
| source_line | 1 |
|
79
82
|
|
80
83
|
Scenario: The feature's description is modeled.
|
81
84
|
Then the descriptive lines of feature "1" are as follows:
|
@@ -10,6 +10,7 @@ Feature: Scenario Outline elements can be modeled.
|
|
10
10
|
4. the outline's tags
|
11
11
|
5. the outline's applied tags
|
12
12
|
6. the outline's example blocks
|
13
|
+
7. the outline's source line
|
13
14
|
|
14
15
|
|
15
16
|
Background: Test file setup.
|
@@ -37,6 +38,9 @@ Feature: Scenario Outline elements can be modeled.
|
|
37
38
|
And parameter delimiters of "*" and "*"
|
38
39
|
When the file is read
|
39
40
|
|
41
|
+
Scenario: The outline source line is modeled.
|
42
|
+
Then the test is found to have the following properties:
|
43
|
+
| source_line | 5 |
|
40
44
|
|
41
45
|
Scenario: The outline name is modeled.
|
42
46
|
Then the test is found to have the following properties:
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Feature: Row elements can be modeled.
|
2
|
+
|
3
|
+
|
4
|
+
Acceptance criteria
|
5
|
+
|
6
|
+
All conceptual pieces of a Row can be modeled:
|
7
|
+
1. the row's source line
|
8
|
+
2. the row's cells
|
9
|
+
|
10
|
+
|
11
|
+
Background: Test file setup.
|
12
|
+
Given the following feature file:
|
13
|
+
"""
|
14
|
+
Feature:
|
15
|
+
|
16
|
+
Scenario Outline:
|
17
|
+
* a step
|
18
|
+
Examples:
|
19
|
+
| param1 | param2 | extra param |
|
20
|
+
| x | y | ? |
|
21
|
+
| 1 | 2 | 3 |
|
22
|
+
Examples:
|
23
|
+
| param1 |
|
24
|
+
| a |
|
25
|
+
"""
|
26
|
+
And parameter delimiters of "*" and "*"
|
27
|
+
When the file is read
|
28
|
+
|
29
|
+
|
30
|
+
Scenario: The row's source line is modeled.
|
31
|
+
Then the test example block "1" row "1" is found to have the following properties:
|
32
|
+
| source_line | 6 |
|
33
|
+
And the test example block "1" row "2" is found to have the following properties:
|
34
|
+
| source_line | 7 |
|
35
|
+
And the test example block "1" row "3" is found to have the following properties:
|
36
|
+
| source_line | 8 |
|
37
|
+
And the test example block "2" row "1" is found to have the following properties:
|
38
|
+
| source_line | 10 |
|
39
|
+
And the test example block "2" row "2" is found to have the following properties:
|
40
|
+
| source_line | 11 |
|
41
|
+
|
42
|
+
Scenario: The row's cells are modeled.
|
43
|
+
Then the test example block "1" row "1" cells are as follows:
|
44
|
+
| param1 |
|
45
|
+
| param2 |
|
46
|
+
| extra param |
|
47
|
+
And the test example block "1" row "2" cells are as follows:
|
48
|
+
| x |
|
49
|
+
| y |
|
50
|
+
| ? |
|
51
|
+
And the test example block "1" row "3" cells are as follows:
|
52
|
+
| 1 |
|
53
|
+
| 2 |
|
54
|
+
| 3 |
|
55
|
+
And the test example block "2" row "1" cells are as follows:
|
56
|
+
| param1 |
|
57
|
+
And the test example block "2" row "2" cells are as follows:
|
58
|
+
| a |
|
59
|
+
|
60
|
+
Scenario Outline: Row models pass all other specifications
|
61
|
+
Exact specifications detailing the API for Row models.
|
62
|
+
Given that there are "<additional specifications>" detailing models
|
63
|
+
When the corresponding unit tests are run
|
64
|
+
Then all of those specifications are met
|
65
|
+
Examples:
|
66
|
+
| additional specifications |
|
67
|
+
| row_unit_spec.rb |
|
@@ -9,6 +9,7 @@ Feature: Scenario elements can be modeled.
|
|
9
9
|
3. the scenario's steps
|
10
10
|
4. the scenario's tags
|
11
11
|
5. the scenario's applied tags
|
12
|
+
6. the scenario's source line
|
12
13
|
|
13
14
|
|
14
15
|
Background: Test file setup.
|
@@ -30,6 +31,9 @@ Feature: Scenario elements can be modeled.
|
|
30
31
|
And parameter delimiters of "*" and "*"
|
31
32
|
When the file is read
|
32
33
|
|
34
|
+
Scenario: The scenario source line is modeled.
|
35
|
+
Then the test is found to have the following properties:
|
36
|
+
| source_line | 6 |
|
33
37
|
|
34
38
|
Scenario: The scenario name is modeled.
|
35
39
|
Then the test is found to have the following properties:
|
@@ -8,6 +8,7 @@ Feature: Step elements can be modeled.
|
|
8
8
|
2. the text of the step
|
9
9
|
3. the step's arguments, if any
|
10
10
|
4. the step's associated block, if any
|
11
|
+
5. the step's source line
|
11
12
|
|
12
13
|
|
13
14
|
Background: Test file setup.
|
@@ -30,6 +31,11 @@ Feature: Step elements can be modeled.
|
|
30
31
|
And parameter delimiters of "*" and "*"
|
31
32
|
When the file is read
|
32
33
|
|
34
|
+
Scenario: The step's source line is modeled.
|
35
|
+
Then the test step "1" source line is "4"
|
36
|
+
And the test step "2" source line is "5"
|
37
|
+
And the test step "3" source line is "10"
|
38
|
+
And the test step "4" source line is "13"
|
33
39
|
|
34
40
|
Scenario: The step's keyword is modeled.
|
35
41
|
Then the test step "1" keyword is "Given"
|
@@ -23,7 +23,7 @@ Feature: Table elements can be modeled.
|
|
23
23
|
When the file is read
|
24
24
|
|
25
25
|
|
26
|
-
Scenario: The table's contents are modeled.
|
26
|
+
Scenario: The table's contents are modeled.
|
27
27
|
Then the step "1" table has the following contents:
|
28
28
|
| value 1 | value 2 |
|
29
29
|
| value 3 | value 4 |
|
@@ -20,6 +20,22 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? row(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, example, row, properties|
|
24
|
+
file ||= 1
|
25
|
+
test ||= 1
|
26
|
+
example ||= 1
|
27
|
+
row ||= 1
|
28
|
+
|
29
|
+
properties = properties.rows_hash
|
30
|
+
|
31
|
+
properties.each do |property, value|
|
32
|
+
expected = value
|
33
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].send(property.to_sym).to_s
|
34
|
+
|
35
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
23
39
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? descriptive lines are as follows:$/ do |file, test, example, lines|
|
24
40
|
file ||= 1
|
25
41
|
test ||= 1
|
@@ -72,10 +88,10 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
72
88
|
example ||= 1
|
73
89
|
|
74
90
|
rows = rows.raw.flatten
|
75
|
-
|
91
|
+
example = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1]
|
76
92
|
|
77
|
-
expected = rows.collect { |row| row.split(',') }
|
78
|
-
actual =
|
93
|
+
expected = rows.collect { |row| row.split(',') }
|
94
|
+
actual = example.row_elements[1..example.row_elements.count].collect { |row| row.cells }
|
79
95
|
|
80
96
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
81
97
|
end
|
@@ -111,14 +127,24 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
111
127
|
test ||= 1
|
112
128
|
example ||= 1
|
113
129
|
|
114
|
-
|
115
|
-
|
116
|
-
expected = parameters
|
130
|
+
expected = parameters.raw.flatten
|
117
131
|
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].parameters
|
118
132
|
|
119
133
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
120
134
|
end
|
121
135
|
|
136
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? row(?: "([^"]*)")? cells are as follows:$/ do |file, test, example, row, cells|
|
137
|
+
file ||= 1
|
138
|
+
test ||= 1
|
139
|
+
example ||= 1
|
140
|
+
row ||= 1
|
141
|
+
|
142
|
+
expected = cells.raw.flatten
|
143
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].cells
|
144
|
+
|
145
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
146
|
+
end
|
147
|
+
|
122
148
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no descriptive lines$/ do |file, test, example|
|
123
149
|
file ||= 1
|
124
150
|
test ||= 1
|
@@ -140,8 +166,10 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
140
166
|
test ||= 1
|
141
167
|
example ||= 1
|
142
168
|
|
169
|
+
example = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1]
|
170
|
+
|
143
171
|
expected = []
|
144
|
-
actual =
|
172
|
+
actual = example.row_elements[1..example.row_elements.count]
|
145
173
|
|
146
174
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
147
175
|
end
|
@@ -89,3 +89,14 @@ Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)
|
|
89
89
|
|
90
90
|
actual.should == expected
|
91
91
|
end
|
92
|
+
|
93
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? source line is "([^"]*)"$/ do |file, test, step, line_number|
|
94
|
+
file ||= 1
|
95
|
+
test ||= 1
|
96
|
+
step ||= 1
|
97
|
+
|
98
|
+
expected = line_number.to_i
|
99
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].source_line
|
100
|
+
|
101
|
+
actual.should == expected
|
102
|
+
end
|
@@ -5,13 +5,21 @@ module CucumberAnalytics
|
|
5
5
|
class Example < FeatureElement
|
6
6
|
|
7
7
|
include Taggable
|
8
|
+
include Containing
|
9
|
+
|
8
10
|
|
9
11
|
# The argument rows in the example table
|
10
12
|
attr_accessor :rows
|
11
13
|
|
12
14
|
# The parameters for the example table
|
15
|
+
#
|
16
|
+
# todo - Make this a read only method that derives the parameters from
|
17
|
+
# the row elements
|
13
18
|
attr_accessor :parameters
|
14
19
|
|
20
|
+
# The row elements in the example table
|
21
|
+
attr_accessor :row_elements
|
22
|
+
|
15
23
|
|
16
24
|
# Creates a new Example object and, if *source* is provided,
|
17
25
|
# populates the object.
|
@@ -23,6 +31,7 @@ module CucumberAnalytics
|
|
23
31
|
@tags = []
|
24
32
|
@rows = []
|
25
33
|
@parameters = []
|
34
|
+
@row_elements = []
|
26
35
|
|
27
36
|
build_example(parsed_example) if parsed_example
|
28
37
|
end
|
@@ -34,8 +43,10 @@ module CucumberAnalytics
|
|
34
43
|
case
|
35
44
|
when row.is_a?(Array)
|
36
45
|
@rows << Hash[@parameters.zip(row.collect { |value| value.strip })]
|
46
|
+
@row_elements << Row.new("|#{row.join('|')}|")
|
37
47
|
when row.is_a?(Hash)
|
38
48
|
@rows << row.each_value { |value| value.strip! }
|
49
|
+
@row_elements << Row.new("|#{row.values.join('|')}|")
|
39
50
|
else
|
40
51
|
raise(ArgumentError, "Can only add row from a Hash or an Array but received #{row.class}")
|
41
52
|
end
|
@@ -55,6 +66,12 @@ module CucumberAnalytics
|
|
55
66
|
end
|
56
67
|
|
57
68
|
@rows.delete_at(location) if location
|
69
|
+
@row_elements.delete_at(location + 1) if location
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns the immediate child elements of the element.
|
73
|
+
def contains
|
74
|
+
@row_elements
|
58
75
|
end
|
59
76
|
|
60
77
|
|
@@ -81,18 +98,26 @@ module CucumberAnalytics
|
|
81
98
|
|
82
99
|
def build_example(parsed_example)
|
83
100
|
populate_element_tags(parsed_example)
|
84
|
-
|
85
|
-
|
101
|
+
populate_example_row_elements(parsed_example)
|
102
|
+
populate_example_parameters
|
103
|
+
populate_example_rows
|
86
104
|
end
|
87
105
|
|
88
|
-
def populate_example_parameters
|
89
|
-
@parameters =
|
106
|
+
def populate_example_parameters
|
107
|
+
@parameters = @row_elements.first.cells
|
108
|
+
end
|
109
|
+
|
110
|
+
def populate_example_rows
|
111
|
+
@row_elements.each do |row|
|
112
|
+
@rows << Hash[@parameters.zip(row.cells)]
|
113
|
+
end
|
114
|
+
|
115
|
+
@rows.shift
|
90
116
|
end
|
91
117
|
|
92
|
-
def
|
93
|
-
parsed_example['rows'].shift
|
118
|
+
def populate_example_row_elements(parsed_example)
|
94
119
|
parsed_example['rows'].each do |row|
|
95
|
-
@
|
120
|
+
@row_elements << build_child_element(Row, row)
|
96
121
|
end
|
97
122
|
end
|
98
123
|
|
@@ -4,6 +4,9 @@ module CucumberAnalytics
|
|
4
4
|
|
5
5
|
class FeatureElement
|
6
6
|
|
7
|
+
include Sourceable
|
8
|
+
|
9
|
+
|
7
10
|
# The name of the FeatureElement
|
8
11
|
attr_accessor :name
|
9
12
|
|
@@ -30,6 +33,7 @@ module CucumberAnalytics
|
|
30
33
|
def build_feature_element(parsed_element)
|
31
34
|
populate_feature_element_name(parsed_element)
|
32
35
|
populate_feature_element_description(parsed_element)
|
36
|
+
populate_element_source_line(parsed_element)
|
33
37
|
end
|
34
38
|
|
35
39
|
def populate_feature_element_name(parsed_element)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module CucumberAnalytics
|
2
|
+
|
3
|
+
# A class modeling a Cucumber Examples table row.
|
4
|
+
|
5
|
+
class Row
|
6
|
+
|
7
|
+
include Sourceable
|
8
|
+
|
9
|
+
# The parent object that contains *self*
|
10
|
+
attr_accessor :parent_element
|
11
|
+
|
12
|
+
# The cells that make up the row
|
13
|
+
attr_accessor :cells
|
14
|
+
|
15
|
+
|
16
|
+
# Creates a new Row object and, if *source* is provided, populates
|
17
|
+
# the object.
|
18
|
+
def initialize(source = nil)
|
19
|
+
parsed_row = process_source(source)
|
20
|
+
|
21
|
+
@cells = []
|
22
|
+
|
23
|
+
build_row(parsed_row) if parsed_row
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
|
30
|
+
def process_source(source)
|
31
|
+
case
|
32
|
+
when source.is_a?(String)
|
33
|
+
parse_row(source)
|
34
|
+
else
|
35
|
+
source
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_row(source_text)
|
40
|
+
base_file_string = "Feature: Fake feature to parse\nScenario Outline:\n* fake step\nExamples: fake examples\n"
|
41
|
+
source_text = base_file_string + source_text
|
42
|
+
|
43
|
+
parsed_file = Parsing::parse_text(source_text)
|
44
|
+
|
45
|
+
parsed_file.first['elements'].first['examples'].first['rows'].first
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_row(parsed_row)
|
49
|
+
populate_element_source_line(parsed_row)
|
50
|
+
populate_row_cells(parsed_row)
|
51
|
+
end
|
52
|
+
|
53
|
+
def populate_row_cells(parsed_row)
|
54
|
+
@cells = parsed_row['cells']
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CucumberAnalytics
|
2
|
+
|
3
|
+
# A mix-in module containing methods used by elements that know their
|
4
|
+
# source code line.
|
5
|
+
|
6
|
+
module Sourceable
|
7
|
+
|
8
|
+
# The line number where the element began in the source code
|
9
|
+
attr_reader :source_line
|
10
|
+
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
|
15
|
+
def populate_element_source_line(parsed_element)
|
16
|
+
@source_line = parsed_element['line']
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -5,7 +5,7 @@ module CucumberAnalytics
|
|
5
5
|
class Step
|
6
6
|
|
7
7
|
include Containing
|
8
|
-
|
8
|
+
include Sourceable
|
9
9
|
|
10
10
|
# The step's keyword
|
11
11
|
attr_accessor :keyword
|
@@ -157,6 +157,7 @@ module CucumberAnalytics
|
|
157
157
|
populate_base(step)
|
158
158
|
populate_block(step)
|
159
159
|
populate_keyword(step)
|
160
|
+
populate_element_source_line(step)
|
160
161
|
|
161
162
|
scan_arguments
|
162
163
|
end
|
@@ -75,6 +75,11 @@ module CucumberAnalytics
|
|
75
75
|
@defined_expressions ||= []
|
76
76
|
end
|
77
77
|
|
78
|
+
# Clears the step patterns that have been loaded into the World.
|
79
|
+
def clear_step_patterns
|
80
|
+
@defined_expressions = []
|
81
|
+
end
|
82
|
+
|
78
83
|
# Returns all tags found in the passed container.
|
79
84
|
def tags_in(container)
|
80
85
|
Array.new.tap { |accumulated_tags| collect_all_in(:tags, container, accumulated_tags) }
|
data/lib/cucumber_analytics.rb
CHANGED
@@ -2,6 +2,7 @@ require 'cucumber_analytics/version'
|
|
2
2
|
require 'cucumber_analytics/parsing'
|
3
3
|
require 'cucumber_analytics/containing'
|
4
4
|
require 'cucumber_analytics/taggable'
|
5
|
+
require 'cucumber_analytics/sourceable'
|
5
6
|
require 'cucumber_analytics/feature_file'
|
6
7
|
require 'cucumber_analytics/directory'
|
7
8
|
require 'cucumber_analytics/feature_element.rb'
|
@@ -15,3 +16,4 @@ require 'cucumber_analytics/step'
|
|
15
16
|
require 'cucumber_analytics/doc_string'
|
16
17
|
require 'cucumber_analytics/table'
|
17
18
|
require 'cucumber_analytics/world'
|
19
|
+
require 'cucumber_analytics/row'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
SimpleCov.command_name('Example') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
+
|
5
|
+
describe 'Example, Integration' do
|
6
|
+
|
7
|
+
it 'properly sets its child elements' do
|
8
|
+
source = ['Examples:',
|
9
|
+
' | param |',
|
10
|
+
' | value 1 |']
|
11
|
+
source = source.join("\n")
|
12
|
+
|
13
|
+
example = CucumberAnalytics::Example.new(source)
|
14
|
+
rows = example.row_elements
|
15
|
+
|
16
|
+
rows[0].parent_element.should equal example
|
17
|
+
rows[1].parent_element.should equal example
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,7 @@ require "#{File.dirname(__FILE__)}/unit/containing_element_unit_specs"
|
|
9
9
|
require "#{File.dirname(__FILE__)}/unit/bare_bones_unit_specs"
|
10
10
|
require "#{File.dirname(__FILE__)}/unit/test_element_unit_specs"
|
11
11
|
require "#{File.dirname(__FILE__)}/unit/prepopulated_unit_specs"
|
12
|
+
require "#{File.dirname(__FILE__)}/unit/sourced_element_unit_specs"
|
12
13
|
|
13
14
|
|
14
15
|
DEFAULT_FEATURE_FILE_NAME = 'test_feature.feature'
|
@@ -12,6 +12,7 @@ describe 'Background, Unit' do
|
|
12
12
|
it_should_behave_like 'a bare bones element', clazz
|
13
13
|
it_should_behave_like 'a prepopulated element', clazz
|
14
14
|
it_should_behave_like 'a test element', clazz
|
15
|
+
it_should_behave_like 'a sourced element', clazz
|
15
16
|
|
16
17
|
it 'can be parsed from stand alone text' do
|
17
18
|
source = 'Background: '
|
@@ -11,6 +11,8 @@ describe 'Example, Unit' do
|
|
11
11
|
it_should_behave_like 'a tagged element', clazz
|
12
12
|
it_should_behave_like 'a bare bones element', clazz
|
13
13
|
it_should_behave_like 'a prepopulated element', clazz
|
14
|
+
it_should_behave_like 'a sourced element', clazz
|
15
|
+
it_should_behave_like 'a containing element', clazz
|
14
16
|
|
15
17
|
|
16
18
|
it 'can be parsed from stand alone text' do
|
@@ -78,6 +80,21 @@ describe 'Example, Unit' do
|
|
78
80
|
rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
79
81
|
end
|
80
82
|
|
83
|
+
it 'has row elements - #row_elements' do
|
84
|
+
@example.should respond_to(:row_elements)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'can get and set its row elements - #row_elements, #row_elements=' do
|
88
|
+
@example.row_elements = :some_row_elements
|
89
|
+
@example.row_elements.should == :some_row_elements
|
90
|
+
@example.row_elements = :some_other_row_elements
|
91
|
+
@example.row_elements.should == :some_other_row_elements
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'starts with no row elements' do
|
95
|
+
@example.row_elements.should == []
|
96
|
+
end
|
97
|
+
|
81
98
|
context '#add_row' do
|
82
99
|
|
83
100
|
it 'can add a new example row' do
|
@@ -92,6 +109,7 @@ describe 'Example, Unit' do
|
|
92
109
|
example.add_row(new_row)
|
93
110
|
|
94
111
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
112
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4']]
|
95
113
|
end
|
96
114
|
|
97
115
|
it 'can add a new row as an array' do
|
@@ -102,6 +120,7 @@ describe 'Example, Unit' do
|
|
102
120
|
example.add_row(new_row)
|
103
121
|
|
104
122
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
123
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4']]
|
105
124
|
end
|
106
125
|
|
107
126
|
it 'can only use a Hash or an Array to add a new row' do
|
@@ -120,6 +139,7 @@ describe 'Example, Unit' do
|
|
120
139
|
example.add_row(array_row)
|
121
140
|
|
122
141
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4'], ['value5', 'value6']]
|
142
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4'], ['value5', 'value6']]
|
123
143
|
end
|
124
144
|
end
|
125
145
|
|
@@ -137,6 +157,7 @@ describe 'Example, Unit' do
|
|
137
157
|
example.remove_row(old_row)
|
138
158
|
|
139
159
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
160
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2']]
|
140
161
|
end
|
141
162
|
|
142
163
|
it 'can remove an existing row as an array' do
|
@@ -147,6 +168,7 @@ describe 'Example, Unit' do
|
|
147
168
|
example.remove_row(old_row)
|
148
169
|
|
149
170
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
171
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2']]
|
150
172
|
end
|
151
173
|
|
152
174
|
it 'can only use a Hash or an Array to remove an existing row' do
|
@@ -165,6 +187,7 @@ describe 'Example, Unit' do
|
|
165
187
|
example.remove_row(array_row)
|
166
188
|
|
167
189
|
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
190
|
+
example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2']]
|
168
191
|
end
|
169
192
|
end
|
170
193
|
|
@@ -12,6 +12,7 @@ describe 'Feature, Unit' do
|
|
12
12
|
it_should_behave_like 'a tagged element', clazz
|
13
13
|
it_should_behave_like 'a bare bones element', clazz
|
14
14
|
it_should_behave_like 'a prepopulated element', clazz
|
15
|
+
it_should_behave_like 'a sourced element', clazz
|
15
16
|
|
16
17
|
before(:each) do
|
17
18
|
@feature = clazz.new
|
@@ -13,6 +13,7 @@ describe 'Outline, Unit' do
|
|
13
13
|
it_should_behave_like 'a bare bones element', clazz
|
14
14
|
it_should_behave_like 'a prepopulated element', clazz
|
15
15
|
it_should_behave_like 'a test element', clazz
|
16
|
+
it_should_behave_like 'a sourced element', clazz
|
16
17
|
|
17
18
|
|
18
19
|
it 'can be parsed from stand alone text' do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
SimpleCov.command_name('Row') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
+
|
5
|
+
describe 'Row, Unit' do
|
6
|
+
|
7
|
+
clazz = CucumberAnalytics::Row
|
8
|
+
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
10
|
+
it_should_behave_like 'a bare bones element', clazz
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
12
|
+
it_should_behave_like 'a sourced element', clazz
|
13
|
+
|
14
|
+
it 'can be parsed from stand alone text' do
|
15
|
+
source = '| a | row |'
|
16
|
+
|
17
|
+
expect { clazz.new(source) }.to_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
@table = clazz.new
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has cells - #cells' do
|
25
|
+
@table.should respond_to(:cells)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'can get and set its cells - #cells, #cells=' do
|
29
|
+
@table.cells = :some_cells
|
30
|
+
@table.cells.should == :some_cells
|
31
|
+
@table.cells = :some_other_cells
|
32
|
+
@table.cells.should == :some_other_cells
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'starts with no cells' do
|
36
|
+
@table.cells.should == []
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -13,6 +13,7 @@ describe 'Scenario, Unit' do
|
|
13
13
|
it_should_behave_like 'a bare bones element', clazz
|
14
14
|
it_should_behave_like 'a prepopulated element', clazz
|
15
15
|
it_should_behave_like 'a test element', clazz
|
16
|
+
it_should_behave_like 'a sourced element', clazz
|
16
17
|
|
17
18
|
it 'can be parsed from stand alone text' do
|
18
19
|
source = 'Scenario: '
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
SimpleCov.command_name('Sourceable') unless RUBY_VERSION.to_s < '1.9.0'
|
4
|
+
|
5
|
+
describe 'Sourceable, Unit' do
|
6
|
+
|
7
|
+
nodule = CucumberAnalytics::Sourceable
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@element = Object.new.extend(nodule)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has a source line - #source_line' do
|
14
|
+
@element.should respond_to(:source_line)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for 'a sourced element' do |clazz|
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@element = clazz.new
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it 'has a source line - #source_line' do
|
11
|
+
@element.should respond_to(:source_line)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'starts with no source line' do
|
15
|
+
@element.source_line.should == nil
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/unit/step_unit_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe 'Step, Unit' do
|
|
9
9
|
it_should_behave_like 'a nested element', clazz
|
10
10
|
it_should_behave_like 'a bare bones element', clazz
|
11
11
|
it_should_behave_like 'a prepopulated element', clazz
|
12
|
-
|
12
|
+
it_should_behave_like 'a sourced element', clazz
|
13
13
|
|
14
14
|
before(:each) do
|
15
15
|
@step = clazz.new
|
@@ -111,6 +111,19 @@ describe 'World, Unit' do
|
|
111
111
|
|
112
112
|
@world.loaded_step_patterns.should =~ patterns
|
113
113
|
end
|
114
|
+
|
115
|
+
it 'can clear its loaded step patterns - #clear_step_patterns' do
|
116
|
+
patterns = [/a pattern/, /another pattern/]
|
117
|
+
|
118
|
+
patterns.each do |pattern|
|
119
|
+
@world.load_step_pattern(pattern)
|
120
|
+
end
|
121
|
+
|
122
|
+
@world.loaded_step_patterns.should =~ patterns
|
123
|
+
@world.clear_step_patterns
|
124
|
+
@world.loaded_step_patterns.should == []
|
125
|
+
end
|
126
|
+
|
114
127
|
end
|
115
128
|
|
116
129
|
context 'collecting stuff' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kessler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- features/modeling/feature_file_modeling.feature
|
111
111
|
- features/modeling/feature_modeling.feature
|
112
112
|
- features/modeling/outline_modeling.feature
|
113
|
+
- features/modeling/row_modeling.feature
|
113
114
|
- features/modeling/scenario_modeling.feature
|
114
115
|
- features/modeling/step_modeling.feature
|
115
116
|
- features/modeling/table_modeling.feature
|
@@ -138,7 +139,9 @@ files:
|
|
138
139
|
- lib/cucumber_analytics/feature_file.rb
|
139
140
|
- lib/cucumber_analytics/outline.rb
|
140
141
|
- lib/cucumber_analytics/parsing.rb
|
142
|
+
- lib/cucumber_analytics/row.rb
|
141
143
|
- lib/cucumber_analytics/scenario.rb
|
144
|
+
- lib/cucumber_analytics/sourceable.rb
|
142
145
|
- lib/cucumber_analytics/step.rb
|
143
146
|
- lib/cucumber_analytics/table.rb
|
144
147
|
- lib/cucumber_analytics/taggable.rb
|
@@ -147,6 +150,7 @@ files:
|
|
147
150
|
- lib/cucumber_analytics/world.rb
|
148
151
|
- spec/integration/background_integration_spec.rb
|
149
152
|
- spec/integration/directory_integration_spec.rb
|
153
|
+
- spec/integration/example_integration_spec.rb
|
150
154
|
- spec/integration/feature_file_integration_spec.rb
|
151
155
|
- spec/integration/feature_integration_spec.rb
|
152
156
|
- spec/integration/outline_integration_spec.rb
|
@@ -168,7 +172,10 @@ files:
|
|
168
172
|
- spec/unit/outline_unit_spec.rb
|
169
173
|
- spec/unit/parsing_unit_spec.rb
|
170
174
|
- spec/unit/prepopulated_unit_specs.rb
|
175
|
+
- spec/unit/row_unit_spec.rb
|
171
176
|
- spec/unit/scenario_unit_spec.rb
|
177
|
+
- spec/unit/sourceable_unit_spec.rb
|
178
|
+
- spec/unit/sourced_element_unit_specs.rb
|
172
179
|
- spec/unit/step_unit_spec.rb
|
173
180
|
- spec/unit/table_unit_spec.rb
|
174
181
|
- spec/unit/taggable_unit_spec.rb
|
@@ -216,6 +223,7 @@ test_files:
|
|
216
223
|
- features/modeling/feature_file_modeling.feature
|
217
224
|
- features/modeling/feature_modeling.feature
|
218
225
|
- features/modeling/outline_modeling.feature
|
226
|
+
- features/modeling/row_modeling.feature
|
219
227
|
- features/modeling/scenario_modeling.feature
|
220
228
|
- features/modeling/step_modeling.feature
|
221
229
|
- features/modeling/table_modeling.feature
|
@@ -235,6 +243,7 @@ test_files:
|
|
235
243
|
- features/support/transforms.rb
|
236
244
|
- spec/integration/background_integration_spec.rb
|
237
245
|
- spec/integration/directory_integration_spec.rb
|
246
|
+
- spec/integration/example_integration_spec.rb
|
238
247
|
- spec/integration/feature_file_integration_spec.rb
|
239
248
|
- spec/integration/feature_integration_spec.rb
|
240
249
|
- spec/integration/outline_integration_spec.rb
|
@@ -256,7 +265,10 @@ test_files:
|
|
256
265
|
- spec/unit/outline_unit_spec.rb
|
257
266
|
- spec/unit/parsing_unit_spec.rb
|
258
267
|
- spec/unit/prepopulated_unit_specs.rb
|
268
|
+
- spec/unit/row_unit_spec.rb
|
259
269
|
- spec/unit/scenario_unit_spec.rb
|
270
|
+
- spec/unit/sourceable_unit_spec.rb
|
271
|
+
- spec/unit/sourced_element_unit_specs.rb
|
260
272
|
- spec/unit/step_unit_spec.rb
|
261
273
|
- spec/unit/table_unit_spec.rb
|
262
274
|
- spec/unit/taggable_unit_spec.rb
|