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,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Parsing') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Parsing, Unit' do
|
|
6
|
+
|
|
7
|
+
it 'can parse text - #parse_text' do
|
|
8
|
+
CukeModeler::Parsing.should respond_to(:parse_text)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'can only parse strings' do
|
|
12
|
+
expect{CukeModeler::Parsing.parse_text(5)}.to raise_error(ArgumentError)
|
|
13
|
+
expect{CukeModeler::Parsing.parse_text('Feature:')}.to_not raise_error
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'returns an Array' do
|
|
17
|
+
result = CukeModeler::Parsing.parse_text('Feature:')
|
|
18
|
+
result.is_a?(Array).should be_true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a raw element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has an underlying implementation representation - #raw_element' do
|
|
10
|
+
@element.should respond_to(:raw_element)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can get and set its underlying implementation representation - #raw_element, #raw_element=' do
|
|
14
|
+
@element.raw_element = :some_raw_element
|
|
15
|
+
@element.raw_element.should == :some_raw_element
|
|
16
|
+
@element.raw_element = :some_other_raw_element
|
|
17
|
+
@element.raw_element.should == :some_other_raw_element
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'starts with no underlying implementation representation' do
|
|
21
|
+
@element.raw_element.should == nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Raw') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Raw, Unit' do
|
|
6
|
+
|
|
7
|
+
nodule = CukeModeler::Raw
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
@element = Object.new.extend(nodule)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
it 'has a raw element - #raw_element' do
|
|
15
|
+
@element.should respond_to(:raw_element)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'can get and set its raw element - #raw_element, #raw_element=' do
|
|
19
|
+
@element.raw_element = :some_raw_element
|
|
20
|
+
@element.raw_element.should == :some_raw_element
|
|
21
|
+
@element.raw_element = :some_other_raw_element
|
|
22
|
+
@element.raw_element.should == :some_other_raw_element
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Row') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Row, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CukeModeler::Row
|
|
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 - #cells' do
|
|
29
|
+
@row.should respond_to(:cells)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'can get and set its cells - #cells, #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 '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 row' do
|
|
50
|
+
expect { @row.to_s }.to_not raise_error
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Scenario, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CukeModeler::Scenario
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a containing element', clazz
|
|
12
|
+
it_should_behave_like 'a tagged element', clazz
|
|
13
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
14
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
15
|
+
it_should_behave_like 'a test element', clazz
|
|
16
|
+
it_should_behave_like 'a sourced element', clazz
|
|
17
|
+
it_should_behave_like 'a raw element', clazz
|
|
18
|
+
|
|
19
|
+
it 'can be parsed from stand alone text' do
|
|
20
|
+
source = 'Scenario: test scenario'
|
|
21
|
+
|
|
22
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
|
23
|
+
|
|
24
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
|
25
|
+
@element.name.should == 'test scenario'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before(:each) do
|
|
29
|
+
@scenario = clazz.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'contains only steps' do
|
|
33
|
+
steps = [:step_1, :step_2]
|
|
34
|
+
everything = steps
|
|
35
|
+
|
|
36
|
+
@scenario.steps = steps
|
|
37
|
+
|
|
38
|
+
@scenario.contains.should =~ everything
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'scenario output edge cases' do
|
|
42
|
+
|
|
43
|
+
it 'is a String' do
|
|
44
|
+
@scenario.to_s.should be_a(String)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'can output an empty scenario' do
|
|
48
|
+
expect { @scenario.to_s }.to_not raise_error
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'can output a scenario that has only a name' do
|
|
52
|
+
@scenario.name = 'a name'
|
|
53
|
+
|
|
54
|
+
expect { @scenario.to_s }.to_not raise_error
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'can output a scenario that has only a description' do
|
|
58
|
+
@scenario.description_text = 'a description'
|
|
59
|
+
|
|
60
|
+
expect { @scenario.to_s }.to_not raise_error
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'can output a scenario that has only a tags' do
|
|
64
|
+
@scenario.tags = ['a tag']
|
|
65
|
+
|
|
66
|
+
expect { @scenario.to_s }.to_not raise_error
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Sourceable') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Sourceable, Unit' do
|
|
6
|
+
|
|
7
|
+
nodule = CukeModeler::Sourceable
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
@element = Object.new.extend(nodule)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'has a source line - #source_line' do
|
|
14
|
+
@element.should respond_to(:source_line)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a sourced element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
it 'has a source line - #source_line' do
|
|
11
|
+
@element.should respond_to(:source_line)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'starts with no source line' do
|
|
15
|
+
@element.source_line.should == nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Step, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CukeModeler::Step
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
12
|
+
it_should_behave_like 'a sourced element', clazz
|
|
13
|
+
it_should_behave_like 'a raw element', clazz
|
|
14
|
+
|
|
15
|
+
before(:each) do
|
|
16
|
+
@step = clazz.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'has arguments - #arguments' do
|
|
20
|
+
@step.should respond_to(:arguments)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'can get and set its arguments - #arguments, #arguments=' do
|
|
24
|
+
@step.arguments = :some_arguments
|
|
25
|
+
@step.arguments.should == :some_arguments
|
|
26
|
+
@step.arguments = :some_other_arguments
|
|
27
|
+
@step.arguments.should == :some_other_arguments
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'starts with no arguments' do
|
|
31
|
+
@step.arguments.should == []
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'has a base - #base' do
|
|
35
|
+
@step.should respond_to(:base)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'can get and set its base - #base, #base=' do
|
|
39
|
+
@step.base = :some_base
|
|
40
|
+
@step.base.should == :some_base
|
|
41
|
+
@step.base = :some_other_base
|
|
42
|
+
@step.base.should == :some_other_base
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'starts with no base' do
|
|
46
|
+
@step.base.should == nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'has a block - #block' do
|
|
50
|
+
@step.should respond_to(:block)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'can get and set its block - #block, #block=' do
|
|
54
|
+
@step.block = :some_block
|
|
55
|
+
@step.block.should == :some_block
|
|
56
|
+
@step.block = :some_other_block
|
|
57
|
+
@step.block.should == :some_other_block
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'starts with no block' do
|
|
61
|
+
@step.block.should == nil
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'has a keyword - #keyword' do
|
|
65
|
+
@step.should respond_to(:keyword)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'can get and set its keyword - #keyword, #keyword=' do
|
|
69
|
+
@step.keyword = :some_keyword
|
|
70
|
+
@step.keyword.should == :some_keyword
|
|
71
|
+
@step.keyword = :some_other_keyword
|
|
72
|
+
@step.keyword.should == :some_other_keyword
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'starts with no keyword' do
|
|
76
|
+
@step.keyword.should == nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'has a left delimiter - #left_delimiter' do
|
|
80
|
+
@step.should respond_to(:left_delimiter)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'can get and set its left delimiter - #left_delimiter, #left_delimiter=' do
|
|
84
|
+
@step.left_delimiter = :some_left_delimiter
|
|
85
|
+
@step.left_delimiter.should == :some_left_delimiter
|
|
86
|
+
@step.left_delimiter = :some_other_left_delimiter
|
|
87
|
+
@step.left_delimiter.should == :some_other_left_delimiter
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'starts with no left delimiter' do
|
|
91
|
+
@step.left_delimiter.should == nil
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'has a right delimiter - #right_delimiter' do
|
|
95
|
+
@step.should respond_to(:right_delimiter)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'can get and set its right delimiter - #right_delimiter, #right_delimiter=' do
|
|
99
|
+
@step.right_delimiter = :some_right_delimiter
|
|
100
|
+
@step.right_delimiter.should == :some_right_delimiter
|
|
101
|
+
@step.right_delimiter = :some_other_right_delimiter
|
|
102
|
+
@step.right_delimiter.should == :some_other_right_delimiter
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'starts with no right delimiter' do
|
|
106
|
+
@step.right_delimiter.should == nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'can set both of its delimiters at once - #delimiter=' do
|
|
110
|
+
@step.delimiter = :new_delimiter
|
|
111
|
+
@step.left_delimiter.should == :new_delimiter
|
|
112
|
+
@step.right_delimiter.should == :new_delimiter
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context '#scan_arguments' do
|
|
116
|
+
|
|
117
|
+
it 'can explicitly scan for arguments' do
|
|
118
|
+
@step.should respond_to(:scan_arguments)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'can determine its arguments based on a regular expression' do
|
|
122
|
+
source = 'Given a test step with a parameter'
|
|
123
|
+
step = CukeModeler::Step.new(source)
|
|
124
|
+
|
|
125
|
+
step.scan_arguments(/parameter/)
|
|
126
|
+
step.arguments.should == ['parameter']
|
|
127
|
+
step.scan_arguments(/t s/)
|
|
128
|
+
step.arguments.should == ['t s']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'can determine its arguments based on delimiters' do
|
|
132
|
+
source = 'Given a test step with -parameter 1- and -parameter 2-'
|
|
133
|
+
|
|
134
|
+
step = CukeModeler::Step.new(source)
|
|
135
|
+
|
|
136
|
+
step.scan_arguments('-', '-')
|
|
137
|
+
step.arguments.should == ['parameter 1', 'parameter 2']
|
|
138
|
+
step.scan_arguments('!', '!')
|
|
139
|
+
step.arguments.should == []
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'can use different left and right delimiters when scanning' do
|
|
143
|
+
source = 'Given a test step with !a parameter-'
|
|
144
|
+
|
|
145
|
+
step = CukeModeler::Step.new(source)
|
|
146
|
+
|
|
147
|
+
step.scan_arguments('!', '-')
|
|
148
|
+
step.arguments.should == ['a parameter']
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'can use delimiters of varying lengths' do
|
|
152
|
+
source = 'Given a test step with -start-a parameter-end-'
|
|
153
|
+
|
|
154
|
+
step = CukeModeler::Step.new(source)
|
|
155
|
+
|
|
156
|
+
step.scan_arguments('-start-', '-end-')
|
|
157
|
+
step.arguments.should == ['a parameter']
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'can handle delimiters with special regular expression characters' do
|
|
161
|
+
source = 'Given a test step with \d+a parameter.?'
|
|
162
|
+
|
|
163
|
+
step = CukeModeler::Step.new(source)
|
|
164
|
+
|
|
165
|
+
step.scan_arguments('\d+', '.?')
|
|
166
|
+
step.arguments.should == ['a parameter']
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'defaults to its set delimiters when scanning' do
|
|
170
|
+
source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
|
|
171
|
+
step = CukeModeler::Step.new(source)
|
|
172
|
+
|
|
173
|
+
step.left_delimiter = '"'
|
|
174
|
+
step.right_delimiter = '"'
|
|
175
|
+
step.scan_arguments
|
|
176
|
+
|
|
177
|
+
step.arguments.should == ['parameter 2']
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'can be parsed from stand alone text' do
|
|
182
|
+
source = '* test step'
|
|
183
|
+
|
|
184
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
|
185
|
+
|
|
186
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
|
187
|
+
@element.base.should == 'test step'
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
context '#step_text' do
|
|
191
|
+
|
|
192
|
+
before(:each) do
|
|
193
|
+
source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
|
|
194
|
+
@step = CukeModeler::Step.new(source)
|
|
195
|
+
@step.delimiter = '-'
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'can provide different flavors of step\'s text' do
|
|
199
|
+
@step.should respond_to(:step_text)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'returns different text based on options' do
|
|
203
|
+
(clazz.instance_method(:step_text).arity != 0).should be_true
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'returns the step\'s text as an Array' do
|
|
207
|
+
@step.step_text.is_a?(Array).should be_true
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it 'can provide the step\'s text without the arguments' do
|
|
211
|
+
expected_output = ['Given a test step with -- ^and@ *parameter 2!!']
|
|
212
|
+
|
|
213
|
+
@step.step_text(:with_arguments => false).should == expected_output
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it 'can determine its arguments based on delimiters' do
|
|
217
|
+
expected_output = ['Given a test step with -parameter 1- ^@ *parameter 2!!']
|
|
218
|
+
|
|
219
|
+
@step.step_text(:with_arguments => false, :left_delimiter => '^', :right_delimiter => '@').should == expected_output
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'can use delimiters of varying lengths' do
|
|
223
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
|
|
224
|
+
|
|
225
|
+
@step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it 'can handle delimiters with special regular expression characters' do
|
|
229
|
+
expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
|
|
230
|
+
|
|
231
|
+
@step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
context 'step output edge cases' do
|
|
237
|
+
|
|
238
|
+
it 'is a String' do
|
|
239
|
+
@step.to_s.should be_a(String)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it 'can output an empty step' do
|
|
243
|
+
expect { @step.to_s }.to_not raise_error
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it 'can output a step that has only a keyword' do
|
|
247
|
+
@step.keyword = '*'
|
|
248
|
+
|
|
249
|
+
expect { @step.to_s }.to_not raise_error
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
it 'can output a step that has only a base' do
|
|
253
|
+
@step.base = 'step base'
|
|
254
|
+
|
|
255
|
+
expect { @step.to_s }.to_not raise_error
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
end
|
|
259
|
+
end
|