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,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('TableRow') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'TableRow, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CukeModeler::TableRow
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
12
|
+
it_should_behave_like 'a sourced element', clazz
|
|
13
|
+
it_should_behave_like 'a raw element', clazz
|
|
14
|
+
|
|
15
|
+
it 'can be parsed from stand alone text' do
|
|
16
|
+
source = '| a | row |'
|
|
17
|
+
|
|
18
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
|
19
|
+
|
|
20
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
|
21
|
+
@element.cells.should == ['a', 'row']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
before(:each) do
|
|
25
|
+
@row = clazz.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'has cells' do
|
|
29
|
+
@row.should respond_to(:cells)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'can get and set its cells' do
|
|
33
|
+
@row.cells = :some_cells
|
|
34
|
+
@row.cells.should == :some_cells
|
|
35
|
+
@row.cells = :some_other_cells
|
|
36
|
+
@row.cells.should == :some_other_cells
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'starts with no cells' do
|
|
40
|
+
@row.cells.should == []
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context 'table row output edge cases' do
|
|
44
|
+
|
|
45
|
+
it 'is a String' do
|
|
46
|
+
@row.to_s.should be_a(String)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'can output an empty table row' do
|
|
50
|
+
expect { @row.to_s }.to_not raise_error
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
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 = CukeModeler::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
|
+
it_should_behave_like 'a raw element', clazz
|
|
13
|
+
|
|
14
|
+
it 'can be parsed from stand alone text' do
|
|
15
|
+
source = '| a table |'
|
|
16
|
+
|
|
17
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
|
18
|
+
|
|
19
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
|
20
|
+
@element.row_elements.collect { |row| row.cells }.should == [['a table']]
|
|
21
|
+
# todo - remove once #contents is no longer supported
|
|
22
|
+
@element.contents.should == [['a table']]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
before(:each) do
|
|
26
|
+
@table = clazz.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# todo - remove once #contents is no longer supported
|
|
30
|
+
it 'has contents - #contents' do
|
|
31
|
+
@table.should respond_to(:contents)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# todo - remove once #contents is no longer supported
|
|
35
|
+
it 'can get and set its contents - #contents, #contents=' do
|
|
36
|
+
@table.contents = :some_contents
|
|
37
|
+
@table.contents.should == :some_contents
|
|
38
|
+
@table.contents = :some_other_contents
|
|
39
|
+
@table.contents.should == :some_other_contents
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# todo - remove once #contents is no longer supported
|
|
43
|
+
it 'starts with no contents' do
|
|
44
|
+
@table.contents.should == []
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'has row elements' do
|
|
48
|
+
@table.should respond_to(:row_elements)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'can get and set its row elements' do
|
|
52
|
+
@table.row_elements = :some_row_elements
|
|
53
|
+
@table.row_elements.should == :some_row_elements
|
|
54
|
+
@table.row_elements = :some_other_row_elements
|
|
55
|
+
@table.row_elements.should == :some_other_row_elements
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'starts with no row elements' do
|
|
59
|
+
@table.row_elements.should == []
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# todo - remove once #contents is no longer supported
|
|
63
|
+
it 'stores its contents as a nested array of strings' do
|
|
64
|
+
source = "| cell 1 | cell 2 |\n| cell 3 | cell 4 |"
|
|
65
|
+
table = CukeModeler::Table.new(source)
|
|
66
|
+
|
|
67
|
+
contents = table.contents
|
|
68
|
+
|
|
69
|
+
contents.is_a?(Array).should be_true
|
|
70
|
+
|
|
71
|
+
contents.each do |row|
|
|
72
|
+
row.is_a?(Array).should be_true
|
|
73
|
+
row.each { |cell| cell.is_a?(String).should be_true }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context 'table output edge cases' do
|
|
78
|
+
|
|
79
|
+
it 'is a String' do
|
|
80
|
+
@table.to_s.should be_a(String)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'can output an empty table' do
|
|
84
|
+
expect { @table.to_s }.to_not raise_error
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# todo - remove once #contents is no longer supported
|
|
88
|
+
it 'can output a table that only has contents' do
|
|
89
|
+
@table.contents = ['some contents']
|
|
90
|
+
|
|
91
|
+
expect { @table.to_s }.to_not raise_error
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Tag, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CukeModeler::Tag
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
12
|
+
it_should_behave_like 'a sourced element', clazz
|
|
13
|
+
it_should_behave_like 'a raw element', clazz
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
it 'can be parsed from stand alone text' do
|
|
17
|
+
source = '@a_tag'
|
|
18
|
+
|
|
19
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
|
20
|
+
@element.name.should == '@a_tag'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
before(:each) do
|
|
24
|
+
@element = clazz.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
it 'has a name' do
|
|
29
|
+
@element.should respond_to(:name)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'can get and set its name' do
|
|
33
|
+
@element.name = :some_name
|
|
34
|
+
@element.name.should == :some_name
|
|
35
|
+
@element.name = :some_other_name
|
|
36
|
+
@element.name.should == :some_other_name
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'tag output edge cases' do
|
|
40
|
+
|
|
41
|
+
it 'is a String' do
|
|
42
|
+
@element.to_s.should be_a(String)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'can output an empty tag' do
|
|
46
|
+
expect { @element.to_s }.to_not raise_error
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
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 = CukeModeler::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' do
|
|
23
|
+
@element.should respond_to(:tags)
|
|
24
|
+
@element.should respond_to(:tag_elements)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'can get and set its tags' do
|
|
28
|
+
@element.tags = :some_tags
|
|
29
|
+
@element.tags.should == :some_tags
|
|
30
|
+
@element.tags = :some_other_tags
|
|
31
|
+
@element.tags.should == :some_other_tags
|
|
32
|
+
|
|
33
|
+
@element.tag_elements = :some_tag_elements
|
|
34
|
+
@element.tag_elements.should == :some_tag_elements
|
|
35
|
+
@element.tag_elements = :some_other_tag_elements
|
|
36
|
+
@element.tag_elements.should == :some_other_tag_elements
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'has applied tags' do
|
|
40
|
+
@element.should respond_to(:applied_tags)
|
|
41
|
+
@element.should respond_to(:applied_tag_elements)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'inherits its applied tags from its ancestors' do
|
|
45
|
+
all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
|
|
46
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
47
|
+
parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
|
|
48
|
+
|
|
49
|
+
@element.parent_element = parent
|
|
50
|
+
|
|
51
|
+
@element.applied_tags.should == all_parent_tags
|
|
52
|
+
@element.applied_tag_elements.should == all_parent_tag_elements
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'knows all of its applicable tags' do
|
|
56
|
+
all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
|
|
57
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
58
|
+
own_tags = ['@tag_1', '@tag_2']
|
|
59
|
+
own_tag_elements = [:tag_element_1, :tag_element_2]
|
|
60
|
+
|
|
61
|
+
parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
|
|
62
|
+
|
|
63
|
+
@element.parent_element = parent
|
|
64
|
+
@element.tags = own_tags
|
|
65
|
+
@element.tag_elements = own_tag_elements
|
|
66
|
+
|
|
67
|
+
@element.all_tags.should == all_parent_tags + own_tags
|
|
68
|
+
@element.all_tag_elements.should == all_parent_tag_elements + own_tag_elements
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'may have no applied tags' do
|
|
72
|
+
@element.parent_element = :not_a_tagged_object
|
|
73
|
+
|
|
74
|
+
@element.applied_tags.should == []
|
|
75
|
+
@element.applied_tag_elements.should == []
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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' do
|
|
10
|
+
@element.should respond_to(:tags)
|
|
11
|
+
@element.should respond_to(:tag_elements)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'can get and set its tags' do
|
|
15
|
+
@element.tags = :some_tags
|
|
16
|
+
@element.tags.should == :some_tags
|
|
17
|
+
@element.tags = :some_other_tags
|
|
18
|
+
@element.tags.should == :some_other_tags
|
|
19
|
+
|
|
20
|
+
@element.tag_elements = :some_tag_elements
|
|
21
|
+
@element.tag_elements.should == :some_tag_elements
|
|
22
|
+
@element.tag_elements = :some_other_tag_elements
|
|
23
|
+
@element.tag_elements.should == :some_other_tag_elements
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'starts with no tags' do
|
|
27
|
+
@element.tags.should == []
|
|
28
|
+
@element.tag_elements.should == []
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'has applied tags' do
|
|
32
|
+
@element.should respond_to(:applied_tags)
|
|
33
|
+
@element.should respond_to(:applied_tag_elements)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'inherits its applied tags from its ancestors' do
|
|
37
|
+
all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
|
|
38
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
39
|
+
parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
|
|
40
|
+
|
|
41
|
+
@element.parent_element = parent
|
|
42
|
+
|
|
43
|
+
@element.applied_tags.should == all_parent_tags
|
|
44
|
+
@element.applied_tag_elements.should == all_parent_tag_elements
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'knows all of its applicable tags' do
|
|
48
|
+
all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
|
|
49
|
+
all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
|
|
50
|
+
own_tags = ['@tag_1', '@tag_2']
|
|
51
|
+
own_tag_elements = [:tag_element_1, :tag_element_2]
|
|
52
|
+
|
|
53
|
+
parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
|
|
54
|
+
|
|
55
|
+
@element.parent_element = parent
|
|
56
|
+
@element.tags = own_tags
|
|
57
|
+
@element.tag_elements = own_tag_elements
|
|
58
|
+
|
|
59
|
+
@element.all_tags.should == all_parent_tags + own_tags
|
|
60
|
+
@element.all_tag_elements.should == all_parent_tag_elements + own_tag_elements
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
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 = CukeModeler::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
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('World') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'World, Unit' do
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
@world = CukeModeler::World
|
|
9
|
+
@world.loaded_step_patterns.clear
|
|
10
|
+
@world.delimiter = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'has left and right delimiters used for step argument parsing - #left_delimiter, #right_delimiter' do
|
|
14
|
+
@world.should respond_to(:left_delimiter)
|
|
15
|
+
@world.should respond_to(:right_delimiter)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'can get and set the delimiters used for step argument parsing' do
|
|
19
|
+
@world.left_delimiter = '"'
|
|
20
|
+
@world.right_delimiter = '"'
|
|
21
|
+
@world.left_delimiter.should == '"'
|
|
22
|
+
@world.right_delimiter.should == '"'
|
|
23
|
+
|
|
24
|
+
@world.left_delimiter = '!'
|
|
25
|
+
@world.right_delimiter = '!'
|
|
26
|
+
@world.left_delimiter.should == '!'
|
|
27
|
+
@world.right_delimiter.should == '!'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'can have different left and right delimiters' do
|
|
31
|
+
@world.left_delimiter = '"'
|
|
32
|
+
@world.right_delimiter = '*'
|
|
33
|
+
|
|
34
|
+
(@world.left_delimiter != @world.right_delimiter).should be_true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'can set both of its delimiters at once - #delimiter=' do
|
|
38
|
+
@world.delimiter = '*'
|
|
39
|
+
|
|
40
|
+
@world.left_delimiter.should == '*'
|
|
41
|
+
@world.right_delimiter.should == '*'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'starts with no delimiters' do
|
|
45
|
+
@world.left_delimiter.should == nil
|
|
46
|
+
@world.right_delimiter.should == nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'step patterns' do
|
|
50
|
+
|
|
51
|
+
it 'can load step patterns - #load_step_pattern' do
|
|
52
|
+
@world.should respond_to(:load_step_pattern)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'starts with no patterns loaded' do
|
|
56
|
+
@world.loaded_step_patterns.should == []
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'keeps track of loaded step patterns - #loaded_step_patterns' do
|
|
60
|
+
patterns = [/a pattern/, /another pattern/]
|
|
61
|
+
|
|
62
|
+
patterns.each do |pattern|
|
|
63
|
+
@world.load_step_pattern(pattern)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
@world.loaded_step_patterns.should =~ patterns
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'can load step definition files - #load_step_file' do
|
|
70
|
+
file_path = "#{@default_file_directory}/step_file.rb"
|
|
71
|
+
patterns = [/a pattern/, /another pattern/]
|
|
72
|
+
|
|
73
|
+
File.open(file_path, 'w') { |file|
|
|
74
|
+
patterns.each do |pattern|
|
|
75
|
+
file.puts "Given #{pattern.inspect} do end"
|
|
76
|
+
end
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@world.load_step_file(file_path)
|
|
80
|
+
|
|
81
|
+
@world.loaded_step_patterns.should =~ patterns
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'can handle different step keywords - #load_step_file' do
|
|
85
|
+
file_path = "#{@default_file_directory}/step_file.rb"
|
|
86
|
+
patterns = [/given pattern/, /when pattern/, /then pattern/, /and pattern/, /but pattern/]
|
|
87
|
+
|
|
88
|
+
File.open(file_path, 'w') { |file|
|
|
89
|
+
file.puts "Given #{patterns[0].inspect} do end"
|
|
90
|
+
file.puts "When #{patterns[1].inspect} do end"
|
|
91
|
+
file.puts "Then #{patterns[2].inspect} do end"
|
|
92
|
+
file.puts "And #{patterns[3].inspect} do end"
|
|
93
|
+
file.puts "But #{patterns[4].inspect} do end"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@world.load_step_file(file_path)
|
|
97
|
+
|
|
98
|
+
@world.loaded_step_patterns.should =~ patterns
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'can handle a variety of declaration structures - #load_step_file' do
|
|
102
|
+
file_path = "#{@default_file_directory}/step_file.rb"
|
|
103
|
+
patterns = [/parentheses pattern/, /no parentheses pattern/, /excess whitespace pattern/]
|
|
104
|
+
|
|
105
|
+
File.open(file_path, 'w') { |file|
|
|
106
|
+
file.puts "Given(#{patterns[0].inspect}) do end"
|
|
107
|
+
file.puts "Given #{patterns[1].inspect} do end"
|
|
108
|
+
file.puts "Given #{patterns[2].inspect} do end"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@world.load_step_file(file_path)
|
|
112
|
+
|
|
113
|
+
@world.loaded_step_patterns.should =~ patterns
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'can clear its loaded step patterns - #clear_step_patterns' do
|
|
117
|
+
patterns = [/a pattern/, /another pattern/]
|
|
118
|
+
|
|
119
|
+
patterns.each do |pattern|
|
|
120
|
+
@world.load_step_pattern(pattern)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
@world.loaded_step_patterns.should =~ patterns
|
|
124
|
+
@world.clear_step_patterns
|
|
125
|
+
@world.loaded_step_patterns.should == []
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|