cuke_modeler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,16 +4,15 @@ shared_examples_for 'a containing element' do
|
|
4
4
|
|
5
5
|
# clazz must be defined by the calling file
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
let(:element) { clazz.new }
|
8
|
+
|
10
9
|
|
11
|
-
it 'has children
|
12
|
-
|
10
|
+
it 'has children' do
|
11
|
+
element.should respond_to(:contains)
|
13
12
|
end
|
14
13
|
|
15
|
-
it 'returns a collection of children
|
16
|
-
|
14
|
+
it 'returns a collection of children' do
|
15
|
+
element.contains.is_a?(Array).should be_true
|
17
16
|
end
|
18
17
|
|
19
18
|
end
|
@@ -5,99 +5,138 @@ SimpleCov.command_name('Directory') unless RUBY_VERSION.to_s < '1.9.0'
|
|
5
5
|
describe 'Directory, Unit' do
|
6
6
|
|
7
7
|
let(:clazz) { CukeModeler::Directory }
|
8
|
+
let(:directory) { clazz.new }
|
8
9
|
|
9
|
-
it_should_behave_like 'a nested element'
|
10
|
-
it_should_behave_like 'a containing element'
|
11
|
-
it_should_behave_like 'a bare bones element'
|
12
|
-
it_should_behave_like 'a prepopulated element'
|
13
10
|
|
14
|
-
|
15
|
-
@directory = clazz.new
|
16
|
-
end
|
11
|
+
describe 'common behavior' do
|
17
12
|
|
18
|
-
|
19
|
-
|
13
|
+
it_should_behave_like 'a nested element'
|
14
|
+
it_should_behave_like 'a containing element'
|
15
|
+
it_should_behave_like 'a bare bones element'
|
16
|
+
it_should_behave_like 'a prepopulated element'
|
20
17
|
|
21
|
-
expect { CukeModeler::Directory.new(path) }.to raise_error(ArgumentError)
|
22
18
|
end
|
23
19
|
|
24
|
-
it 'knows the name of the directory that it is modeling' do
|
25
|
-
path = "#{@default_file_directory}"
|
26
20
|
|
27
|
-
|
21
|
+
describe 'unique behavior' do
|
28
22
|
|
29
|
-
|
30
|
-
|
23
|
+
it 'has a name' do
|
24
|
+
expect(directory).to respond_to(:name)
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
27
|
+
it 'derives its directory name from its path' do
|
28
|
+
directory.path = 'path/to/foo'
|
34
29
|
|
35
|
-
|
30
|
+
expect(directory.name).to eq('foo')
|
31
|
+
end
|
36
32
|
|
37
|
-
|
38
|
-
|
33
|
+
it 'has a path' do
|
34
|
+
expect(directory).to respond_to(:path)
|
35
|
+
end
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
37
|
+
it 'can change its path' do
|
38
|
+
expect(directory).to respond_to(:path=)
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
40
|
+
directory.path = :some_path
|
41
|
+
directory.path.should == :some_path
|
42
|
+
directory.path = :some_other_path
|
43
|
+
directory.path.should == :some_other_path
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
46
|
+
it 'knows the path of the directory that it is modeling' do
|
47
|
+
path = "#{@default_file_directory}"
|
53
48
|
|
54
|
-
|
55
|
-
end
|
49
|
+
directory = clazz.new(path)
|
56
50
|
|
57
|
-
|
58
|
-
|
59
|
-
end
|
51
|
+
directory.path.should == path
|
52
|
+
end
|
60
53
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@directory.directories = :some_other_directories
|
65
|
-
@directory.directories.should == :some_other_directories
|
66
|
-
end
|
54
|
+
it 'has feature files' do
|
55
|
+
directory.should respond_to(:feature_files)
|
56
|
+
end
|
67
57
|
|
68
|
-
|
69
|
-
|
58
|
+
it 'can change its feature files' do
|
59
|
+
expect(directory).to respond_to(:feature_files=)
|
70
60
|
|
71
|
-
|
72
|
-
|
61
|
+
directory.feature_files = :some_feature_files
|
62
|
+
directory.feature_files.should == :some_feature_files
|
63
|
+
directory.feature_files = :some_other_feature_files
|
64
|
+
directory.feature_files.should == :some_other_feature_files
|
65
|
+
end
|
73
66
|
|
74
|
-
|
75
|
-
|
76
|
-
@directory.directories.should == []
|
77
|
-
end
|
67
|
+
it 'knows how many feature files it has' do
|
68
|
+
directory.feature_files = [:file_1, :file_2, :file_3]
|
78
69
|
|
79
|
-
|
80
|
-
|
81
|
-
files = [:file_1, :file_2, :file_3]
|
82
|
-
everything = files + directories
|
70
|
+
directory.feature_file_count.should == 3
|
71
|
+
end
|
83
72
|
|
84
|
-
|
85
|
-
|
73
|
+
it 'has directories' do
|
74
|
+
directory.should respond_to(:directories)
|
75
|
+
end
|
86
76
|
|
87
|
-
|
88
|
-
|
77
|
+
it 'can change its directories' do
|
78
|
+
expect(directory).to respond_to(:directories=)
|
89
79
|
|
90
|
-
|
80
|
+
directory.directories = :some_directories
|
81
|
+
directory.directories.should == :some_directories
|
82
|
+
directory.directories = :some_other_directories
|
83
|
+
directory.directories.should == :some_other_directories
|
84
|
+
end
|
91
85
|
|
92
|
-
it '
|
93
|
-
|
86
|
+
it 'knows how many directories it has' do
|
87
|
+
directory.directories = [:directory_1, :directory_2, :directory_3]
|
88
|
+
|
89
|
+
directory.directory_count.should == 3
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'abstract instantiation' do
|
93
|
+
|
94
|
+
it 'starts with no path' do
|
95
|
+
expect(directory.path).to be nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'starts with no name' do
|
99
|
+
expect(directory.name).to be nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'starts with no feature files or directories' do
|
103
|
+
directory.feature_files.should == []
|
104
|
+
directory.directories.should == []
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'contains feature files and directories' do
|
110
|
+
directories = [:directory_1, :directory_2, :directory_3]
|
111
|
+
files = [:file_1, :file_2, :file_3]
|
112
|
+
everything = files + directories
|
113
|
+
|
114
|
+
directory.directories = directories
|
115
|
+
directory.feature_files = files
|
116
|
+
|
117
|
+
directory.contains.should =~ everything
|
94
118
|
end
|
95
119
|
|
96
|
-
|
97
|
-
|
120
|
+
describe 'directory output edge cases' do
|
121
|
+
|
122
|
+
it 'is a String' do
|
123
|
+
directory.to_s.should be_a(String)
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
context 'a new directory object' do
|
128
|
+
|
129
|
+
let(:directory) { clazz.new }
|
130
|
+
|
131
|
+
|
132
|
+
it 'can output an empty directory' do
|
133
|
+
expect { directory.to_s }.to_not raise_error
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
98
138
|
end
|
99
139
|
|
100
140
|
end
|
101
141
|
|
102
142
|
end
|
103
|
-
|
@@ -5,134 +5,152 @@ SimpleCov.command_name('DocString') unless RUBY_VERSION.to_s < '1.9.0'
|
|
5
5
|
describe 'DocString, Unit' do
|
6
6
|
|
7
7
|
let(:clazz) { CukeModeler::DocString }
|
8
|
+
let(:doc_string) { clazz.new }
|
8
9
|
|
9
|
-
|
10
|
-
it_should_behave_like 'a bare bones element'
|
11
|
-
it_should_behave_like 'a prepopulated element'
|
12
|
-
it_should_behave_like 'a raw element'
|
10
|
+
describe 'common behavior' do
|
13
11
|
|
14
|
-
|
15
|
-
|
12
|
+
it_should_behave_like 'a nested element'
|
13
|
+
it_should_behave_like 'a bare bones element'
|
14
|
+
it_should_behave_like 'a prepopulated element'
|
15
|
+
it_should_behave_like 'a raw element'
|
16
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.contents_text.should == "some doc string"
|
21
|
-
#todo Remove once Array contents is no longer supported
|
22
|
-
@element.contents.should == ["some doc string"]
|
23
17
|
end
|
24
18
|
|
25
|
-
it 'provides a descriptive filename when being parsed from stand alone text' do
|
26
|
-
source = 'bad doc string text'
|
27
19
|
|
28
|
-
|
29
|
-
end
|
20
|
+
describe 'unique behavior' do
|
30
21
|
|
31
|
-
|
32
|
-
|
33
|
-
raw_data = doc_string.raw_element
|
22
|
+
it 'can be parsed from stand alone text' do
|
23
|
+
source = "\"\"\"\nsome doc string\n\"\"\""
|
34
24
|
|
35
|
-
|
36
|
-
expect(raw_data[:type]).to eq(:DocString)
|
37
|
-
end
|
25
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
27
|
+
# Sanity check in case instantiation failed in a non-explosive manner
|
28
|
+
@element.contents_text.should == "some doc string"
|
29
|
+
#todo Remove once Array contents is no longer supported
|
30
|
+
@element.contents.should == ["some doc string"]
|
31
|
+
end
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
33
|
+
it 'provides a descriptive filename when being parsed from stand alone text' do
|
34
|
+
source = 'bad doc string text'
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
raw_data = doc_string.raw_element
|
36
|
+
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_doc_string\.feature'/)
|
37
|
+
end
|
50
38
|
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
40
|
+
doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
|
41
|
+
raw_data = doc_string.raw_element
|
54
42
|
|
43
|
+
expect(raw_data.keys).to match_array([:type, :location, :content])
|
44
|
+
expect(raw_data[:type]).to eq(:DocString)
|
45
|
+
end
|
55
46
|
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
48
|
+
doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
|
49
|
+
raw_data = doc_string.raw_element
|
59
50
|
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
expect(raw_data.keys).to match_array([:type, :location, :content])
|
52
|
+
expect(raw_data[:type]).to eq(:DocString)
|
53
|
+
end
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@doc_string.content_type = :some_other_content_type
|
68
|
-
@doc_string.content_type.should == :some_other_content_type
|
69
|
-
end
|
55
|
+
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
56
|
+
doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
|
57
|
+
raw_data = doc_string.raw_element
|
70
58
|
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
expect(raw_data.keys).to match_array(['value', 'content_type', 'line'])
|
60
|
+
expect(raw_data['value']).to eq('some doc string')
|
61
|
+
end
|
74
62
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@doc_string.should respond_to(:contents_text)
|
79
|
-
end
|
63
|
+
it 'has a content type' do
|
64
|
+
doc_string.should respond_to(:content_type)
|
65
|
+
end
|
80
66
|
|
81
|
-
|
82
|
-
|
83
|
-
@doc_string.contents = :some_contents
|
84
|
-
@doc_string.contents.should == :some_contents
|
85
|
-
@doc_string.contents = :some_other_contents
|
86
|
-
@doc_string.contents.should == :some_other_contents
|
87
|
-
|
88
|
-
@doc_string.contents_text = :some_contents
|
89
|
-
@doc_string.contents_text.should == :some_contents
|
90
|
-
@doc_string.contents_text = :some_other_contents
|
91
|
-
@doc_string.contents_text.should == :some_other_contents
|
92
|
-
end
|
67
|
+
it 'can change its content type' do
|
68
|
+
expect(doc_string).to respond_to(:content_type=)
|
93
69
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
#todo Remove once Array contents is no longer supported
|
101
|
-
it 'stores its contents as an array of strings - deprecated' do
|
102
|
-
source = "\"\"\"\nsome text\nsome more text\n\"\"\""
|
103
|
-
doc_string = CukeModeler::DocString.new(source)
|
70
|
+
doc_string.content_type = :some_content_type
|
71
|
+
doc_string.content_type.should == :some_content_type
|
72
|
+
doc_string.content_type = :some_other_content_type
|
73
|
+
doc_string.content_type.should == :some_other_content_type
|
74
|
+
end
|
104
75
|
|
105
|
-
|
76
|
+
it 'starts with no content type' do
|
77
|
+
doc_string.content_type.should == nil
|
78
|
+
end
|
106
79
|
|
107
|
-
contents
|
108
|
-
|
109
|
-
|
80
|
+
it 'has contents' do
|
81
|
+
#todo Remove once Array contents is no longer supported
|
82
|
+
doc_string.should respond_to(:contents)
|
83
|
+
doc_string.should respond_to(:contents_text)
|
110
84
|
end
|
111
|
-
end
|
112
85
|
|
113
|
-
|
114
|
-
|
115
|
-
|
86
|
+
it 'can get and set its contents' do
|
87
|
+
expect(doc_string).to respond_to(:contents=)
|
88
|
+
expect(doc_string).to respond_to(:contents_text=)
|
116
89
|
|
117
|
-
|
90
|
+
#todo Remove once Array contents is no longer supported
|
91
|
+
doc_string.contents = :some_contents
|
92
|
+
doc_string.contents.should == :some_contents
|
93
|
+
doc_string.contents = :some_other_contents
|
94
|
+
doc_string.contents.should == :some_other_contents
|
118
95
|
|
119
|
-
|
120
|
-
|
96
|
+
doc_string.contents_text = :some_contents
|
97
|
+
doc_string.contents_text.should == :some_contents
|
98
|
+
doc_string.contents_text = :some_other_contents
|
99
|
+
doc_string.contents_text.should == :some_other_contents
|
100
|
+
end
|
121
101
|
|
122
|
-
|
102
|
+
it 'starts with no contents' do
|
103
|
+
#todo Remove once Array contents is no longer supported
|
104
|
+
doc_string.contents.should == []
|
105
|
+
doc_string.contents_text.should == ''
|
106
|
+
end
|
107
|
+
|
108
|
+
#todo Remove once Array contents is no longer supported
|
109
|
+
it 'stores its contents as an array of strings - deprecated' do
|
110
|
+
source = "\"\"\"\nsome text\nsome more text\n\"\"\""
|
111
|
+
doc_string = clazz.new(source)
|
123
112
|
|
124
|
-
|
125
|
-
|
113
|
+
contents = doc_string.contents
|
114
|
+
|
115
|
+
contents.is_a?(Array).should be_true
|
116
|
+
contents.each do |line|
|
117
|
+
line.is_a?(String).should be_true
|
118
|
+
end
|
126
119
|
end
|
127
120
|
|
128
|
-
it '
|
129
|
-
|
121
|
+
it 'stores its contents as a String' do
|
122
|
+
source = "\"\"\"\nsome text\nsome more text\n\"\"\""
|
123
|
+
doc_string = clazz.new(source)
|
124
|
+
|
125
|
+
contents = doc_string.contents_text
|
126
|
+
|
127
|
+
contents.is_a?(String).should be_true
|
130
128
|
end
|
131
129
|
|
132
|
-
|
133
|
-
|
130
|
+
describe 'doc string output edge cases' do
|
131
|
+
|
132
|
+
it 'is a String' do
|
133
|
+
doc_string.to_s.should be_a(String)
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
context 'a new doc string object' do
|
138
|
+
|
139
|
+
let(:doc_string) { clazz.new }
|
140
|
+
|
141
|
+
|
142
|
+
it 'can output an empty doc string' do
|
143
|
+
expect { doc_string.to_s }.to_not raise_error
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'can output a doc string that has only a content type' do
|
147
|
+
doc_string.content_type = 'some type'
|
148
|
+
|
149
|
+
expect { doc_string.to_s }.to_not raise_error
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
134
153
|
|
135
|
-
expect { @doc_string.to_s }.to_not raise_error
|
136
154
|
end
|
137
155
|
|
138
156
|
end
|