cuke_modeler 0.0.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 +7 -0
- data/.gitignore +17 -0
- data/.simplecov +8 -0
- data/Gemfile +4 -0
- data/History.rdoc +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +38 -0
- data/cuke_modeler.gemspec +29 -0
- data/features/analysis/test_comparison.feature +123 -0
- data/features/analysis/test_manipulation.feature +37 -0
- data/features/modeling/background_modeling.feature +75 -0
- data/features/modeling/background_output.feature +130 -0
- data/features/modeling/directory_modeling.feature +120 -0
- data/features/modeling/directory_output.feature +13 -0
- data/features/modeling/doc_string_modeling.feature +63 -0
- data/features/modeling/doc_string_output.feature +71 -0
- data/features/modeling/example_modeling.feature +111 -0
- data/features/modeling/example_output.feature +192 -0
- data/features/modeling/feature_file_modeling.feature +64 -0
- data/features/modeling/feature_file_output.feature +13 -0
- data/features/modeling/feature_modeling.feature +164 -0
- data/features/modeling/feature_output.feature +244 -0
- data/features/modeling/outline_modeling.feature +100 -0
- data/features/modeling/outline_output.feature +197 -0
- data/features/modeling/row_modeling.feature +77 -0
- data/features/modeling/row_output.feature +27 -0
- data/features/modeling/scenario_modeling.feature +89 -0
- data/features/modeling/scenario_output.feature +147 -0
- data/features/modeling/step_modeling.feature +85 -0
- data/features/modeling/step_output.feature +52 -0
- data/features/modeling/table_modeling.feature +52 -0
- data/features/modeling/table_output.feature +42 -0
- data/features/modeling/table_row_modeling.feature +67 -0
- data/features/modeling/table_row_output.feature +27 -0
- data/features/modeling/tag_modeling.feature +58 -0
- data/features/modeling/tag_output.feature +16 -0
- data/features/step_definitions/action_steps.rb +3 -0
- data/features/step_definitions/background_steps.rb +81 -0
- data/features/step_definitions/directory_steps.rb +52 -0
- data/features/step_definitions/doc_string_steps.rb +63 -0
- data/features/step_definitions/feature_file_steps.rb +41 -0
- data/features/step_definitions/feature_steps.rb +96 -0
- data/features/step_definitions/outline_steps.rb +252 -0
- data/features/step_definitions/setup_steps.rb +50 -0
- data/features/step_definitions/spec_steps.rb +18 -0
- data/features/step_definitions/step_steps.rb +159 -0
- data/features/step_definitions/table_steps.rb +54 -0
- data/features/step_definitions/tag_steps.rb +61 -0
- data/features/step_definitions/test_steps.rb +114 -0
- data/features/step_definitions/verification_steps.rb +9 -0
- data/features/support/env.rb +27 -0
- data/features/support/transforms.rb +3 -0
- data/lib/cuke_modeler.rb +29 -0
- data/lib/cuke_modeler/background.rb +38 -0
- data/lib/cuke_modeler/containing.rb +18 -0
- data/lib/cuke_modeler/directory.rb +86 -0
- data/lib/cuke_modeler/doc_string.rb +87 -0
- data/lib/cuke_modeler/example.rb +184 -0
- data/lib/cuke_modeler/feature.rb +147 -0
- data/lib/cuke_modeler/feature_element.rb +73 -0
- data/lib/cuke_modeler/feature_file.rb +77 -0
- data/lib/cuke_modeler/nested.rb +34 -0
- data/lib/cuke_modeler/outline.rb +68 -0
- data/lib/cuke_modeler/parsing.rb +32 -0
- data/lib/cuke_modeler/raw.rb +20 -0
- data/lib/cuke_modeler/row.rb +64 -0
- data/lib/cuke_modeler/scenario.rb +45 -0
- data/lib/cuke_modeler/sourceable.rb +20 -0
- data/lib/cuke_modeler/step.rb +214 -0
- data/lib/cuke_modeler/table.rb +90 -0
- data/lib/cuke_modeler/table_row.rb +64 -0
- data/lib/cuke_modeler/tag.rb +62 -0
- data/lib/cuke_modeler/taggable.rb +54 -0
- data/lib/cuke_modeler/test_element.rb +77 -0
- data/lib/cuke_modeler/version.rb +3 -0
- data/lib/cuke_modeler/world.rb +113 -0
- data/spec/integration/background_integration_spec.rb +72 -0
- data/spec/integration/directory_integration_spec.rb +48 -0
- data/spec/integration/doc_string_integration_spec.rb +66 -0
- data/spec/integration/example_integration_spec.rb +94 -0
- data/spec/integration/feature_file_integration_spec.rb +44 -0
- data/spec/integration/feature_integration_spec.rb +152 -0
- data/spec/integration/outline_integration_spec.rb +92 -0
- data/spec/integration/scenario_integration_spec.rb +80 -0
- data/spec/integration/step_integration_spec.rb +184 -0
- data/spec/integration/table_integration_spec.rb +86 -0
- data/spec/integration/table_row_integration_spec.rb +68 -0
- data/spec/integration/tag_integration_spec.rb +67 -0
- data/spec/integration/world_integration_spec.rb +13 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/unit/background_unit_spec.rb +55 -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 +103 -0
- data/spec/unit/doc_string_unit_spec.rb +109 -0
- data/spec/unit/example_unit_spec.rb +251 -0
- data/spec/unit/feature_element_unit_spec.rb +19 -0
- data/spec/unit/feature_element_unit_specs.rb +46 -0
- data/spec/unit/feature_file_unit_spec.rb +94 -0
- data/spec/unit/feature_unit_spec.rb +135 -0
- data/spec/unit/nested_element_unit_specs.rb +36 -0
- data/spec/unit/nested_unit_spec.rb +37 -0
- data/spec/unit/outline_unit_spec.rb +91 -0
- data/spec/unit/parsing_unit_spec.rb +21 -0
- data/spec/unit/prepopulated_unit_specs.rb +13 -0
- data/spec/unit/raw_element_unit_specs.rb +24 -0
- data/spec/unit/raw_unit_spec.rb +25 -0
- data/spec/unit/row_unit_spec.rb +55 -0
- data/spec/unit/scenario_unit_spec.rb +71 -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 +259 -0
- data/spec/unit/table_row_unit_spec.rb +55 -0
- data/spec/unit/table_unit_spec.rb +96 -0
- data/spec/unit/tag_unit_spec.rb +51 -0
- data/spec/unit/taggable_unit_spec.rb +78 -0
- data/spec/unit/tagged_element_unit_specs.rb +63 -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 +130 -0
- metadata +364 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Feature: Outputting table row elements
|
|
2
|
+
|
|
3
|
+
The output of an element model is a representation of the element as it would
|
|
4
|
+
appear in gherkin.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Scenario: Output of a table row that has one cell
|
|
8
|
+
Given a table row element based on the following gherkin:
|
|
9
|
+
"""
|
|
10
|
+
|value|
|
|
11
|
+
"""
|
|
12
|
+
When it is outputted
|
|
13
|
+
Then the following text is provided:
|
|
14
|
+
"""
|
|
15
|
+
| value |
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
Scenario: Output of a table row that has multiple cells
|
|
19
|
+
Given a table row element based on the following gherkin:
|
|
20
|
+
"""
|
|
21
|
+
|value|another_value|
|
|
22
|
+
"""
|
|
23
|
+
When it is outputted
|
|
24
|
+
Then the following text is provided:
|
|
25
|
+
"""
|
|
26
|
+
| value | another_value |
|
|
27
|
+
"""
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Feature: Tag elements can be modeled.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Acceptance criteria
|
|
5
|
+
|
|
6
|
+
1. All conceptual pieces of a tag can be modeled:
|
|
7
|
+
- the tag's name
|
|
8
|
+
- the tags's source line
|
|
9
|
+
- the tags's raw element
|
|
10
|
+
|
|
11
|
+
2. Features can be outputted in a convenient form
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Background: Test file setup.
|
|
15
|
+
Given the following feature file:
|
|
16
|
+
"""
|
|
17
|
+
@feature_tag
|
|
18
|
+
Feature:
|
|
19
|
+
|
|
20
|
+
@outline_tag
|
|
21
|
+
Scenario Outline:
|
|
22
|
+
* a step
|
|
23
|
+
|
|
24
|
+
@example_tag
|
|
25
|
+
Examples:
|
|
26
|
+
| a param |
|
|
27
|
+
"""
|
|
28
|
+
When the file is read
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Scenario: The raw tag element is modeled.
|
|
32
|
+
Then the feature tag correctly stores its underlying implementation
|
|
33
|
+
And the test tag correctly stores its underlying implementation
|
|
34
|
+
And the example tag correctly stores its underlying implementation
|
|
35
|
+
|
|
36
|
+
Scenario: The tag's source line is modeled.
|
|
37
|
+
Then the feature tag source line "1"
|
|
38
|
+
And the test tag source line "4"
|
|
39
|
+
And the example tag source line "8"
|
|
40
|
+
|
|
41
|
+
Scenario: The tag name is modeled.
|
|
42
|
+
Then the feature tag name is "@feature_tag"
|
|
43
|
+
And the test tag name is "@outline_tag"
|
|
44
|
+
And the example tag name is "@example_tag"
|
|
45
|
+
|
|
46
|
+
Scenario: Convenient output of a tag
|
|
47
|
+
Then the tag has convenient output
|
|
48
|
+
|
|
49
|
+
@redundant
|
|
50
|
+
Scenario Outline: Tag models pass all other specifications
|
|
51
|
+
Exact specifications detailing the API for tag models.
|
|
52
|
+
Given that there are "<additional specifications>" detailing models
|
|
53
|
+
When the corresponding specifications are run
|
|
54
|
+
Then all of those specifications are met
|
|
55
|
+
Examples:
|
|
56
|
+
| additional specifications |
|
|
57
|
+
| tag_unit_spec.rb |
|
|
58
|
+
| tag_integration_spec.rb |
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Outputting tag elements
|
|
2
|
+
|
|
3
|
+
The output of an element model is a representation of the element as it would
|
|
4
|
+
appear in gherkin.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Scenario: Output of a tag that has a name
|
|
8
|
+
Given a tag element based on the following gherkin:
|
|
9
|
+
"""
|
|
10
|
+
@some_tag
|
|
11
|
+
"""
|
|
12
|
+
When it is outputted
|
|
13
|
+
Then the following text is provided:
|
|
14
|
+
"""
|
|
15
|
+
@some_tag
|
|
16
|
+
"""
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Then /^the(?: feature "([^"]*)")? background is found to have the following properties:$/ do |file, properties|
|
|
2
|
+
file ||= 1
|
|
3
|
+
properties = properties.rows_hash
|
|
4
|
+
|
|
5
|
+
properties.each do |property, expected_value|
|
|
6
|
+
expected = expected_value
|
|
7
|
+
actual = @parsed_files[file - 1].feature.background.send(property.to_sym).to_s
|
|
8
|
+
|
|
9
|
+
actual.should == expected
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then /^the(?: feature "([^"]*)")? background has the following description:/ do |file, text|
|
|
14
|
+
file ||= 1
|
|
15
|
+
|
|
16
|
+
expected = text
|
|
17
|
+
|
|
18
|
+
new_description = @parsed_files[file - 1].feature.background.description_text
|
|
19
|
+
old_description = @parsed_files[file - 1].feature.background.description
|
|
20
|
+
|
|
21
|
+
new_description.should == expected
|
|
22
|
+
old_description.should == remove_whitespace(expected)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then /^the(?: feature "([^"]*)")? background's steps are as follows:$/ do |file, steps|
|
|
26
|
+
file ||= 1
|
|
27
|
+
|
|
28
|
+
steps = steps.raw.flatten.collect do |step|
|
|
29
|
+
if step.start_with? "'"
|
|
30
|
+
step.slice(1..step.length - 2)
|
|
31
|
+
else
|
|
32
|
+
step
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
actual_steps = Array.new.tap do |steps|
|
|
37
|
+
@parsed_files[file - 1].feature.background.steps.each do |step|
|
|
38
|
+
steps << step.base
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
expected = steps
|
|
43
|
+
actual = actual_steps.flatten
|
|
44
|
+
|
|
45
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
When /^step "([^"]*)" of the background (?:of feature "([^"]*)" )?has the following block:$/ do |step, file, block|
|
|
49
|
+
file ||= 1
|
|
50
|
+
|
|
51
|
+
block = block.raw.flatten.collect do |line|
|
|
52
|
+
if line.start_with? "'"
|
|
53
|
+
line.slice(1..line.length - 2)
|
|
54
|
+
else
|
|
55
|
+
line
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
assert @parsed_files[file - 1].feature.background.steps[step - 1].block == block
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Then(/^the(?: feature "([^"]*)")? background correctly stores its underlying implementation$/) do |file|
|
|
64
|
+
file ||= 1
|
|
65
|
+
|
|
66
|
+
raw_element = @parsed_files[file - 1].feature.background.raw_element
|
|
67
|
+
|
|
68
|
+
expected = 'Background'
|
|
69
|
+
actual = raw_element['keyword']
|
|
70
|
+
|
|
71
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
Given(/^a background element based on the following gherkin:$/) do |background_text|
|
|
75
|
+
@element = CukeModeler::Background.new(background_text)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
Then /^the background has convenient output$/ do
|
|
79
|
+
@parsed_files.first.feature.background.method(:to_s).owner.should == CukeModeler::Background
|
|
80
|
+
end
|
|
81
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Then /^(?:the )?directory(?: "([^"]*)")? is found to have the following properties:$/ do |directory, properties|
|
|
2
|
+
directory ||= 1
|
|
3
|
+
properties = properties.rows_hash
|
|
4
|
+
|
|
5
|
+
properties.each do |property, expected_value|
|
|
6
|
+
if property == 'path'
|
|
7
|
+
expected_value.sub!('path_to', @default_file_directory)
|
|
8
|
+
end
|
|
9
|
+
|
|
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}")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
When /^(?:the )?directory(?: "([^"]*)")? feature files are as follows:$/ do |directory, files|
|
|
18
|
+
directory ||= 1
|
|
19
|
+
|
|
20
|
+
actual_files = @parsed_directories[directory - 1].feature_files.collect { |file| file.name }
|
|
21
|
+
|
|
22
|
+
assert actual_files.flatten.sort == files.raw.flatten.sort
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
When /^(?:the )?directory(?: "([^"]*)")? directories are as follows:$/ do |directory, directories|
|
|
26
|
+
directory ||= 1
|
|
27
|
+
|
|
28
|
+
expected = directories.raw.flatten.sort
|
|
29
|
+
actual = @parsed_directories[directory - 1].directories.collect { |sub_directory| sub_directory.name }
|
|
30
|
+
|
|
31
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
When /^(?:the )?directory(?: "([^"]*)")? has no directories$/ do |directory|
|
|
35
|
+
directory ||= 1
|
|
36
|
+
|
|
37
|
+
expected = []
|
|
38
|
+
actual = @parsed_directories[directory - 1].directories
|
|
39
|
+
|
|
40
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Given(/^a directory element based on "([^"]*)"$/) do |directory_name|
|
|
44
|
+
directory_path = "#{@default_file_directory}/#{directory_name}"
|
|
45
|
+
FileUtils.mkdir(directory_path) unless File.exists?(directory_path)
|
|
46
|
+
|
|
47
|
+
@element = CukeModeler::Directory.new(directory_path)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Then(/^the directory has convenient output$/) do
|
|
51
|
+
@parsed_directories.first.method(:to_s).owner.should == CukeModeler::Directory
|
|
52
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents_text.should == contents
|
|
29
|
+
# Remove once Array contents is no longer supported
|
|
30
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents.should == contents.split("\n", -1)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string contents are empty$/ do |file, test, step|
|
|
34
|
+
file ||= 1
|
|
35
|
+
test ||= 1
|
|
36
|
+
step ||= 1
|
|
37
|
+
|
|
38
|
+
#todo Remove once Array contents is no longer supported
|
|
39
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents.should be_empty
|
|
40
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents_text.should be_empty
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then(/^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?doc string correctly stores its underlying implementation$/) do |file, test, step|
|
|
44
|
+
file ||= 1
|
|
45
|
+
test ||= 1
|
|
46
|
+
step ||= 1
|
|
47
|
+
|
|
48
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.raw_element
|
|
49
|
+
|
|
50
|
+
raw_element.has_key?('content_type').should be_true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
Then(/^the doc string has convenient output$/) do
|
|
54
|
+
@parsed_files.first.feature.tests.first.steps.first.block.method(:to_s).owner.should == CukeModeler::DocString
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Given(/^a doc string element based on the following gherkin:$/) do |doc_string_text|
|
|
58
|
+
@element = CukeModeler::DocString.new(doc_string_text)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Given(/^a doc string element based on the string "(.*)"$/) do |string|
|
|
62
|
+
@element = CukeModeler::DocString.new(string.gsub('\n', "\n"))
|
|
63
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Then /^(?:the )?file(?: "([^"]*)")? is found to have the following properties:$/ do |file, properties|
|
|
2
|
+
file ||= 1
|
|
3
|
+
properties = properties.rows_hash
|
|
4
|
+
|
|
5
|
+
properties.each do |property, expected_value|
|
|
6
|
+
if property == 'path'
|
|
7
|
+
expected_value.sub!('path_to', @test_directory)
|
|
8
|
+
end
|
|
9
|
+
|
|
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}")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
When /^(?:the )?file(?: "([^"]*)")? features are as follows:$/ do |file, feature|
|
|
18
|
+
file ||= 1
|
|
19
|
+
|
|
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}")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
When /^(?:the )?file(?: "([^"]*)")? has no features$/ do |file|
|
|
27
|
+
file ||= 1
|
|
28
|
+
|
|
29
|
+
assert @parsed_files[file - 1].feature.nil?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Then(/^the feature file has convenient output$/) do
|
|
33
|
+
@parsed_files.first.method(:to_s).owner.should == CukeModeler::FeatureFile
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Given(/^a feature file element based on "([^"]*)"$/) do |file_name|
|
|
37
|
+
file_path = "#{@default_file_directory}/#{file_name}"
|
|
38
|
+
File.open(file_path, 'w') { |file| file.puts "Feature:" } unless File.exists?(file_path)
|
|
39
|
+
|
|
40
|
+
@element = CukeModeler::FeatureFile.new(file_path)
|
|
41
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Then /^(?:the )?feature(?: "([^"]*)")? is found to have the following properties:$/ do |file, properties|
|
|
2
|
+
file ||= 1
|
|
3
|
+
properties = properties.rows_hash
|
|
4
|
+
|
|
5
|
+
properties.each do |property, expected_value|
|
|
6
|
+
expected = expected_value
|
|
7
|
+
actual = @parsed_files[file - 1].feature.send(property.to_sym).to_s
|
|
8
|
+
|
|
9
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then /^(?:the )?feature "([^"]*)" has the following description:$/ do |file, text|
|
|
14
|
+
new_description = @parsed_files[file - 1].feature.description_text
|
|
15
|
+
old_description = @parsed_files[file - 1].feature.description
|
|
16
|
+
|
|
17
|
+
new_description.should == text
|
|
18
|
+
old_description.should == remove_whitespace(text)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then /^feature "([^"]*)" is found to have the following tags:$/ do |file, expected_tags|
|
|
22
|
+
expected_tags = expected_tags.raw.flatten
|
|
23
|
+
|
|
24
|
+
@parsed_files[file - 1].feature.tags.should == expected_tags
|
|
25
|
+
@parsed_files[file - 1].feature.tag_elements.collect { |tag| tag.name }.should == expected_tags
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Then /^feature "([^"]*)" has no description$/ do |file|
|
|
29
|
+
@parsed_files[file - 1].feature.description_text.should == ''
|
|
30
|
+
@parsed_files[file - 1].feature.description.should == []
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Then /^feature "([^"]*)" has no tags$/ do |file|
|
|
34
|
+
assert @parsed_files[file - 1].feature.tags == []
|
|
35
|
+
assert @parsed_files[file - 1].feature.tag_elements.collect { |tag| tag.name } == []
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
When /^(?:the )?feature(?: "([^"]*)")? scenarios are as follows:$/ do |file, scenarios|
|
|
39
|
+
file ||= 1
|
|
40
|
+
|
|
41
|
+
actual_scenarios = @parsed_files[file - 1].feature.scenarios.collect { |scenario| scenario.name }
|
|
42
|
+
|
|
43
|
+
assert actual_scenarios.flatten.sort == scenarios.raw.flatten.sort
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
When /^(?:the )?feature(?: "([^"]*)")? outlines are as follows:$/ do |file, outlines|
|
|
47
|
+
file ||= 1
|
|
48
|
+
|
|
49
|
+
actual_outlines = @parsed_files[file - 1].feature.outlines.collect { |outline| outline.name }
|
|
50
|
+
|
|
51
|
+
expected = outlines.raw.flatten.sort
|
|
52
|
+
actual = actual_outlines.flatten.sort
|
|
53
|
+
|
|
54
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
When /^(?:the )?feature(?: "([^"]*)")? background is as follows:$/ do |file, background|
|
|
58
|
+
file ||= 1
|
|
59
|
+
|
|
60
|
+
@parsed_files[file - 1].feature.background.name.should == background.raw.flatten.first
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
When /^feature "([^"]*)" has no scenarios$/ do |file|
|
|
64
|
+
assert @parsed_files[file - 1].feature.scenarios == []
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
When /^feature "([^"]*)" has no outlines/ do |file|
|
|
68
|
+
assert @parsed_files[file - 1].feature.outlines == []
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
When /^feature "([^"]*)" has no background/ do |file|
|
|
72
|
+
assert @parsed_files[file - 1].feature.has_background? == false
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Then /^(?:the )?feature(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file|
|
|
76
|
+
file ||= 1
|
|
77
|
+
|
|
78
|
+
raw_element = @parsed_files[file - 1].feature.raw_element
|
|
79
|
+
|
|
80
|
+
raw_element.has_key?('elements').should be_true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Then(/^the feature has convenient output$/) do
|
|
84
|
+
@parsed_files.first.feature.method(:to_s).owner.should == CukeModeler::Feature
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Given(/^a feature element based on the following gherkin:$/) do |feature_text|
|
|
88
|
+
@element = CukeModeler::Feature.new(feature_text)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def remove_whitespace(text)
|
|
92
|
+
stripped_text = text.split("\n").collect { |line| line.strip }
|
|
93
|
+
stripped_text.delete('')
|
|
94
|
+
|
|
95
|
+
stripped_text
|
|
96
|
+
end
|