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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +8 -0
  3. data/features/step_definitions/feature_steps.rb +1 -1
  4. data/features/step_definitions/test_steps.rb +6 -2
  5. data/lib/cuke_modeler/directory.rb +7 -10
  6. data/lib/cuke_modeler/version.rb +1 -1
  7. data/spec/integration/background_integration_spec.rb +53 -40
  8. data/spec/integration/directory_integration_spec.rb +39 -26
  9. data/spec/integration/doc_string_integration_spec.rb +51 -43
  10. data/spec/integration/example_integration_spec.rb +71 -60
  11. data/spec/integration/feature_file_integration_spec.rb +36 -22
  12. data/spec/integration/feature_integration_spec.rb +113 -104
  13. data/spec/integration/outline_integration_spec.rb +71 -56
  14. data/spec/integration/row_integration_spec.rb +72 -0
  15. data/spec/integration/scenario_integration_spec.rb +61 -46
  16. data/spec/integration/step_integration_spec.rb +126 -117
  17. data/spec/integration/table_integration_spec.rb +67 -52
  18. data/spec/integration/table_row_integration_spec.rb +48 -40
  19. data/spec/integration/tag_integration_spec.rb +53 -45
  20. data/spec/integration/world_integration_spec.rb +2 -1
  21. data/spec/spec_helper.rb +15 -12
  22. data/spec/unit/background_unit_spec.rb +65 -50
  23. data/spec/unit/bare_bones_unit_specs.rb +2 -3
  24. data/spec/unit/containing_element_unit_specs.rb +6 -7
  25. data/spec/unit/directory_unit_spec.rb +103 -64
  26. data/spec/unit/doc_string_unit_spec.rb +113 -95
  27. data/spec/unit/example_unit_spec.rb +235 -219
  28. data/spec/unit/feature_element_unit_spec.rb +6 -6
  29. data/spec/unit/feature_element_unit_specs.rb +28 -24
  30. data/spec/unit/feature_file_unit_spec.rb +73 -63
  31. data/spec/unit/feature_unit_spec.rb +145 -111
  32. data/spec/unit/nested_element_unit_specs.rb +14 -13
  33. data/spec/unit/nested_unit_spec.rb +24 -21
  34. data/spec/unit/outline_unit_spec.rb +92 -78
  35. data/spec/unit/parsing_unit_spec.rb +55 -51
  36. data/spec/unit/prepopulated_unit_specs.rb +2 -3
  37. data/spec/unit/raw_element_unit_specs.rb +12 -11
  38. data/spec/unit/raw_unit_spec.rb +15 -12
  39. data/spec/unit/row_unit_spec.rb +68 -52
  40. data/spec/unit/scenario_unit_spec.rb +76 -62
  41. data/spec/unit/sourceable_unit_spec.rb +8 -6
  42. data/spec/unit/sourced_element_unit_specs.rb +4 -6
  43. data/spec/unit/step_unit_spec.rb +231 -203
  44. data/spec/unit/table_row_unit_spec.rb +68 -52
  45. data/spec/unit/table_unit_spec.rb +100 -82
  46. data/spec/unit/tag_unit_spec.rb +62 -48
  47. data/spec/unit/taggable_unit_spec.rb +58 -51
  48. data/spec/unit/tagged_element_unit_specs.rb +28 -26
  49. data/spec/unit/test_element_unit_spec.rb +33 -27
  50. data/spec/unit/test_element_unit_specs.rb +15 -14
  51. data/spec/unit/world_unit_spec.rb +94 -84
  52. metadata +4 -2
@@ -4,9 +4,8 @@ shared_examples_for 'a bare bones element' do
4
4
 
5
5
  # clazz must be defined by the calling file
6
6
 
7
- before(:each) do
8
- @element = clazz.new
9
- end
7
+ let(:element) { clazz.new }
8
+
10
9
 
11
10
  it 'can be initialized empty' do
12
11
  expect { clazz.new }.to_not raise_error
@@ -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
- before(:each) do
8
- @element = clazz.new
9
- end
7
+ let(:element) { clazz.new }
8
+
10
9
 
11
- it 'has children - #contains' do
12
- @element.should respond_to(:contains)
10
+ it 'has children' do
11
+ element.should respond_to(:contains)
13
12
  end
14
13
 
15
- it 'returns a collection of children - #contains' do
16
- @element.contains.is_a?(Array).should be_true
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
- before(:each) do
15
- @directory = clazz.new
16
- end
11
+ describe 'common behavior' do
17
12
 
18
- it 'cannot model a non-existent directory' do
19
- path = "#{@default_file_directory}/missing_directory"
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
- directory = CukeModeler::Directory.new(path)
21
+ describe 'unique behavior' do
28
22
 
29
- directory.name.should == 'temp_files'
30
- end
23
+ it 'has a name' do
24
+ expect(directory).to respond_to(:name)
25
+ end
31
26
 
32
- it 'knows the path of the directory that it is modeling' do
33
- path = "#{@default_file_directory}"
27
+ it 'derives its directory name from its path' do
28
+ directory.path = 'path/to/foo'
34
29
 
35
- directory = CukeModeler::Directory.new(path)
30
+ expect(directory.name).to eq('foo')
31
+ end
36
32
 
37
- directory.path.should == path
38
- end
33
+ it 'has a path' do
34
+ expect(directory).to respond_to(:path)
35
+ end
39
36
 
40
- it 'has feature files - #feature_files' do
41
- @directory.should respond_to(:feature_files)
42
- end
37
+ it 'can change its path' do
38
+ expect(directory).to respond_to(:path=)
43
39
 
44
- it 'can get and set its feature files - #feature_files, #feature_files=' do
45
- @directory.feature_files = :some_feature_files
46
- @directory.feature_files.should == :some_feature_files
47
- @directory.feature_files = :some_other_feature_files
48
- @directory.feature_files.should == :some_other_feature_files
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
- it 'knows how many feature files it has - #feature_file_count' do
52
- @directory.feature_files = [:file_1, :file_2, :file_3]
46
+ it 'knows the path of the directory that it is modeling' do
47
+ path = "#{@default_file_directory}"
53
48
 
54
- @directory.feature_file_count.should == 3
55
- end
49
+ directory = clazz.new(path)
56
50
 
57
- it 'has directories - #directories' do
58
- @directory.should respond_to(:directories)
59
- end
51
+ directory.path.should == path
52
+ end
60
53
 
61
- it 'can get and set its directories - #directories, #directories=' do
62
- @directory.directories = :some_directories
63
- @directory.directories.should == :some_directories
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
- it 'knows how many directories it has - #directory_count' do
69
- @directory.directories = [:directory_1, :directory_2, :directory_3]
58
+ it 'can change its feature files' do
59
+ expect(directory).to respond_to(:feature_files=)
70
60
 
71
- @directory.directory_count.should == 3
72
- end
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
- it 'starts with no feature files or directories' do
75
- @directory.feature_files.should == []
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
- it 'contains feature files and directories' do
80
- directories = [:directory_1, :directory_2, :directory_3]
81
- files = [:file_1, :file_2, :file_3]
82
- everything = files + directories
70
+ directory.feature_file_count.should == 3
71
+ end
83
72
 
84
- @directory.directories = directories
85
- @directory.feature_files = files
73
+ it 'has directories' do
74
+ directory.should respond_to(:directories)
75
+ end
86
76
 
87
- @directory.contains.should =~ everything
88
- end
77
+ it 'can change its directories' do
78
+ expect(directory).to respond_to(:directories=)
89
79
 
90
- context 'directory output edge cases' do
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 'is a String' do
93
- @directory.to_s.should be_a(String)
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
- it 'can output an empty directory' do
97
- expect { @directory.to_s }.to_not raise_error
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
- it_should_behave_like 'a nested element'
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
- it 'can be parsed from stand alone text' do
15
- source = "\"\"\"\nsome doc string\n\"\"\""
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
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_doc_string\.feature'/)
29
- end
20
+ describe 'unique behavior' do
30
21
 
31
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
32
- doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
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
- expect(raw_data.keys).to match_array([:type, :location, :content])
36
- expect(raw_data[:type]).to eq(:DocString)
37
- end
25
+ expect { @element = clazz.new(source) }.to_not raise_error
38
26
 
39
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
40
- doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
41
- raw_data = doc_string.raw_element
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
- expect(raw_data.keys).to match_array([:type, :location, :content])
44
- expect(raw_data[:type]).to eq(:DocString)
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
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
48
- doc_string = clazz.new("\"\"\"\nsome doc string\n\"\"\"")
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
- expect(raw_data.keys).to match_array(['value', 'content_type', 'line'])
52
- expect(raw_data['value']).to eq('some doc string')
53
- end
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
- before(:each) do
57
- @doc_string = clazz.new
58
- end
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
- it 'has a content type - #content_type' do
61
- @doc_string.should respond_to(:content_type)
62
- end
51
+ expect(raw_data.keys).to match_array([:type, :location, :content])
52
+ expect(raw_data[:type]).to eq(:DocString)
53
+ end
63
54
 
64
- it 'can get and set its content type - #content_type, #content_type=' do
65
- @doc_string.content_type = :some_content_type
66
- @doc_string.content_type.should == :some_content_type
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
- it 'starts with no content type' do
72
- @doc_string.content_type.should == nil
73
- end
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
- it 'has contents' do
76
- #todo Remove once Array contents is no longer supported
77
- @doc_string.should respond_to(:contents)
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
- it 'can get and set its contents' do
82
- #todo Remove once Array contents is no longer supported
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
- it 'starts with no contents' do
95
- #todo Remove once Array contents is no longer supported
96
- @doc_string.contents.should == []
97
- @doc_string.contents_text.should == ''
98
- end
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
- contents = doc_string.contents
76
+ it 'starts with no content type' do
77
+ doc_string.content_type.should == nil
78
+ end
106
79
 
107
- contents.is_a?(Array).should be_true
108
- contents.each do |line|
109
- line.is_a?(String).should be_true
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
- it 'stores its contents as a String' do
114
- source = "\"\"\"\nsome text\nsome more text\n\"\"\""
115
- doc_string = clazz.new(source)
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
- contents = doc_string.contents_text
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
- contents.is_a?(String).should be_true
120
- end
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
- context 'doc string output edge cases' do
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
- it 'is a String' do
125
- @doc_string.to_s.should be_a(String)
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 'can output an empty doc string' do
129
- expect { @doc_string.to_s }.to_not raise_error
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
- it 'can output a doc string that has only a content type' do
133
- @doc_string.content_type = 'some type'
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