cuke_modeler 0.3.0 → 0.4.0
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 +4 -4
- data/History.rdoc +8 -0
- data/features/step_definitions/feature_steps.rb +1 -1
- data/features/step_definitions/test_steps.rb +6 -2
- data/lib/cuke_modeler/directory.rb +7 -10
- data/lib/cuke_modeler/version.rb +1 -1
- data/spec/integration/background_integration_spec.rb +53 -40
- data/spec/integration/directory_integration_spec.rb +39 -26
- data/spec/integration/doc_string_integration_spec.rb +51 -43
- data/spec/integration/example_integration_spec.rb +71 -60
- data/spec/integration/feature_file_integration_spec.rb +36 -22
- data/spec/integration/feature_integration_spec.rb +113 -104
- data/spec/integration/outline_integration_spec.rb +71 -56
- data/spec/integration/row_integration_spec.rb +72 -0
- data/spec/integration/scenario_integration_spec.rb +61 -46
- data/spec/integration/step_integration_spec.rb +126 -117
- data/spec/integration/table_integration_spec.rb +67 -52
- data/spec/integration/table_row_integration_spec.rb +48 -40
- data/spec/integration/tag_integration_spec.rb +53 -45
- data/spec/integration/world_integration_spec.rb +2 -1
- data/spec/spec_helper.rb +15 -12
- data/spec/unit/background_unit_spec.rb +65 -50
- data/spec/unit/bare_bones_unit_specs.rb +2 -3
- data/spec/unit/containing_element_unit_specs.rb +6 -7
- data/spec/unit/directory_unit_spec.rb +103 -64
- data/spec/unit/doc_string_unit_spec.rb +113 -95
- data/spec/unit/example_unit_spec.rb +235 -219
- data/spec/unit/feature_element_unit_spec.rb +6 -6
- data/spec/unit/feature_element_unit_specs.rb +28 -24
- data/spec/unit/feature_file_unit_spec.rb +73 -63
- data/spec/unit/feature_unit_spec.rb +145 -111
- data/spec/unit/nested_element_unit_specs.rb +14 -13
- data/spec/unit/nested_unit_spec.rb +24 -21
- data/spec/unit/outline_unit_spec.rb +92 -78
- data/spec/unit/parsing_unit_spec.rb +55 -51
- data/spec/unit/prepopulated_unit_specs.rb +2 -3
- data/spec/unit/raw_element_unit_specs.rb +12 -11
- data/spec/unit/raw_unit_spec.rb +15 -12
- data/spec/unit/row_unit_spec.rb +68 -52
- data/spec/unit/scenario_unit_spec.rb +76 -62
- data/spec/unit/sourceable_unit_spec.rb +8 -6
- data/spec/unit/sourced_element_unit_specs.rb +4 -6
- data/spec/unit/step_unit_spec.rb +231 -203
- data/spec/unit/table_row_unit_spec.rb +68 -52
- data/spec/unit/table_unit_spec.rb +100 -82
- data/spec/unit/tag_unit_spec.rb +62 -48
- data/spec/unit/taggable_unit_spec.rb +58 -51
- data/spec/unit/tagged_element_unit_specs.rb +28 -26
- data/spec/unit/test_element_unit_spec.rb +33 -27
- data/spec/unit/test_element_unit_specs.rb +15 -14
- data/spec/unit/world_unit_spec.rb +94 -84
- metadata +4 -2
@@ -4,27 +4,28 @@ shared_examples_for 'a nested element' do
|
|
4
4
|
|
5
5
|
# clazz must be defined by the calling file
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
let(:nested_element) { clazz.new }
|
8
|
+
|
10
9
|
|
11
|
-
it 'has a parent element
|
12
|
-
|
10
|
+
it 'has a parent element' do
|
11
|
+
nested_element.should respond_to(:parent_element)
|
13
12
|
end
|
14
13
|
|
15
|
-
it 'can
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
it 'can change its parent element' do
|
15
|
+
expect(nested_element).to respond_to(:parent_element=)
|
16
|
+
|
17
|
+
nested_element.parent_element = :some_parent_element
|
18
|
+
nested_element.parent_element.should == :some_parent_element
|
19
|
+
nested_element.parent_element = :some_other_parent_element
|
20
|
+
nested_element.parent_element.should == :some_other_parent_element
|
20
21
|
end
|
21
22
|
|
22
23
|
it 'starts with no parent element' do
|
23
|
-
|
24
|
+
nested_element.parent_element.should == nil
|
24
25
|
end
|
25
26
|
|
26
27
|
it 'has access to its ancestors' do
|
27
|
-
|
28
|
+
nested_element.should respond_to(:get_ancestor)
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'gets an ancestor based on type' do
|
@@ -32,7 +33,7 @@ shared_examples_for 'a nested element' do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it 'raises and exception if an unknown ancestor type is requested' do
|
35
|
-
expect {
|
36
|
+
expect { nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
|
36
37
|
end
|
37
38
|
|
38
39
|
end
|
@@ -4,34 +4,37 @@ SimpleCov.command_name('Nested') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
4
|
|
5
5
|
describe 'Nested, Unit' do
|
6
6
|
|
7
|
-
nodule
|
7
|
+
let(:nodule) { CukeModeler::Nested }
|
8
|
+
let(:nested_element) { Object.new.extend(nodule) }
|
8
9
|
|
9
|
-
before(:each) do
|
10
|
-
@nested_element = Object.new.extend(nodule)
|
11
|
-
end
|
12
10
|
|
11
|
+
describe 'unique behavior' do
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
it 'has a parent element' do
|
14
|
+
nested_element.should respond_to(:parent_element)
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
@nested_element.parent_element.should == :some_parent_element
|
21
|
-
@nested_element.parent_element = :some_other_parent_element
|
22
|
-
@nested_element.parent_element.should == :some_other_parent_element
|
23
|
-
end
|
17
|
+
it 'can change its parent element' do
|
18
|
+
expect(nested_element).to respond_to(:parent_element=)
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
nested_element.parent_element = :some_parent_element
|
21
|
+
nested_element.parent_element.should == :some_parent_element
|
22
|
+
nested_element.parent_element = :some_other_parent_element
|
23
|
+
nested_element.parent_element.should == :some_other_parent_element
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
it 'has access to its ancestors' do
|
27
|
+
nested_element.should respond_to(:get_ancestor)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'gets an ancestor based on type' do
|
31
|
+
(nodule.instance_method(:get_ancestor).arity == 1).should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'raises and exception if an unknown ancestor type is requested' do
|
35
|
+
expect { nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
|
36
|
+
end
|
32
37
|
|
33
|
-
it 'raises and exception if an unknown ancestor type is requested' do
|
34
|
-
expect { @nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
|
35
38
|
end
|
36
39
|
|
37
40
|
end
|
@@ -5,118 +5,132 @@ SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
|
|
5
5
|
describe 'Outline, Unit' do
|
6
6
|
|
7
7
|
let(:clazz) { CukeModeler::Outline }
|
8
|
+
let(:outline) { clazz.new }
|
8
9
|
|
9
|
-
it_should_behave_like 'a feature element'
|
10
|
-
it_should_behave_like 'a nested element'
|
11
|
-
it_should_behave_like 'a containing element'
|
12
|
-
it_should_behave_like 'a tagged element'
|
13
|
-
it_should_behave_like 'a bare bones element'
|
14
|
-
it_should_behave_like 'a prepopulated element'
|
15
|
-
it_should_behave_like 'a test element'
|
16
|
-
it_should_behave_like 'a sourced element'
|
17
|
-
it_should_behave_like 'a raw element'
|
18
10
|
|
11
|
+
describe 'common behavior' do
|
19
12
|
|
20
|
-
|
21
|
-
|
13
|
+
it_should_behave_like 'a feature element'
|
14
|
+
it_should_behave_like 'a nested element'
|
15
|
+
it_should_behave_like 'a containing element'
|
16
|
+
it_should_behave_like 'a tagged element'
|
17
|
+
it_should_behave_like 'a bare bones element'
|
18
|
+
it_should_behave_like 'a prepopulated element'
|
19
|
+
it_should_behave_like 'a test element'
|
20
|
+
it_should_behave_like 'a sourced element'
|
21
|
+
it_should_behave_like 'a raw element'
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
describe 'unique behavior' do
|
27
|
+
|
28
|
+
it 'can be parsed from stand alone text' do
|
29
|
+
source = "Scenario Outline: test outline
|
22
30
|
Examples:
|
23
31
|
|param|
|
24
32
|
|value|"
|
25
33
|
|
26
|
-
|
34
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
37
|
+
@element.name.should == 'test outline'
|
38
|
+
end
|
31
39
|
|
32
|
-
|
33
|
-
|
40
|
+
it 'provides a descriptive filename when being parsed from stand alone text' do
|
41
|
+
source = "bad outline text \n Scenario Outline:\n And a step\n @foo "
|
34
42
|
|
35
|
-
|
36
|
-
|
43
|
+
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_outline\.feature'/)
|
44
|
+
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
46
|
+
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
47
|
+
outline = clazz.new("Scenario Outline: test outline\nExamples:\n|param|\n|value|")
|
48
|
+
raw_data = outline.raw_element
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :examples])
|
51
|
+
expect(raw_data[:type]).to eq(:ScenarioOutline)
|
52
|
+
end
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
55
|
+
outline = clazz.new("Scenario Outline: test outline\nExamples:\n|param|\n|value|")
|
56
|
+
raw_data = outline.raw_element
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
58
|
+
expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :examples])
|
59
|
+
expect(raw_data[:type]).to eq(:ScenarioOutline)
|
60
|
+
end
|
53
61
|
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
63
|
+
outline = clazz.new("Scenario Outline: test outline\nExamples:\n|param|\n|value|")
|
64
|
+
raw_data = outline.raw_element
|
57
65
|
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
expect(raw_data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type'])
|
67
|
+
expect(raw_data['keyword']).to eq('Scenario Outline')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'has examples' do
|
71
|
+
outline.should respond_to(:examples)
|
72
|
+
end
|
61
73
|
|
74
|
+
it 'can change its examples' do
|
75
|
+
expect(outline).to respond_to(:examples=)
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
77
|
+
outline.examples = :some_examples
|
78
|
+
outline.examples.should == :some_examples
|
79
|
+
outline.examples = :some_other_examples
|
80
|
+
outline.examples.should == :some_other_examples
|
81
|
+
end
|
66
82
|
|
83
|
+
it 'starts with no examples' do
|
84
|
+
outline.examples.should == []
|
85
|
+
end
|
67
86
|
|
68
|
-
|
69
|
-
|
70
|
-
|
87
|
+
it 'contains steps and examples' do
|
88
|
+
steps = [:step_1, :step_2, :step_3]
|
89
|
+
examples = [:example_1, :example_2, :example_3]
|
90
|
+
everything = steps + examples
|
71
91
|
|
72
|
-
|
73
|
-
|
74
|
-
@outline.examples.should == :some_examples
|
75
|
-
@outline.examples = :some_other_examples
|
76
|
-
@outline.examples.should == :some_other_examples
|
77
|
-
end
|
92
|
+
outline.steps = steps
|
93
|
+
outline.examples = examples
|
78
94
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
95
|
+
outline.contains.should =~ everything
|
96
|
+
end
|
82
97
|
|
83
|
-
|
84
|
-
steps = [:step_1, :step_2, :step_3]
|
85
|
-
examples = [:example_1, :example_2, :example_3]
|
86
|
-
everything = steps + examples
|
98
|
+
describe 'outline output edge cases' do
|
87
99
|
|
88
|
-
|
89
|
-
|
100
|
+
it 'is a String' do
|
101
|
+
outline.to_s.should be_a(String)
|
102
|
+
end
|
90
103
|
|
91
|
-
@outline.contains.should =~ everything
|
92
|
-
end
|
93
104
|
|
94
|
-
|
105
|
+
context 'a new outline object' do
|
95
106
|
|
96
|
-
|
97
|
-
@outline.to_s.should be_a(String)
|
98
|
-
end
|
107
|
+
let(:outline) { clazz.new }
|
99
108
|
|
100
|
-
it 'can output an empty outline' do
|
101
|
-
expect { @outline.to_s }.to_not raise_error
|
102
|
-
end
|
103
109
|
|
104
|
-
|
105
|
-
|
110
|
+
it 'can output an empty outline' do
|
111
|
+
expect { outline.to_s }.to_not raise_error
|
112
|
+
end
|
106
113
|
|
107
|
-
|
108
|
-
|
114
|
+
it 'can output an outline that has only a name' do
|
115
|
+
outline.name = 'a name'
|
109
116
|
|
110
|
-
|
111
|
-
|
117
|
+
expect { outline.to_s }.to_not raise_error
|
118
|
+
end
|
112
119
|
|
113
|
-
|
114
|
-
|
120
|
+
it 'can output an outline that has only a description' do
|
121
|
+
outline.description_text = 'a description'
|
122
|
+
|
123
|
+
expect { outline.to_s }.to_not raise_error
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'can output an outline that has only tags' do
|
127
|
+
outline.tags = ['a tag']
|
128
|
+
|
129
|
+
expect { outline.to_s }.to_not raise_error
|
130
|
+
end
|
115
131
|
|
116
|
-
|
117
|
-
@outline.tags = ['a tag']
|
132
|
+
end
|
118
133
|
|
119
|
-
expect { @outline.to_s }.to_not raise_error
|
120
134
|
end
|
121
135
|
|
122
136
|
end
|
@@ -7,79 +7,83 @@ describe 'Parsing, Unit' do
|
|
7
7
|
let(:nodule) { CukeModeler::Parsing }
|
8
8
|
|
9
9
|
|
10
|
-
|
11
|
-
nodule.should respond_to(:parse_text)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'can only parse strings' do
|
15
|
-
expect { nodule.parse_text(5) }.to raise_error(ArgumentError)
|
16
|
-
expect { nodule.parse_text('Feature:') }.to_not raise_error
|
17
|
-
end
|
10
|
+
describe 'unique behavior' do
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
12
|
+
it 'can parse text' do
|
13
|
+
nodule.should respond_to(:parse_text)
|
14
|
+
end
|
23
15
|
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
it 'can only parse strings' do
|
17
|
+
expect { nodule.parse_text(5) }.to raise_error(ArgumentError)
|
18
|
+
expect { nodule.parse_text('Feature:') }.to_not raise_error
|
19
|
+
end
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
21
|
+
it 'returns an Array' do
|
22
|
+
result = nodule.parse_text('Feature:')
|
23
|
+
result.is_a?(Array).should be_true
|
24
|
+
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
it 'takes the text that is to be parsed and an optional file name' do
|
27
|
+
expect(nodule.method(:parse_text).arity).to eq(-2)
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
module CukeModeler
|
40
|
-
class TestError < StandardError
|
41
|
-
end
|
42
|
-
end
|
30
|
+
it 'raises and error if an error is encountered while parsing text' do
|
31
|
+
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /Error encountered while parsing '.*'/)
|
32
|
+
end
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
it 'includes the file parsed in the error that it raises' do
|
35
|
+
expect { nodule.parse_text('bad file', 'file foo.txt') }.to raise_error(/'file foo\.txt'/)
|
36
|
+
end
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
it 'includes the underlying error message in the error that it raises' do
|
39
|
+
begin
|
40
|
+
# Custom error type in order to ensure that we are throwing the correct thing
|
41
|
+
module CukeModeler
|
42
|
+
class TestError < StandardError
|
53
43
|
end
|
54
44
|
end
|
55
|
-
else
|
56
|
-
old_method = Gherkin::Parser::Parser.instance_method(:parse)
|
57
45
|
|
58
|
-
|
59
|
-
|
46
|
+
# Monkey patch Gherkin to throw the error that we need for testing
|
47
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
48
|
+
old_method = Gherkin::Parser.instance_method(:parse)
|
49
|
+
|
50
|
+
module Gherkin
|
60
51
|
class Parser
|
61
52
|
def parse(*args)
|
62
53
|
raise(CukeModeler::TestError, 'something went wrong')
|
63
54
|
end
|
64
55
|
end
|
65
56
|
end
|
57
|
+
else
|
58
|
+
old_method = Gherkin::Parser::Parser.instance_method(:parse)
|
59
|
+
|
60
|
+
module Gherkin
|
61
|
+
module Parser
|
62
|
+
class Parser
|
63
|
+
def parse(*args)
|
64
|
+
raise(CukeModeler::TestError, 'something went wrong')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
66
69
|
end
|
67
|
-
end
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
expect { nodule.parse_text('bad file') }.to raise_error(/CukeModeler::TestError.*something went wrong/)
|
72
|
+
ensure
|
73
|
+
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
74
|
+
if Gem.loaded_specs['gherkin'].version.version[/^3|4/]
|
75
|
+
Gherkin::Parser.send(:define_method, :parse, old_method)
|
76
|
+
else
|
77
|
+
Gherkin::Parser::Parser.send(:define_method, :parse, old_method)
|
78
|
+
end
|
76
79
|
end
|
80
|
+
|
77
81
|
end
|
78
82
|
|
79
|
-
|
83
|
+
it 'has a default file name if one is not provided' do
|
84
|
+
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
85
|
+
end
|
80
86
|
|
81
|
-
it 'has a default file name if one is not provided' do
|
82
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
83
87
|
end
|
84
88
|
|
85
89
|
end
|