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,54 @@
|
|
|
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
|
+
|
|
8
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements.collect { |row| row.cells }.should == expected
|
|
9
|
+
# todo - remove once #contents is no longer supported
|
|
10
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.contents.should == expected
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?(?:step(?: "([^"]*)") )?table correctly stores its underlying implementation$/ do |file, test, step|
|
|
14
|
+
file ||= 1
|
|
15
|
+
test ||= 1
|
|
16
|
+
step ||= 1
|
|
17
|
+
|
|
18
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.raw_element
|
|
19
|
+
|
|
20
|
+
raw_element.is_a?(Array).should be_true
|
|
21
|
+
raw_element.each { |row| row.has_key?('cells').should be_true }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Given(/^a table row element$/) do
|
|
25
|
+
@element = CukeModeler::TableRow.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
When(/^the table row element has no cells$/) do
|
|
29
|
+
@element.cells = []
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Given(/^a table row element based on the following gherkin:$/) do |row_text|
|
|
33
|
+
@element = CukeModeler::TableRow.new(row_text)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Then(/^the table row has convenient output$/) do
|
|
37
|
+
@parsed_files.first.feature.tests.first.steps.first.block.row_elements.first.method(:to_s).owner.should == CukeModeler::TableRow
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Given(/^a table element$/) do
|
|
41
|
+
@element = CukeModeler::Table.new
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
When(/^the table element has no rows$/) do
|
|
45
|
+
@element.row_elements = []
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Then(/^the table has convenient output$/) do
|
|
49
|
+
@parsed_files.first.feature.tests.first.steps.first.block.method(:to_s).owner.should == CukeModeler::Table
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Given(/^a table element based on the following gherkin:$/) do |table_text|
|
|
53
|
+
@element = CukeModeler::Table.new(table_text)
|
|
54
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Then /^the feature tag correctly stores its underlying implementation$/ do
|
|
2
|
+
raw_element = @parsed_files.first.feature.tag_elements.first.raw_element
|
|
3
|
+
|
|
4
|
+
raw_element.has_key?('name').should be_true
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
When(/^the test tag correctly stores its underlying implementation$/) do
|
|
8
|
+
raw_element = @parsed_files.first.feature.tests.first.tag_elements.first.raw_element
|
|
9
|
+
|
|
10
|
+
raw_element.has_key?('name').should be_true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
When(/^the example tag correctly stores its underlying implementation$/) do
|
|
14
|
+
raw_element = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first.raw_element
|
|
15
|
+
|
|
16
|
+
raw_element.has_key?('name').should be_true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then(/^the feature tag name is "([^"]*)"$/) do |tag_name|
|
|
20
|
+
tag = @parsed_files.first.feature.tag_elements.first
|
|
21
|
+
|
|
22
|
+
tag.name.should == tag_name
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
When(/^the test tag name is "([^"]*)"$/) do |tag_name|
|
|
26
|
+
tag = @parsed_files.first.feature.tests.first.tag_elements.first
|
|
27
|
+
|
|
28
|
+
tag.name.should == tag_name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
When(/^the example tag name is "([^"]*)"$/) do |tag_name|
|
|
32
|
+
tag = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first
|
|
33
|
+
|
|
34
|
+
tag.name.should == tag_name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Then(/^the feature tag source line "([^"]*)"$/) do |line|
|
|
38
|
+
tag = @parsed_files.first.feature.tag_elements.first
|
|
39
|
+
|
|
40
|
+
tag.source_line.should == line
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
When(/^the test tag source line "([^"]*)"$/) do |line|
|
|
44
|
+
tag = @parsed_files.first.feature.tests.first.tag_elements.first
|
|
45
|
+
|
|
46
|
+
tag.source_line.should == line
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
When(/^the example tag source line "([^"]*)"$/) do |line|
|
|
50
|
+
tag = @parsed_files.first.feature.tests.first.examples.first.tag_elements.first
|
|
51
|
+
|
|
52
|
+
tag.source_line.should == line
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Then(/^the tag has convenient output$/) do
|
|
56
|
+
@parsed_files.first.feature.tag_elements.first.method(:to_s).owner.should == CukeModeler::Tag
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Given(/^a tag element based on the following gherkin:$/) do |tag_text|
|
|
60
|
+
@element = CukeModeler::Tag.new(tag_text)
|
|
61
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, properties|
|
|
2
|
+
file ||= 1
|
|
3
|
+
test ||= 1
|
|
4
|
+
|
|
5
|
+
properties = properties.rows_hash
|
|
6
|
+
|
|
7
|
+
properties.each do |property, value|
|
|
8
|
+
assert value == @parsed_files[file - 1].feature.tests[test - 1].send(property.to_sym).to_s
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? has the following description:$/ do |file, test, text|
|
|
13
|
+
file ||= 1
|
|
14
|
+
test ||= 1
|
|
15
|
+
|
|
16
|
+
new_description = @parsed_files[file - 1].feature.tests[test - 1].description_text
|
|
17
|
+
old_description = @parsed_files[file - 1].feature.tests[test - 1].description
|
|
18
|
+
|
|
19
|
+
new_description.should == text
|
|
20
|
+
old_description.should == remove_whitespace(text)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps are as follows:$/ do |file, test, steps|
|
|
24
|
+
file ||= 1
|
|
25
|
+
test ||= 1
|
|
26
|
+
|
|
27
|
+
steps = steps.raw.flatten.collect do |step|
|
|
28
|
+
if step.start_with? "'"
|
|
29
|
+
step.slice(1..step.length - 2)
|
|
30
|
+
else
|
|
31
|
+
step
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
actual_steps = Array.new.tap do |steps|
|
|
36
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps.each do |step|
|
|
37
|
+
steps << step.base
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
assert actual_steps.flatten == steps
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following tags:$/ do |file, test, expected_tags|
|
|
45
|
+
file ||= 1
|
|
46
|
+
test ||= 1
|
|
47
|
+
|
|
48
|
+
expected_tags = expected_tags.raw.flatten
|
|
49
|
+
|
|
50
|
+
@parsed_files[file - 1].feature.tests[test - 1].tags.should == expected_tags
|
|
51
|
+
@parsed_files[file - 1].feature.tests[test - 1].tag_elements.collect { |tag| tag.name }.should == expected_tags
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following applied tags:$/ do |file, test, expected_tags|
|
|
55
|
+
file ||= 1
|
|
56
|
+
test ||= 1
|
|
57
|
+
|
|
58
|
+
expected_tags = expected_tags.raw.flatten
|
|
59
|
+
|
|
60
|
+
@parsed_files[file - 1].feature.tests[test - 1].applied_tags.should == expected_tags
|
|
61
|
+
@parsed_files[file - 1].feature.tests[test - 1].applied_tag_elements.collect { |tag| tag.name }.should == expected_tags
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step "([^"]*)" has the following block:$/ do |file, test, step, block|
|
|
65
|
+
file ||= 1
|
|
66
|
+
test ||= 1
|
|
67
|
+
|
|
68
|
+
block = block.raw.flatten.collect do |line|
|
|
69
|
+
if line.start_with? "'"
|
|
70
|
+
line.slice(1..line.length - 2)
|
|
71
|
+
else
|
|
72
|
+
line
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
assert @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block == block
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
|
80
|
+
file ||= 1
|
|
81
|
+
first_test ||= 1
|
|
82
|
+
|
|
83
|
+
expected = true
|
|
84
|
+
actual = @parsed_files[file - 1].feature.tests[first_test - 1] == @parsed_files[file - 1].feature.tests[second_test - 1]
|
|
85
|
+
|
|
86
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is not equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
|
90
|
+
file ||= 1
|
|
91
|
+
first_test ||= 1
|
|
92
|
+
|
|
93
|
+
assert @parsed_files[file - 1].feature.tests[first_test - 1] != @parsed_files[file - 1].feature.tests[second_test - 1]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test|
|
|
97
|
+
file ||= 1
|
|
98
|
+
test ||= 1
|
|
99
|
+
|
|
100
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].raw_element
|
|
101
|
+
|
|
102
|
+
expected = ['Scenario', 'Scenario Outline']
|
|
103
|
+
actual = raw_element['keyword']
|
|
104
|
+
|
|
105
|
+
expected.include?(actual).should be_true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Then(/^the scenario has convenient output$/) do
|
|
109
|
+
@parsed_files.first.feature.tests.first.method(:to_s).owner.should == CukeModeler::Scenario
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
Given(/^a scenario element based on the following gherkin:$/) do |scenario_text|
|
|
113
|
+
@element = CukeModeler::Scenario.new(scenario_text)
|
|
114
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Then(/^the following text is provided:$/) do |expected_text|
|
|
2
|
+
expected_text.sub!('path_to', @default_file_directory)
|
|
3
|
+
|
|
4
|
+
@output.should == expected_text
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Then(/^the text provided is "(.*)"$/) do |text_string|
|
|
8
|
+
@output.should == text_string.gsub('\n', "\n")
|
|
9
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
unless RUBY_VERSION.to_s < '1.9.0'
|
|
2
|
+
require 'simplecov'
|
|
3
|
+
SimpleCov.command_name('cucumber_tests')
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require 'test/unit/assertions'
|
|
7
|
+
include Test::Unit::Assertions
|
|
8
|
+
|
|
9
|
+
require File.dirname(__FILE__) + '/../../lib/cuke_modeler'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Before do
|
|
13
|
+
@default_file_directory = "#{File.dirname(__FILE__)}/../temp_files"
|
|
14
|
+
@default_feature_file_name = 'test_feature.feature'
|
|
15
|
+
@default_step_file_name = 'test_steps.rb'
|
|
16
|
+
@test_file_directory = "#{File.dirname(__FILE__)}/../test_files"
|
|
17
|
+
@test_step_file_location = "#{@default_file_directory}/#{@default_step_file_name}"
|
|
18
|
+
@spec_directory = "#{File.dirname(__FILE__)}/../../spec"
|
|
19
|
+
|
|
20
|
+
FileUtils.mkdir(@default_file_directory)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
After do
|
|
24
|
+
FileUtils.remove_dir(@default_file_directory, true)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
data/lib/cuke_modeler.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "cuke_modeler/version"
|
|
2
|
+
|
|
3
|
+
require 'cuke_modeler/parsing'
|
|
4
|
+
require 'cuke_modeler/containing'
|
|
5
|
+
require 'cuke_modeler/taggable'
|
|
6
|
+
require 'cuke_modeler/raw'
|
|
7
|
+
require 'cuke_modeler/sourceable'
|
|
8
|
+
require 'cuke_modeler/nested'
|
|
9
|
+
require 'cuke_modeler/feature_file'
|
|
10
|
+
require 'cuke_modeler/directory'
|
|
11
|
+
require 'cuke_modeler/feature_element.rb'
|
|
12
|
+
require 'cuke_modeler/feature'
|
|
13
|
+
require 'cuke_modeler/test_element.rb'
|
|
14
|
+
require 'cuke_modeler/background'
|
|
15
|
+
require 'cuke_modeler/scenario'
|
|
16
|
+
require 'cuke_modeler/outline'
|
|
17
|
+
require 'cuke_modeler/example'
|
|
18
|
+
require 'cuke_modeler/step'
|
|
19
|
+
require 'cuke_modeler/doc_string'
|
|
20
|
+
require 'cuke_modeler/table'
|
|
21
|
+
require 'cuke_modeler/world'
|
|
22
|
+
require 'cuke_modeler/row'
|
|
23
|
+
require 'cuke_modeler/table_row'
|
|
24
|
+
require 'cuke_modeler/tag'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
module CukeModeler
|
|
28
|
+
# Your code goes here...
|
|
29
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module CukeModeler
|
|
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
|
+
|
|
14
|
+
build_background(parsed_background) if parsed_background
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Returns gherkin representation of the background.
|
|
18
|
+
def to_s
|
|
19
|
+
text = ''
|
|
20
|
+
|
|
21
|
+
text << "Background:#{name_output_string}"
|
|
22
|
+
text << "\n" + description_output_string unless description_text.empty?
|
|
23
|
+
text << "\n" unless steps.empty? || description_text.empty?
|
|
24
|
+
text << "\n" + steps_output_string unless steps.empty?
|
|
25
|
+
|
|
26
|
+
text
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def build_background(parsed_background)
|
|
34
|
+
# Just a stub in case something specific needs to be done
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
module CukeModeler
|
|
2
|
+
|
|
3
|
+
# A class modeling a directory containing .feature files.
|
|
4
|
+
|
|
5
|
+
class Directory
|
|
6
|
+
|
|
7
|
+
include Containing
|
|
8
|
+
include Nested
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# The FeatureFile objects contained by the Directory
|
|
12
|
+
attr_accessor :feature_files
|
|
13
|
+
|
|
14
|
+
# The Directory objects contained by the Directory
|
|
15
|
+
attr_accessor :directories
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Creates a new Directory object and, if *directory_parsed* is provided,
|
|
19
|
+
# populates the object.
|
|
20
|
+
def initialize(directory_parsed = nil)
|
|
21
|
+
@directory = directory_parsed
|
|
22
|
+
|
|
23
|
+
@feature_files = []
|
|
24
|
+
@directories = []
|
|
25
|
+
|
|
26
|
+
if directory_parsed
|
|
27
|
+
raise(ArgumentError, "Unknown directory: #{directory_parsed.inspect}") unless File.exists?(directory_parsed)
|
|
28
|
+
build_directory
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the name of the directory.
|
|
33
|
+
def name
|
|
34
|
+
File.basename(@directory.gsub('\\', '/'))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the path of the directory.
|
|
38
|
+
def path
|
|
39
|
+
@directory
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Returns the number of sub-directories contained in the directory.
|
|
43
|
+
def directory_count
|
|
44
|
+
@directories.count
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns the number of features files contained in the directory.
|
|
48
|
+
def feature_file_count
|
|
49
|
+
@feature_files.count
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Returns the immediate child elements of the directory (i.e. its Directory
|
|
53
|
+
# and FeatureFile objects).
|
|
54
|
+
def contains
|
|
55
|
+
@feature_files + @directories
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns the path of the directory.
|
|
59
|
+
def to_s
|
|
60
|
+
path.to_s
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def build_directory
|
|
68
|
+
entries = Dir.entries(@directory)
|
|
69
|
+
entries.delete '.'
|
|
70
|
+
entries.delete '..'
|
|
71
|
+
|
|
72
|
+
entries.each do |entry|
|
|
73
|
+
entry = "#{@directory}/#{entry}"
|
|
74
|
+
|
|
75
|
+
case
|
|
76
|
+
when File.directory?(entry)
|
|
77
|
+
@directories << build_child_element(Directory, entry)
|
|
78
|
+
when entry =~ /\.feature$/
|
|
79
|
+
@feature_files << build_child_element(FeatureFile, entry)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|