cucumber_analytics 0.0.9 → 1.0.0
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 +15 -0
- data/History.rdoc +16 -0
- data/README.rdoc +5 -3
- data/Rakefile +7 -2
- data/cucumber_analytics.gemspec +7 -5
- data/features/analysis/step_collection.feature +44 -45
- data/features/modeling/background_modeling.feature +14 -144
- data/features/modeling/directory_modeling.feature +3 -2
- data/features/modeling/doc_string_modeling.feature +46 -0
- data/features/modeling/example_modeling.feature +13 -34
- data/features/modeling/feature_file_modeling.feature +3 -2
- data/features/modeling/feature_modeling.feature +18 -80
- data/features/modeling/outline_modeling.feature +25 -164
- data/features/modeling/scenario_modeling.feature +17 -144
- data/features/modeling/step_modeling.feature +68 -0
- data/features/modeling/table_modeling.feature +41 -0
- data/features/step_definitions/background_steps.rb +12 -11
- data/features/step_definitions/directory_steps.rb +6 -3
- data/features/step_definitions/doc_string_steps.rb +50 -0
- data/features/step_definitions/{file_steps.rb → feature_file_steps.rb} +8 -2
- data/features/step_definitions/feature_steps.rb +8 -4
- data/features/step_definitions/outline_steps.rb +12 -6
- data/features/step_definitions/setup_steps.rb +2 -2
- data/features/step_definitions/spec_steps.rb +6 -3
- data/features/step_definitions/step_steps.rb +91 -0
- data/features/step_definitions/table_steps.rb +10 -0
- data/features/step_definitions/test_steps.rb +6 -10
- data/features/step_definitions/world_steps.rb +28 -19
- data/features/support/env.rb +0 -2
- data/lib/cucumber_analytics/background.rb +16 -0
- data/lib/cucumber_analytics/containing.rb +18 -0
- data/lib/cucumber_analytics/directory.rb +83 -0
- data/lib/cucumber_analytics/doc_string.rb +55 -0
- data/lib/cucumber_analytics/example.rb +100 -0
- data/lib/cucumber_analytics/feature.rb +120 -0
- data/lib/cucumber_analytics/feature_element.rb +22 -40
- data/lib/cucumber_analytics/feature_file.rb +74 -0
- data/lib/cucumber_analytics/outline.rb +49 -0
- data/lib/cucumber_analytics/parsing.rb +30 -0
- data/lib/cucumber_analytics/scenario.rb +31 -0
- data/lib/cucumber_analytics/step.rb +142 -32
- data/lib/cucumber_analytics/table.rb +51 -0
- data/lib/cucumber_analytics/taggable.rb +35 -0
- data/lib/cucumber_analytics/test_element.rb +36 -91
- data/lib/cucumber_analytics/version.rb +1 -1
- data/lib/cucumber_analytics/world.rb +109 -153
- data/lib/cucumber_analytics.rb +12 -8
- data/spec/integration/background_integration_spec.rb +18 -0
- data/spec/integration/directory_integration_spec.rb +24 -0
- data/spec/{feature_spec.rb → integration/feature_file_integration_spec.rb} +5 -5
- data/spec/integration/feature_integration_spec.rb +86 -0
- data/spec/integration/outline_integration_spec.rb +22 -0
- data/spec/integration/scenario_integration_spec.rb +18 -0
- data/spec/integration/step_integration_spec.rb +116 -0
- data/spec/integration/world_integration_spec.rb +40 -0
- data/spec/spec_helper.rb +7 -3
- data/spec/unit/background_unit_spec.rb +22 -0
- data/spec/unit/bare_bones_unit_specs.rb +13 -0
- data/spec/unit/containing_element_unit_specs.rb +17 -0
- data/spec/unit/directory_unit_spec.rb +91 -0
- data/spec/unit/doc_string_unit_spec.rb +65 -0
- data/spec/unit/example_unit_spec.rb +171 -0
- data/spec/unit/feature_element_unit_spec.rb +19 -0
- data/spec/unit/feature_element_unit_specs.rb +39 -0
- data/spec/unit/feature_file_unit_spec.rb +82 -0
- data/spec/unit/feature_unit_spec.rb +81 -0
- data/spec/unit/nested_element_unit_specs.rb +24 -0
- data/spec/unit/outline_unit_spec.rb +56 -0
- data/spec/unit/parsing_unit_spec.rb +21 -0
- data/spec/unit/prepopulated_unit_specs.rb +13 -0
- data/spec/unit/scenario_unit_spec.rb +36 -0
- data/spec/unit/step_unit_spec.rb +231 -0
- data/spec/unit/table_unit_spec.rb +52 -0
- data/spec/unit/taggable_unit_spec.rb +63 -0
- data/spec/unit/tagged_element_unit_specs.rb +48 -0
- data/spec/unit/test_element_unit_spec.rb +40 -0
- data/spec/unit/test_element_unit_specs.rb +31 -0
- data/spec/unit/world_unit_spec.rb +167 -0
- metadata +106 -41
- data/lib/cucumber_analytics/logging.rb +0 -28
- data/lib/cucumber_analytics/outline_example.rb +0 -110
- data/lib/cucumber_analytics/parsed_background.rb +0 -45
- data/lib/cucumber_analytics/parsed_directory.rb +0 -78
- data/lib/cucumber_analytics/parsed_feature.rb +0 -97
- data/lib/cucumber_analytics/parsed_file.rb +0 -199
- data/lib/cucumber_analytics/parsed_scenario.rb +0 -67
- data/lib/cucumber_analytics/parsed_scenario_outline.rb +0 -122
- data/spec/background_spec.rb +0 -23
- data/spec/directory_spec.rb +0 -18
- data/spec/example_spec.rb +0 -37
- data/spec/file_spec.rb +0 -20
- data/spec/outline_spec.rb +0 -32
- data/spec/scenario_spec.rb +0 -33
- data/spec/step_spec.rb +0 -24
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Outline, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Outline
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a containing element', clazz
|
|
12
|
+
it_should_behave_like 'a tagged element', clazz
|
|
13
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
14
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
15
|
+
it_should_behave_like 'a test element', clazz
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
it 'can be parsed from stand alone text' do
|
|
19
|
+
source = 'Scenario Outline: '
|
|
20
|
+
|
|
21
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
before(:each) do
|
|
26
|
+
@outline = clazz.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
it 'has examples - #examples' do
|
|
31
|
+
@outline.should respond_to(:examples)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'can get and set its examples - #examples, #examples=' do
|
|
35
|
+
@outline.examples = :some_examples
|
|
36
|
+
@outline.examples.should == :some_examples
|
|
37
|
+
@outline.examples = :some_other_examples
|
|
38
|
+
@outline.examples.should == :some_other_examples
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'starts with no examples' do
|
|
42
|
+
@outline.examples.should == []
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'contains steps and examples' do
|
|
46
|
+
steps = [:step_1, :step_2, :step_3]
|
|
47
|
+
examples = [:example_1, :example_2, :example_3]
|
|
48
|
+
everything = steps + examples
|
|
49
|
+
|
|
50
|
+
@outline.steps = steps
|
|
51
|
+
@outline.examples = examples
|
|
52
|
+
|
|
53
|
+
@outline.contains.should =~ everything
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Parsing') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Parsing, Unit' do
|
|
6
|
+
|
|
7
|
+
it 'can parse text - #parse_text' do
|
|
8
|
+
CucumberAnalytics::Parsing.should respond_to(:parse_text)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'can only parse strings' do
|
|
12
|
+
expect{CucumberAnalytics::Parsing.parse_text(5)}.to raise_error(ArgumentError)
|
|
13
|
+
expect{CucumberAnalytics::Parsing.parse_text('Feature:')}.to_not raise_error
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'returns an Array' do
|
|
17
|
+
result = CucumberAnalytics::Parsing.parse_text('Feature:')
|
|
18
|
+
result.is_a?(Array).should be_true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Scenario, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Scenario
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a containing element', clazz
|
|
12
|
+
it_should_behave_like 'a tagged element', clazz
|
|
13
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
14
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
15
|
+
it_should_behave_like 'a test element', clazz
|
|
16
|
+
|
|
17
|
+
it 'can be parsed from stand alone text' do
|
|
18
|
+
source = 'Scenario: '
|
|
19
|
+
|
|
20
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
before(:each) do
|
|
24
|
+
@scenario = clazz.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'contains only steps' do
|
|
28
|
+
steps = [:step_1, :step_2]
|
|
29
|
+
everything = steps
|
|
30
|
+
|
|
31
|
+
@scenario.steps = steps
|
|
32
|
+
|
|
33
|
+
@scenario.contains.should =~ everything
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Step, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Step
|
|
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
|
+
|
|
13
|
+
|
|
14
|
+
before(:each) do
|
|
15
|
+
@step = clazz.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'has arguments - #arguments' do
|
|
19
|
+
@step.should respond_to(:arguments)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'can get and set its arguments - #arguments, #arguments=' do
|
|
23
|
+
@step.arguments = :some_arguments
|
|
24
|
+
@step.arguments.should == :some_arguments
|
|
25
|
+
@step.arguments = :some_other_arguments
|
|
26
|
+
@step.arguments.should == :some_other_arguments
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'starts with no arguments' do
|
|
30
|
+
@step.arguments.should == []
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'has a base - #base' do
|
|
34
|
+
@step.should respond_to(:base)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'can get and set its base - #base, #base=' do
|
|
38
|
+
@step.base = :some_base
|
|
39
|
+
@step.base.should == :some_base
|
|
40
|
+
@step.base = :some_other_base
|
|
41
|
+
@step.base.should == :some_other_base
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'starts with no base' do
|
|
45
|
+
@step.base.should == nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'has a block - #block' do
|
|
49
|
+
@step.should respond_to(:block)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'can get and set its block - #block, #block=' do
|
|
53
|
+
@step.block = :some_block
|
|
54
|
+
@step.block.should == :some_block
|
|
55
|
+
@step.block = :some_other_block
|
|
56
|
+
@step.block.should == :some_other_block
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'starts with no block' do
|
|
60
|
+
@step.block.should == nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'has a keyword - #keyword' do
|
|
64
|
+
@step.should respond_to(:keyword)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'can get and set its keyword - #keyword, #keyword=' do
|
|
68
|
+
@step.keyword = :some_keyword
|
|
69
|
+
@step.keyword.should == :some_keyword
|
|
70
|
+
@step.keyword = :some_other_keyword
|
|
71
|
+
@step.keyword.should == :some_other_keyword
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'starts with no keyword' do
|
|
75
|
+
@step.keyword.should == nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'has a left delimiter - #left_delimiter' do
|
|
79
|
+
@step.should respond_to(:left_delimiter)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'can get and set its left delimiter - #left_delimiter, #left_delimiter=' do
|
|
83
|
+
@step.left_delimiter = :some_left_delimiter
|
|
84
|
+
@step.left_delimiter.should == :some_left_delimiter
|
|
85
|
+
@step.left_delimiter = :some_other_left_delimiter
|
|
86
|
+
@step.left_delimiter.should == :some_other_left_delimiter
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'starts with no left delimiter' do
|
|
90
|
+
@step.left_delimiter.should == nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'has a right delimiter - #right_delimiter' do
|
|
94
|
+
@step.should respond_to(:right_delimiter)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'can get and set its right delimiter - #right_delimiter, #right_delimiter=' do
|
|
98
|
+
@step.right_delimiter = :some_right_delimiter
|
|
99
|
+
@step.right_delimiter.should == :some_right_delimiter
|
|
100
|
+
@step.right_delimiter = :some_other_right_delimiter
|
|
101
|
+
@step.right_delimiter.should == :some_other_right_delimiter
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'starts with no right delimiter' do
|
|
105
|
+
@step.right_delimiter.should == nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'can set both of its delimiters at once - #delimiter=' do
|
|
109
|
+
@step.delimiter = :new_delimiter
|
|
110
|
+
@step.left_delimiter.should == :new_delimiter
|
|
111
|
+
@step.right_delimiter.should == :new_delimiter
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
context '#scan_arguments' do
|
|
115
|
+
|
|
116
|
+
it 'can explicitly scan for arguments' do
|
|
117
|
+
@step.should respond_to(:scan_arguments)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'can determine its arguments based on a regular expression' do
|
|
121
|
+
source = 'Given a test step with a parameter'
|
|
122
|
+
step = CucumberAnalytics::Step.new(source)
|
|
123
|
+
|
|
124
|
+
step.scan_arguments(/parameter/)
|
|
125
|
+
step.arguments.should == ['parameter']
|
|
126
|
+
step.scan_arguments(/t s/)
|
|
127
|
+
step.arguments.should == ['t s']
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'can determine its arguments based on delimiters' do
|
|
131
|
+
source = 'Given a test step with -parameter 1- and -parameter 2-'
|
|
132
|
+
|
|
133
|
+
step = CucumberAnalytics::Step.new(source)
|
|
134
|
+
|
|
135
|
+
step.scan_arguments('-', '-')
|
|
136
|
+
step.arguments.should == ['parameter 1', 'parameter 2']
|
|
137
|
+
step.scan_arguments('!', '!')
|
|
138
|
+
step.arguments.should == []
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'can use different left and right delimiters when scanning' do
|
|
142
|
+
source = 'Given a test step with !a parameter-'
|
|
143
|
+
|
|
144
|
+
step = CucumberAnalytics::Step.new(source)
|
|
145
|
+
|
|
146
|
+
step.scan_arguments('!', '-')
|
|
147
|
+
step.arguments.should == ['a parameter']
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it 'can use delimiters of varying lengths' do
|
|
151
|
+
source = 'Given a test step with -start-a parameter-end-'
|
|
152
|
+
|
|
153
|
+
step = CucumberAnalytics::Step.new(source)
|
|
154
|
+
|
|
155
|
+
step.scan_arguments('-start-', '-end-')
|
|
156
|
+
step.arguments.should == ['a parameter']
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'can handle delimiters with special regular expression characters' do
|
|
160
|
+
source = 'Given a test step with \d+a parameter.?'
|
|
161
|
+
|
|
162
|
+
step = CucumberAnalytics::Step.new(source)
|
|
163
|
+
|
|
164
|
+
step.scan_arguments('\d+', '.?')
|
|
165
|
+
step.arguments.should == ['a parameter']
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'defaults to its set delimiters when scanning' do
|
|
169
|
+
source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
|
|
170
|
+
step = CucumberAnalytics::Step.new(source)
|
|
171
|
+
|
|
172
|
+
step.left_delimiter = '"'
|
|
173
|
+
step.right_delimiter = '"'
|
|
174
|
+
step.scan_arguments
|
|
175
|
+
|
|
176
|
+
step.arguments.should == ['parameter 2']
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'can be parsed from stand alone text' do
|
|
181
|
+
source = '* some step'
|
|
182
|
+
|
|
183
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
context '#step_text ' do
|
|
187
|
+
|
|
188
|
+
before(:each) do
|
|
189
|
+
source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
|
|
190
|
+
@step = CucumberAnalytics::Step.new(source)
|
|
191
|
+
@step.delimiter = '-'
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it 'can provide different flavors of step\'s text' do
|
|
195
|
+
@step.should respond_to(:step_text)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'returns different text based on options' do
|
|
199
|
+
(clazz.instance_method(:step_text).arity != 0).should be_true
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'returns the step\'s text as an Array' do
|
|
203
|
+
@step.step_text.is_a?(Array).should be_true
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'can provide the step\'s text without the arguments' do
|
|
207
|
+
expected_output = ['Given a test step with -- ^and@ *parameter 2!!']
|
|
208
|
+
|
|
209
|
+
@step.step_text(with_arguments: false).should == expected_output
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it 'can determine its arguments based on delimiters' do
|
|
213
|
+
expected_output = ['Given a test step with -parameter 1- ^@ *parameter 2!!']
|
|
214
|
+
|
|
215
|
+
@step.step_text(with_arguments: false, left_delimiter: '^', right_delimiter: '@').should == expected_output
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'can use delimiters of varying lengths' do
|
|
219
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
|
|
220
|
+
|
|
221
|
+
@step.step_text(with_arguments: false, left_delimiter: '*', right_delimiter: '!!').should == expected_output
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
it 'can handle delimiters with special regular expression characters' do
|
|
225
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
|
|
226
|
+
|
|
227
|
+
@step.step_text(with_arguments: false, left_delimiter: '*', right_delimiter: '!!').should == expected_output
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
end
|
|
231
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Table') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Table, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Table
|
|
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
|
+
|
|
13
|
+
it 'can be parsed from stand alone text' do
|
|
14
|
+
source = '| a table |'
|
|
15
|
+
|
|
16
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
before(:each) do
|
|
20
|
+
@table = clazz.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'has contents - #contents' do
|
|
24
|
+
@table.should respond_to(:contents)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'can get and set its contents - #contents, #contents=' do
|
|
28
|
+
@table.contents = :some_contents
|
|
29
|
+
@table.contents.should == :some_contents
|
|
30
|
+
@table.contents = :some_other_contents
|
|
31
|
+
@table.contents.should == :some_other_contents
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'starts with no contents' do
|
|
35
|
+
@table.contents.should == []
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'stores its contents as a nested array of strings' do
|
|
39
|
+
source = "| cell 1 | cell 2 |\n| cell 3 | cell 4 |"
|
|
40
|
+
table = CucumberAnalytics::Table.new(source)
|
|
41
|
+
|
|
42
|
+
contents = table.contents
|
|
43
|
+
|
|
44
|
+
contents.is_a?(Array).should be_true
|
|
45
|
+
|
|
46
|
+
contents.each do |row|
|
|
47
|
+
row.is_a?(Array).should be_true
|
|
48
|
+
row.each { |cell| cell.is_a?(String).should be_true }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Taggable') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Taggable, Unit' do
|
|
6
|
+
|
|
7
|
+
nodule = CucumberAnalytics::Taggable
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
@element = Object.new.extend(nodule)
|
|
11
|
+
|
|
12
|
+
def @element.parent_element
|
|
13
|
+
@parent_element
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def @element.parent_element=(parent)
|
|
17
|
+
@parent_element = parent
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
it 'has tags - #tags' do
|
|
23
|
+
@element.should respond_to(:tags)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'can get and set its tags - #tags, #tags=' do
|
|
27
|
+
@element.tags = :some_tags
|
|
28
|
+
@element.tags.should == :some_tags
|
|
29
|
+
@element.tags = :some_other_tags
|
|
30
|
+
@element.tags.should == :some_other_tags
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'has applied tags - #applied_tags' do
|
|
34
|
+
@element.should respond_to(:applied_tags)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'inherits its applied tags from its ancestors - #applied_tags' do
|
|
38
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
39
|
+
parent = double(:all_tags => all_parent_tags)
|
|
40
|
+
|
|
41
|
+
@element.parent_element = parent
|
|
42
|
+
|
|
43
|
+
@element.applied_tags.should == all_parent_tags
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'knows all of its applicable tags - #all_tags' do
|
|
47
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
48
|
+
own_tags = ['@tag_1', '@tag_2']
|
|
49
|
+
parent = double(:all_tags => all_parent_tags)
|
|
50
|
+
|
|
51
|
+
@element.parent_element = parent
|
|
52
|
+
@element.tags = own_tags
|
|
53
|
+
|
|
54
|
+
@element.all_tags.should == all_parent_tags + own_tags
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'may have no applied tags' do
|
|
58
|
+
@element.parent_element = :not_a_tagged_object
|
|
59
|
+
|
|
60
|
+
@element.applied_tags.should == []
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a tagged element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has tags - #tags' do
|
|
10
|
+
@element.should respond_to(:tags)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can get and set its tags - #tags, #tags=' do
|
|
14
|
+
@element.tags = :some_tags
|
|
15
|
+
@element.tags.should == :some_tags
|
|
16
|
+
@element.tags = :some_other_tags
|
|
17
|
+
@element.tags.should == :some_other_tags
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'starts with no tags' do
|
|
21
|
+
@element.tags.should == []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'has applied tags - #applied_tags' do
|
|
25
|
+
@element.should respond_to(:applied_tags)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'inherits its applied tags from its ancestors - #applied_tags' do
|
|
29
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
30
|
+
parent = double(:all_tags => all_parent_tags)
|
|
31
|
+
|
|
32
|
+
@element.parent_element = parent
|
|
33
|
+
|
|
34
|
+
@element.applied_tags.should == all_parent_tags
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'knows all of its applicable tags - #all_tags' do
|
|
38
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
39
|
+
own_tags = ['@tag_1', '@tag_2']
|
|
40
|
+
parent = double(:all_tags => all_parent_tags)
|
|
41
|
+
|
|
42
|
+
@element.parent_element = parent
|
|
43
|
+
@element.tags = own_tags
|
|
44
|
+
|
|
45
|
+
@element.all_tags.should == all_parent_tags + own_tags
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('TestElement') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'TestElement, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::TestElement
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a test element', clazz
|
|
10
|
+
it_should_behave_like 'a feature element', clazz
|
|
11
|
+
it_should_behave_like 'a nested element', clazz
|
|
12
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
13
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
before(:each) do
|
|
17
|
+
@element = clazz.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'contains only steps - #contains' do
|
|
21
|
+
steps = [:step_1, :step_2, :step_3]
|
|
22
|
+
@element.steps = steps
|
|
23
|
+
|
|
24
|
+
@element.contains.should =~ steps
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'can determine its equality with another TestElement - #==' do
|
|
28
|
+
element_1 = clazz.new
|
|
29
|
+
element_2 = clazz.new
|
|
30
|
+
element_3 = clazz.new
|
|
31
|
+
|
|
32
|
+
element_1.steps = :some_steps
|
|
33
|
+
element_2.steps = :some_steps
|
|
34
|
+
element_3.steps = :some_other_steps
|
|
35
|
+
|
|
36
|
+
(element_1 == element_2).should be_true
|
|
37
|
+
(element_1 == element_3).should be_false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a test element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has steps - #steps' do
|
|
10
|
+
@element.should respond_to(:steps)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can get and set its steps - #steps, #steps=' do
|
|
14
|
+
@element.steps = :some_steps
|
|
15
|
+
@element.steps.should == :some_steps
|
|
16
|
+
@element.steps = :some_other_steps
|
|
17
|
+
@element.steps.should == :some_other_steps
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'starts with no steps' do
|
|
21
|
+
@element.steps.should == []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'contains steps - #contains' do
|
|
25
|
+
steps = [:step_1, :step_2, :step_3]
|
|
26
|
+
@element.steps = steps
|
|
27
|
+
|
|
28
|
+
steps.each { |step| @element.contains.should include(step) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|