cucumber_analytics 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -3,25 +3,23 @@ Then /^the(?: feature "([^"]*)")? background is found to have the following prop
|
|
3
3
|
properties = properties.rows_hash
|
4
4
|
|
5
5
|
properties.each do |property, expected_value|
|
6
|
-
|
6
|
+
expected = expected_value
|
7
|
+
actual = @parsed_files[file - 1].feature.background.send(property.to_sym).to_s
|
8
|
+
|
9
|
+
actual.should == expected
|
7
10
|
end
|
8
11
|
end
|
9
12
|
|
10
13
|
Then /^the(?: feature "([^"]*)")? background's descriptive lines are as follows:$/ do |file, lines|
|
11
14
|
file ||= 1
|
12
15
|
expected_description = lines.raw.flatten
|
16
|
+
actual_description = @parsed_files[file - 1].feature.background.description
|
13
17
|
|
14
|
-
|
18
|
+
actual_description.should == expected_description
|
15
19
|
end
|
16
20
|
|
17
|
-
Then /^the(?: feature "([^"]*)")? background's steps
|
21
|
+
Then /^the(?: feature "([^"]*)")? background's steps are as follows:$/ do |file, steps|
|
18
22
|
file ||= 1
|
19
|
-
arguments ||= 'with'
|
20
|
-
keywords ||= 'with'
|
21
|
-
translate = {'with' => true,
|
22
|
-
'without' => false}
|
23
|
-
|
24
|
-
options = {:with_keywords => translate[keywords], :with_arguments => translate[arguments]}
|
25
23
|
|
26
24
|
steps = steps.raw.flatten.collect do |step|
|
27
25
|
if step.start_with? "'"
|
@@ -33,11 +31,14 @@ Then /^the(?: feature "([^"]*)")? background's steps(?: "([^"]*)" arguments)?(?:
|
|
33
31
|
|
34
32
|
actual_steps = Array.new.tap do |steps|
|
35
33
|
@parsed_files[file - 1].feature.background.steps.each do |step|
|
36
|
-
steps << step.
|
34
|
+
steps << step.base
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
|
38
|
+
expected = steps
|
39
|
+
actual = actual_steps.flatten
|
40
|
+
|
41
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
41
42
|
end
|
42
43
|
|
43
44
|
When /^step "([^"]*)" of the background (?:of feature "([^"]*)" )?has the following block:$/ do |step, file, block|
|
@@ -7,7 +7,10 @@ Then /^(?:the )?directory(?: "([^"]*)")? is found to have the following properti
|
|
7
7
|
expected_value.sub!('path_to', @default_file_directory)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
expected = expected_value
|
11
|
+
actual = @parsed_directories[directory - 1].send(property.to_sym).to_s
|
12
|
+
|
13
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
@@ -23,7 +26,7 @@ When /^(?:the )?directory(?: "([^"]*)")? directories are as follows:$/ do |direc
|
|
23
26
|
directory ||= 1
|
24
27
|
|
25
28
|
expected = directories.raw.flatten.sort
|
26
|
-
actual = @parsed_directories[directory - 1].
|
29
|
+
actual = @parsed_directories[directory - 1].directories.collect { |sub_directory| sub_directory.name }
|
27
30
|
|
28
31
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
29
32
|
end
|
@@ -32,7 +35,7 @@ When /^(?:the )?directory(?: "([^"]*)")? has no directories$/ do |directory|
|
|
32
35
|
directory ||= 1
|
33
36
|
|
34
37
|
expected = []
|
35
|
-
actual = @parsed_directories[directory - 1].
|
38
|
+
actual = @parsed_directories[directory - 1].directories
|
36
39
|
|
37
40
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
38
41
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string content type is "([^"]*)"$/ do |file, test, step, type|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
step ||= 1
|
5
|
+
|
6
|
+
expected = type
|
7
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.content_type
|
8
|
+
|
9
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string has no content type$/ do |file, test, step|
|
13
|
+
file ||= 1
|
14
|
+
test ||= 1
|
15
|
+
step ||= 1
|
16
|
+
|
17
|
+
expected = nil
|
18
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.content_type
|
19
|
+
|
20
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string has the following contents:$/ do |file, test, step, contents|
|
24
|
+
file ||= 1
|
25
|
+
test ||= 1
|
26
|
+
step ||= 1
|
27
|
+
|
28
|
+
expected = contents.raw.flatten.collect do |cell_value|
|
29
|
+
if cell_value.start_with? "'"
|
30
|
+
cell_value.slice(1..cell_value.length - 2)
|
31
|
+
else
|
32
|
+
cell_value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents
|
37
|
+
|
38
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string contents are empty$/ do |file, test, step|
|
42
|
+
file ||= 1
|
43
|
+
test ||= 1
|
44
|
+
step ||= 1
|
45
|
+
|
46
|
+
expected = []
|
47
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents
|
48
|
+
|
49
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
50
|
+
end
|
@@ -7,14 +7,20 @@ Then /^(?:the )?file(?: "([^"]*)")? is found to have the following properties:$/
|
|
7
7
|
expected_value.sub!('path_to', @test_directory)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
expected = expected_value
|
11
|
+
actual = @parsed_files[file - 1].send(property.to_sym).to_s
|
12
|
+
|
13
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
17
|
When /^(?:the )?file(?: "([^"]*)")? features are as follows:$/ do |file, feature|
|
15
18
|
file ||= 1
|
16
19
|
|
17
|
-
|
20
|
+
expected = feature.raw.flatten.first
|
21
|
+
actual = @parsed_files[file - 1].feature.name
|
22
|
+
|
23
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
18
24
|
end
|
19
25
|
|
20
26
|
When /^(?:the )?file(?: "([^"]*)")? has no features$/ do |file|
|
@@ -18,9 +18,10 @@ Then /^the descriptive lines of feature "([^"]*)" are as follows:$/ do |file, li
|
|
18
18
|
end
|
19
19
|
|
20
20
|
Then /^feature "([^"]*)" is found to have the following tags:$/ do |file, tags|
|
21
|
-
|
21
|
+
expected = tags.raw.flatten
|
22
|
+
actual = @parsed_files[file - 1].feature.tags
|
22
23
|
|
23
|
-
assert
|
24
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
24
25
|
end
|
25
26
|
|
26
27
|
Then /^feature "([^"]*)" has no descriptive lines$/ do |file|
|
@@ -44,13 +45,16 @@ When /^(?:the )?feature(?: "([^"]*)")? outlines are as follows:$/ do |file, outl
|
|
44
45
|
|
45
46
|
actual_outlines = @parsed_files[file - 1].feature.outlines.collect { |outline| outline.name }
|
46
47
|
|
47
|
-
|
48
|
+
expected = outlines.raw.flatten.sort
|
49
|
+
actual = actual_outlines.flatten.sort
|
50
|
+
|
51
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
48
52
|
end
|
49
53
|
|
50
54
|
When /^(?:the )?feature(?: "([^"]*)")? background is as follows:$/ do |file, background|
|
51
55
|
file ||= 1
|
52
56
|
|
53
|
-
|
57
|
+
@parsed_files[file - 1].feature.background.name.should == background.raw.flatten.first
|
54
58
|
end
|
55
59
|
|
56
60
|
When /^feature "([^"]*)" has no scenarios$/ do |file|
|
@@ -2,9 +2,10 @@ When /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example blocks are as
|
|
2
2
|
file ||= 1
|
3
3
|
test ||= 1
|
4
4
|
|
5
|
-
|
5
|
+
expected = names.raw.flatten
|
6
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples.collect { |example| example.name }
|
6
7
|
|
7
|
-
assert
|
8
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
8
9
|
end
|
9
10
|
|
10
11
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, example, properties|
|
@@ -34,9 +35,11 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
34
35
|
test ||= 1
|
35
36
|
example ||= 1
|
36
37
|
|
37
|
-
tags = tags.raw.flatten
|
38
38
|
|
39
|
-
|
39
|
+
expected = tags.raw.flatten
|
40
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tags
|
41
|
+
|
42
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
40
43
|
end
|
41
44
|
|
42
45
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? is found to have the following applied tags:$/ do |file, test, example, tags|
|
@@ -57,7 +60,10 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
57
60
|
test ||= 1
|
58
61
|
example ||= 1
|
59
62
|
|
60
|
-
|
63
|
+
expected = []
|
64
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tags
|
65
|
+
|
66
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
61
67
|
end
|
62
68
|
|
63
69
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? rows are as follows:$/ do |file, test, example, rows|
|
@@ -108,7 +114,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^
|
|
108
114
|
parameters = parameters.raw.flatten
|
109
115
|
|
110
116
|
expected = parameters
|
111
|
-
actual
|
117
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].parameters
|
112
118
|
|
113
119
|
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
114
120
|
end
|
@@ -12,7 +12,7 @@ When /^the file(?: "([^"]*)")? is read$/ do |file_name|
|
|
12
12
|
@test_directory ||= @default_file_directory
|
13
13
|
file_name ||= @default_feature_file_name
|
14
14
|
|
15
|
-
@parsed_files << CucumberAnalytics::
|
15
|
+
@parsed_files << CucumberAnalytics::FeatureFile.new("#{@test_directory}/#{file_name}")
|
16
16
|
end
|
17
17
|
|
18
18
|
When /^the step definition file "([^"]*)" is read$/ do |file_name|
|
@@ -37,7 +37,7 @@ When /^the directory(?: "([^"]*)")? is read$/ do |directory_name|
|
|
37
37
|
@parsed_directories ||= []
|
38
38
|
@test_directory = "#{@default_file_directory}/#{directory_name}" if directory_name
|
39
39
|
|
40
|
-
@parsed_directories << CucumberAnalytics::
|
40
|
+
@parsed_directories << CucumberAnalytics::Directory.new(@test_directory)
|
41
41
|
end
|
42
42
|
|
43
43
|
When /^the following step definition file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
@@ -1,15 +1,18 @@
|
|
1
1
|
Given /^that there are "([^"]*)" detailing models$/ do |spec_file|
|
2
|
-
|
2
|
+
sub_directory = spec_file =~ /integration/ ? 'integration' : 'unit'
|
3
|
+
spec_file = "#{SPEC_DIRECTORY}/#{sub_directory}/#{spec_file}"
|
4
|
+
|
5
|
+
fail "The spec file does not exist: #{spec_file}" unless File.exists?(spec_file)
|
3
6
|
|
4
7
|
@spec_file = spec_file
|
5
8
|
end
|
6
9
|
|
7
10
|
When /^the corresponding unit tests are run$/ do
|
8
|
-
command = "rspec
|
11
|
+
command = "rspec #{@spec_file}"
|
9
12
|
|
10
13
|
@specs_passed = system(command)
|
11
14
|
end
|
12
15
|
|
13
16
|
Then /^all of those specifications are met$/ do
|
14
|
-
fail "There were unmet specifications." unless @specs_passed
|
17
|
+
fail "There were unmet specifications in '#{@spec_file}'." unless @specs_passed
|
15
18
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? keyword is "([^"]*)"$/ do |file, test, step, keyword|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
step ||= 1
|
5
|
+
|
6
|
+
expected = keyword
|
7
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].keyword
|
8
|
+
|
9
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has the following block:$/ do |file, test, step, block|
|
13
|
+
file ||= 1
|
14
|
+
test ||= 1
|
15
|
+
step ||= 1
|
16
|
+
|
17
|
+
expected = block.raw.flatten.collect do |cell_value|
|
18
|
+
if cell_value.start_with? "'"
|
19
|
+
cell_value.slice(1..cell_value.length - 2)
|
20
|
+
else
|
21
|
+
cell_value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.flatten
|
26
|
+
|
27
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has no block$/ do |file, test, step|
|
31
|
+
file ||= 1
|
32
|
+
test ||= 1
|
33
|
+
step ||= 1
|
34
|
+
|
35
|
+
expected = nil
|
36
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block
|
37
|
+
|
38
|
+
actual.should == expected
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? text is "([^"]*)"$/ do |file, test, step, text|
|
42
|
+
file ||= 1
|
43
|
+
test ||= 1
|
44
|
+
step ||= 1
|
45
|
+
|
46
|
+
expected = text
|
47
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].base
|
48
|
+
|
49
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? arguments are:$/ do |file, test, step, arguments|
|
53
|
+
file ||= 1
|
54
|
+
test ||= 1
|
55
|
+
step ||= 1
|
56
|
+
|
57
|
+
expected = arguments.raw.flatten
|
58
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
59
|
+
|
60
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? has no arguments$/ do |file, test, step|
|
64
|
+
file ||= 1
|
65
|
+
test ||= 1
|
66
|
+
step ||= 1
|
67
|
+
|
68
|
+
expected = []
|
69
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
70
|
+
|
71
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has a "([^"]*)"$/ do |file, test, step, type|
|
75
|
+
file ||= 1
|
76
|
+
test ||= 1
|
77
|
+
step ||= 1
|
78
|
+
|
79
|
+
case type
|
80
|
+
when 'doc string'
|
81
|
+
expected = CucumberAnalytics::DocString
|
82
|
+
when 'table'
|
83
|
+
expected = CucumberAnalytics::Table
|
84
|
+
else
|
85
|
+
raise(ArgumentError, "Unknown block type: #{type}")
|
86
|
+
end
|
87
|
+
|
88
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.class
|
89
|
+
|
90
|
+
actual.should == expected
|
91
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?table has the following contents:$/ do |file, test, step, contents|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
step ||= 1
|
5
|
+
|
6
|
+
expected = contents.raw
|
7
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents
|
8
|
+
|
9
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
10
|
+
end
|
@@ -17,16 +17,9 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? descriptive lines are
|
|
17
17
|
assert @parsed_files[file - 1].feature.tests[test - 1].description == lines
|
18
18
|
end
|
19
19
|
|
20
|
-
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps
|
20
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps are as follows:$/ do |file, test, steps|
|
21
21
|
file ||= 1
|
22
22
|
test ||= 1
|
23
|
-
arguments ||= 'with'
|
24
|
-
keywords ||= 'with'
|
25
|
-
translate = {'with' => true,
|
26
|
-
'without' => false}
|
27
|
-
|
28
|
-
options = {:with_keywords => translate[keywords], :with_arguments => translate[arguments]}
|
29
|
-
|
30
23
|
|
31
24
|
steps = steps.raw.flatten.collect do |step|
|
32
25
|
if step.start_with? "'"
|
@@ -38,7 +31,7 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps(?: "([^"]*)" ar
|
|
38
31
|
|
39
32
|
actual_steps = Array.new.tap do |steps|
|
40
33
|
@parsed_files[file - 1].feature.tests[test - 1].steps.each do |step|
|
41
|
-
steps << step.
|
34
|
+
steps << step.base
|
42
35
|
end
|
43
36
|
end
|
44
37
|
|
@@ -84,7 +77,10 @@ Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is equal to test "([^
|
|
84
77
|
file ||= 1
|
85
78
|
first_test ||= 1
|
86
79
|
|
87
|
-
|
80
|
+
expected = true
|
81
|
+
actual = @parsed_files[file - 1].feature.tests[first_test - 1] == @parsed_files[file - 1].feature.tests[second_test - 1]
|
82
|
+
|
83
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
88
84
|
end
|
89
85
|
|
90
86
|
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is not equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
@@ -39,7 +39,7 @@ Then /^the(?: "([^"]*)")? steps collected from feature "([^"]*)" background are
|
|
39
39
|
expected_steps = CucumberAnalytics::World.steps_in(container)
|
40
40
|
end
|
41
41
|
|
42
|
-
assert expected_steps.collect { |step| step.
|
42
|
+
assert expected_steps.collect { |step| step.base }.flatten.sort == steps.sort
|
43
43
|
end
|
44
44
|
|
45
45
|
Then /^the(?: "([^"]*)")? steps collected from feature "([^"]*)" test "([^"]*)" are as follows:$/ do |defined, file, test, steps|
|
@@ -56,57 +56,63 @@ Then /^the(?: "([^"]*)")? steps collected from feature "([^"]*)" test "([^"]*)"
|
|
56
56
|
expected_steps = CucumberAnalytics::World.steps_in(container)
|
57
57
|
end
|
58
58
|
|
59
|
-
assert expected_steps.collect { |step| step.
|
59
|
+
assert expected_steps.collect { |step| step.base }.flatten.sort == steps.sort
|
60
60
|
end
|
61
61
|
|
62
62
|
When /^the(?: "([^"]*)")? steps collected from (?:the )?feature(?: "([^"]*)")? are as follows:$/ do |defined, file, steps|
|
63
63
|
file ||= 1
|
64
|
-
steps = steps.raw.flatten
|
65
64
|
container = @parsed_files[file - 1].feature
|
66
65
|
|
67
66
|
case defined
|
68
67
|
when 'defined'
|
69
|
-
|
68
|
+
actual_steps = CucumberAnalytics::World.defined_steps_in(container)
|
70
69
|
when 'undefined'
|
71
|
-
|
70
|
+
actual_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
72
71
|
else
|
73
|
-
|
72
|
+
actual_steps = CucumberAnalytics::World.steps_in(container)
|
74
73
|
end
|
75
74
|
|
76
|
-
|
75
|
+
expected = steps.raw.flatten.sort
|
76
|
+
actual = actual_steps.collect { |step| step.base }.flatten.sort
|
77
|
+
|
78
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
77
79
|
end
|
78
80
|
|
79
81
|
When /^the(?: "([^"]*)")? steps collected from (?:the )?file(?: "([^"]*)")? are as follows:$/ do |defined, file, steps|
|
80
82
|
file ||= 1
|
81
|
-
steps = steps.raw.flatten
|
82
83
|
container = @parsed_files[file - 1]
|
83
84
|
|
84
85
|
case defined
|
85
86
|
when 'defined'
|
86
|
-
|
87
|
+
actual_steps = CucumberAnalytics::World.defined_steps_in(container)
|
87
88
|
when 'undefined'
|
88
|
-
|
89
|
+
actual_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
89
90
|
else
|
90
|
-
|
91
|
+
actual_steps = CucumberAnalytics::World.steps_in(container)
|
91
92
|
end
|
92
93
|
|
93
|
-
|
94
|
+
expected = steps.raw.flatten.sort
|
95
|
+
actual = actual_steps.collect { |step| step.base }.flatten.sort
|
96
|
+
|
97
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
94
98
|
end
|
95
99
|
|
96
100
|
When /^the(?: "([^"]*)")? steps collected from the directory are as follows:$/ do |defined, steps|
|
97
|
-
steps = steps.raw.flatten
|
98
101
|
container = @parsed_directories.last
|
99
102
|
|
100
103
|
case defined
|
101
104
|
when 'defined'
|
102
|
-
|
105
|
+
actual_steps = CucumberAnalytics::World.defined_steps_in(container)
|
103
106
|
when 'undefined'
|
104
|
-
|
107
|
+
actual_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
105
108
|
else
|
106
|
-
|
109
|
+
actual_steps = CucumberAnalytics::World.steps_in(container)
|
107
110
|
end
|
108
111
|
|
109
|
-
|
112
|
+
expected = steps.raw.flatten.sort
|
113
|
+
actual = actual_steps.collect { |step| step.base }.flatten.sort
|
114
|
+
|
115
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
110
116
|
end
|
111
117
|
|
112
118
|
Then /^the tests collected from feature "([^"]*)" are as follows:$/ do |file, tests|
|
@@ -153,9 +159,12 @@ end
|
|
153
159
|
Then /^the files collected from directory "([^"]*)" are as follows:$/ do |directory, files|
|
154
160
|
directory ||= 1
|
155
161
|
|
156
|
-
actual_files = CucumberAnalytics::World.
|
162
|
+
actual_files = CucumberAnalytics::World.feature_files_in(@parsed_directories[directory - 1]).collect { |file| file.name }
|
157
163
|
|
158
|
-
|
164
|
+
expected = files.raw.flatten.sort
|
165
|
+
actual = actual_files.flatten.sort
|
166
|
+
|
167
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
159
168
|
end
|
160
169
|
|
161
170
|
Then /^the directories collected from directory "([^"]*)" are as follows:$/ do |directory, directories|
|
data/features/support/env.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module CucumberAnalytics
|
2
|
+
|
3
|
+
# A class modeling a Cucumber feature's Background.
|
4
|
+
|
5
|
+
class Background < TestElement
|
6
|
+
|
7
|
+
# Creates a new Background object and, if *source* is provided, populates
|
8
|
+
# the object.
|
9
|
+
def initialize(source = nil)
|
10
|
+
parsed_background = process_source(source)
|
11
|
+
|
12
|
+
super(parsed_background)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module CucumberAnalytics
|
2
|
+
|
3
|
+
# A class modeling a directory containing .feature files.
|
4
|
+
|
5
|
+
class Directory
|
6
|
+
|
7
|
+
include Containing
|
8
|
+
|
9
|
+
|
10
|
+
# The FeatureFile objects contained by the Directory
|
11
|
+
attr_accessor :feature_files
|
12
|
+
|
13
|
+
# The Directory objects contained by the Directory
|
14
|
+
attr_accessor :directories
|
15
|
+
|
16
|
+
# The parent object that contains *self*
|
17
|
+
attr_accessor :parent_element
|
18
|
+
|
19
|
+
|
20
|
+
# Creates a new Directory object and, if *directory_parsed* is provided,
|
21
|
+
# populates the object.
|
22
|
+
def initialize(directory_parsed = nil)
|
23
|
+
@directory = directory_parsed
|
24
|
+
|
25
|
+
@feature_files = []
|
26
|
+
@directories = []
|
27
|
+
|
28
|
+
if directory_parsed
|
29
|
+
raise(ArgumentError, "Unknown directory: #{directory_parsed.inspect}") unless File.exists?(directory_parsed)
|
30
|
+
build_directory
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the name of the directory.
|
35
|
+
def name
|
36
|
+
File.basename(@directory.gsub('\\', '/'))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the path of the directory.
|
40
|
+
def path
|
41
|
+
@directory
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the number of sub-directories contained in the directory.
|
45
|
+
def directory_count
|
46
|
+
@directories.count
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the number of features files contained in the directory.
|
50
|
+
def feature_file_count
|
51
|
+
@feature_files.count
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the immediate child elements of the directory (i.e. its Directory
|
55
|
+
# and FeatureFile objects).
|
56
|
+
def contains
|
57
|
+
@feature_files + @directories
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
|
64
|
+
def build_directory
|
65
|
+
entries = Dir.entries(@directory)
|
66
|
+
entries.delete '.'
|
67
|
+
entries.delete '..'
|
68
|
+
|
69
|
+
entries.each do |entry|
|
70
|
+
entry = "#{@directory}/#{entry}"
|
71
|
+
|
72
|
+
case
|
73
|
+
when File.directory?(entry)
|
74
|
+
@directories << build_child_element(Directory, entry)
|
75
|
+
when entry =~ /\.feature$/
|
76
|
+
@feature_files << build_child_element(FeatureFile, entry)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|