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
@@ -5,15 +5,15 @@ SimpleCov.command_name('FeatureElement') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'FeatureElement, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::FeatureElement }
8
+ let(:element) { 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 prepopulated element'
12
- it_should_behave_like 'a bare bones element'
10
+ describe 'common behavior' do
13
11
 
12
+ it_should_behave_like 'a feature element'
13
+ it_should_behave_like 'a nested element'
14
+ it_should_behave_like 'a prepopulated element'
15
+ it_should_behave_like 'a bare bones element'
14
16
 
15
- before(:each) do
16
- @element = clazz.new
17
17
  end
18
18
 
19
19
  end
@@ -4,45 +4,49 @@ shared_examples_for 'a feature 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 a name - #name' do
12
- @element.should respond_to(:name)
10
+ it 'has a name' do
11
+ element.should respond_to(:name)
13
12
  end
14
13
 
15
- it 'can get and set its name - #name, #name=' do
16
- @element.name = :some_name
17
- @element.name.should == :some_name
18
- @element.name = :some_other_name
19
- @element.name.should == :some_other_name
14
+ it 'can change its name' do
15
+ expect(element).to respond_to(:name=)
16
+
17
+ element.name = :some_name
18
+ element.name.should == :some_name
19
+ element.name = :some_other_name
20
+ element.name.should == :some_other_name
20
21
  end
21
22
 
22
23
  it 'has a description' do
23
- @element.should respond_to(:description)
24
- @element.should respond_to(:description_text)
24
+ element.should respond_to(:description)
25
+ element.should respond_to(:description_text)
25
26
  end
26
27
 
27
28
  it 'can get and set its description' do
28
- @element.description = :some_description
29
- @element.description.should == :some_description
30
- @element.description = :some_other_description
31
- @element.description.should == :some_other_description
32
-
33
- @element.description_text = :some_description
34
- @element.description_text.should == :some_description
35
- @element.description_text = :some_other_description
36
- @element.description_text.should == :some_other_description
29
+ expect(element).to respond_to(:description=)
30
+ expect(element).to respond_to(:description_text=)
31
+
32
+ element.description = :some_description
33
+ element.description.should == :some_description
34
+ element.description = :some_other_description
35
+ element.description.should == :some_other_description
36
+
37
+ element.description_text = :some_description
38
+ element.description_text.should == :some_description
39
+ element.description_text = :some_other_description
40
+ element.description_text.should == :some_other_description
37
41
  end
38
42
 
39
43
  it 'starts with no name' do
40
- @element.name.should == ''
44
+ element.name.should == ''
41
45
  end
42
46
 
43
47
  it 'starts with no description' do
44
- @element.description.should == []
45
- @element.description_text.should == ''
48
+ element.description.should == []
49
+ element.description_text.should == ''
46
50
  end
47
51
 
48
52
  end
@@ -5,95 +5,105 @@ SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'FeatureFile, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::FeatureFile }
8
+ let(:feature_file) { 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
 
11
+ describe 'common behavior' do
14
12
 
15
- before(:each) do
16
- @feature_file = clazz.new
17
- end
18
-
19
- it 'cannot model a non-existent file' do
20
- path = "#{@default_file_directory}/missing_file.txt"
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'
21
17
 
22
- expect { CukeModeler::FeatureFile.new(path) }.to raise_error(ArgumentError)
23
18
  end
24
19
 
25
- it 'provides its own filename when being parsed' do
26
- path = "#{@default_file_directory}/#{@default_feature_file_name}"
27
- File.open(path, "w") { |file| file.puts 'bad feature text' }
28
20
 
29
- expect { clazz.new(path) }.to raise_error(/'#{path}'/)
30
- end
21
+ describe 'unique behavior' do
31
22
 
32
- it 'knows the name of the file that it is modeling' do
33
- path = "#{@default_file_directory}/#{@default_feature_file_name}"
34
- File.open(path, "w") { |file| file.puts "Feature:" }
23
+ it 'provides its own filename when being parsed' do
24
+ path = "#{@default_file_directory}/#{@default_feature_file_name}"
25
+ File.open(path, "w") { |file| file.puts 'bad feature text' }
35
26
 
36
- feature = CukeModeler::FeatureFile.new(path)
27
+ expect { clazz.new(path) }.to raise_error(/'#{path}'/)
28
+ end
37
29
 
38
- feature.name.should == @default_feature_file_name
39
- end
30
+ it 'knows the name of the file that it is modeling' do
31
+ path = "#{@default_file_directory}/#{@default_feature_file_name}"
32
+ File.open(path, "w") { |file| file.puts "Feature:" }
40
33
 
41
- it 'knows the path of the file that it is modeling' do
42
- path = "#{@default_file_directory}/#{@default_feature_file_name}"
43
- File.open(path, "w") { |file| file.puts "Feature:" }
34
+ feature = clazz.new(path)
44
35
 
45
- file = CukeModeler::FeatureFile.new(path)
36
+ feature.name.should == @default_feature_file_name
37
+ end
46
38
 
47
- file.path.should == path
48
- end
39
+ it 'knows the path of the file that it is modeling' do
40
+ path = "#{@default_file_directory}/#{@default_feature_file_name}"
41
+ File.open(path, "w") { |file| file.puts "Feature:" }
49
42
 
50
- it 'has features - #features' do
51
- @feature_file.should respond_to(:features)
52
- end
43
+ file = clazz.new(path)
53
44
 
54
- it 'can get and set its features - #features, #features=' do
55
- @feature_file.features = :some_features
56
- @feature_file.features.should == :some_features
57
- @feature_file.features = :some_other_features
58
- @feature_file.features.should == :some_other_features
59
- end
45
+ file.path.should == path
46
+ end
60
47
 
61
- it 'knows how many features it has - #feature_count' do
62
- @feature_file.features = [:a_feature]
63
- @feature_file.feature_count.should == 1
64
- @feature_file.features = []
65
- @feature_file.feature_count.should == 0
66
- end
48
+ it 'has features' do
49
+ feature_file.should respond_to(:features)
50
+ end
67
51
 
68
- it 'starts with no features' do
69
- @feature_file.features.should == []
70
- end
52
+ it 'can change its features' do
53
+ expect(feature_file).to respond_to(:features=)
54
+
55
+ feature_file.features = :some_features
56
+ feature_file.features.should == :some_features
57
+ feature_file.features = :some_other_features
58
+ feature_file.features.should == :some_other_features
59
+ end
71
60
 
72
- it 'contains features' do
73
- features = [:a_feature]
74
- everything = features
61
+ it 'knows how many features it has' do
62
+ feature_file.features = [:a_feature]
63
+ feature_file.feature_count.should == 1
64
+ feature_file.features = []
65
+ feature_file.feature_count.should == 0
66
+ end
75
67
 
76
- @feature_file.features = features
68
+ it 'starts with no features' do
69
+ feature_file.features.should == []
70
+ end
77
71
 
78
- @feature_file.contains.should =~ everything
79
- end
72
+ it 'contains features' do
73
+ features = [:a_feature]
74
+ everything = features
80
75
 
81
- it 'can easily access its sole feature' do
82
- @feature_file.features = []
83
- @feature_file.feature.should be_nil
76
+ feature_file.features = features
84
77
 
85
- @feature_file.features = [:a_feature]
86
- @feature_file.feature.should == :a_feature
87
- end
78
+ feature_file.contains.should =~ everything
79
+ end
88
80
 
89
- context 'feature file output edge cases' do
81
+ it 'can easily access its sole feature' do
82
+ feature_file.features = []
83
+ feature_file.feature.should be_nil
90
84
 
91
- it 'is a String' do
92
- @feature_file.to_s.should be_a(String)
85
+ feature_file.features = [:a_feature]
86
+ feature_file.feature.should == :a_feature
93
87
  end
94
88
 
95
- it 'can output an empty feature file' do
96
- expect { @feature_file.to_s }.to_not raise_error
89
+ describe 'feature file output edge cases' do
90
+
91
+ it 'is a String' do
92
+ feature_file.to_s.should be_a(String)
93
+ end
94
+
95
+
96
+ context 'a new feature file object' do
97
+
98
+ let(:feature_file) { clazz.new }
99
+
100
+
101
+ it 'can output an empty feature file' do
102
+ expect { feature_file.to_s }.to_not raise_error
103
+ end
104
+
105
+ end
106
+
97
107
  end
98
108
 
99
109
  end
@@ -5,159 +5,193 @@ SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Feature, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::Feature }
8
+ let(:feature) { 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 sourced element'
16
- it_should_behave_like 'a raw element'
17
-
18
- before(:each) do
19
- @feature = clazz.new
20
- end
21
10
 
22
- it 'can be parsed from stand alone text' do
23
- source = 'Feature: test feature'
11
+ describe 'common behavior' do
24
12
 
25
- expect { @element = clazz.new(source) }.to_not raise_error
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 sourced element'
20
+ it_should_behave_like 'a raw element'
26
21
 
27
- # Sanity check in case instantiation failed in a non-explosive manner
28
- @element.name.should == 'test feature'
29
22
  end
30
23
 
31
- it 'provides a descriptive filename when being parsed from stand alone text' do
32
- source = 'bad feature text'
33
24
 
34
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_feature\.feature'/)
35
- end
25
+ describe 'unique behavior' do
36
26
 
37
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
38
- feature = clazz.new('Feature: test feature')
39
- raw_data = feature.raw_element
27
+ it 'can be parsed from stand alone text' do
28
+ source = 'Feature: test feature'
40
29
 
41
- expect(raw_data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :children])
42
- expect(raw_data[:type]).to eq(:Feature)
43
- end
30
+ expect { @element = clazz.new(source) }.to_not raise_error
44
31
 
45
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
46
- feature = clazz.new('Feature: test feature')
47
- raw_data = feature.raw_element
32
+ # Sanity check in case instantiation failed in a non-explosive manner
33
+ @element.name.should == 'test feature'
34
+ end
48
35
 
49
- expect(raw_data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :scenarioDefinitions, :comments])
50
- expect(raw_data[:type]).to eq(:Feature)
51
- end
36
+ it 'provides a descriptive filename when being parsed from stand alone text' do
37
+ source = 'bad feature text'
52
38
 
53
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
54
- feature = clazz.new('Feature: test feature')
55
- raw_data = feature.raw_element
39
+ expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_feature\.feature'/)
40
+ end
56
41
 
57
- expect(raw_data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'uri'])
58
- expect(raw_data['keyword']).to eq('Feature')
59
- end
42
+ it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
43
+ feature = clazz.new('Feature: test feature')
44
+ raw_data = feature.raw_element
60
45
 
61
- it 'will complain about unknown element types' do
62
- parsed_element = {'description' => '',
63
- 'elements' => [{'keyword' => 'Scenario', 'description' => ''},
64
- {'keyword' => 'New Type', 'description' => ''}]}
46
+ expect(raw_data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :children])
47
+ expect(raw_data[:type]).to eq(:Feature)
48
+ end
65
49
 
66
- expect { clazz.new(parsed_element) }.to raise_error(ArgumentError)
67
- end
50
+ it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
51
+ feature = clazz.new('Feature: test feature')
52
+ raw_data = feature.raw_element
68
53
 
69
- it 'has a background - #background' do
70
- @feature.should respond_to(:background)
71
- end
54
+ expect(raw_data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :scenarioDefinitions, :comments])
55
+ expect(raw_data[:type]).to eq(:Feature)
56
+ end
72
57
 
73
- it 'can get and set its background - #background, #background=' do
74
- @feature.background = :some_background
75
- @feature.background.should == :some_background
76
- @feature.background = :some_other_background
77
- @feature.background.should == :some_other_background
78
- end
58
+ it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
59
+ feature = clazz.new('Feature: test feature')
60
+ raw_data = feature.raw_element
79
61
 
80
- it 'knows whether or not it presently has a background - has_background?' do
81
- @feature.background = :a_background
82
- @feature.has_background?.should be_true
83
- @feature.background = nil
84
- @feature.has_background?.should be_false
85
- end
62
+ expect(raw_data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'uri'])
63
+ expect(raw_data['keyword']).to eq('Feature')
64
+ end
86
65
 
87
- it 'has tests - #tests' do
88
- @feature.should respond_to(:tests)
89
- end
66
+ it 'will complain about unknown element types' do
67
+ parsed_element = {'description' => '',
68
+ 'elements' => [{'keyword' => 'Scenario', 'description' => ''},
69
+ {'keyword' => 'New Type', 'description' => ''}]}
90
70
 
91
- it 'can get and set its tests - #tests, #tests=' do
92
- @feature.tests = :some_tests
93
- @feature.tests.should == :some_tests
94
- @feature.tests = :some_other_tests
95
- @feature.tests.should == :some_other_tests
96
- end
71
+ expect { clazz.new(parsed_element) }.to raise_error(ArgumentError)
72
+ end
97
73
 
98
- it 'knows how many tests it has - #test_count' do
99
- @feature.tests = []
100
- @feature.test_count.should == 0
101
- @feature.tests = [:test_1, :test_2]
102
- @feature.test_count.should == 2
103
- end
74
+ it 'has a background' do
75
+ feature.should respond_to(:background)
76
+ end
104
77
 
105
- it 'contains backgrounds and tests' do
106
- tests = [:test_1, :test_2]
107
- background = :a_background
108
- everything = [background] + tests
78
+ it 'can change its background' do
79
+ expect(feature).to respond_to(:background=)
109
80
 
110
- @feature.background = background
111
- @feature.tests = tests
81
+ feature.background = :some_background
82
+ feature.background.should == :some_background
83
+ feature.background = :some_other_background
84
+ feature.background.should == :some_other_background
85
+ end
112
86
 
113
- @feature.contains.should =~ everything
114
- end
87
+ it 'knows whether or not it presently has a background - has_background?' do
88
+ feature.background = :a_background
89
+ feature.has_background?.should be_true
90
+ feature.background = nil
91
+ feature.has_background?.should be_false
92
+ end
115
93
 
116
- it 'contains a background only if one is present' do
117
- tests = [:test_1, :test_2]
118
- background = nil
119
- everything = tests
94
+ it 'has tests' do
95
+ feature.should respond_to(:tests)
96
+ end
120
97
 
121
- @feature.background = background
122
- @feature.tests = tests
98
+ it 'can change its tests' do
99
+ expect(feature).to respond_to(:tests=)
123
100
 
124
- @feature.contains.should =~ everything
125
- end
101
+ feature.tests = :some_tests
102
+ feature.tests.should == :some_tests
103
+ feature.tests = :some_other_tests
104
+ feature.tests.should == :some_other_tests
105
+ end
126
106
 
127
- it 'starts with no background' do
128
- @feature.background.should == nil
129
- end
107
+ it 'knows how many tests it has' do
108
+ feature.tests = []
109
+ feature.test_count.should == 0
110
+ feature.tests = [:test_1, :test_2]
111
+ feature.test_count.should == 2
112
+ end
130
113
 
131
- it 'starts with no tests' do
132
- @feature.tests.should == []
133
- end
114
+ it 'can selectively access its scenarios' do
115
+ expect(feature).to respond_to(:scenarios)
116
+ end
117
+
118
+ it 'can selectively access its outlines' do
119
+ expect(feature).to respond_to(:outlines)
120
+ end
134
121
 
135
- context 'feature output edge cases' do
122
+ it 'finds no scenarios or outlines when it has no tests' do
123
+ feature.tests = []
136
124
 
137
- it 'is a String' do
138
- @feature.to_s.should be_a(String)
125
+ expect(feature.scenarios).to be_empty
126
+ expect(feature.outlines).to be_empty
139
127
  end
140
128
 
141
- it 'can output an empty feature' do
142
- expect { @feature.to_s }.to_not raise_error
129
+ it 'contains backgrounds and tests' do
130
+ tests = [:test_1, :test_2]
131
+ background = :a_background
132
+ everything = [background] + tests
133
+
134
+ feature.background = background
135
+ feature.tests = tests
136
+
137
+ feature.contains.should =~ everything
143
138
  end
144
139
 
145
- it 'can output a feature that has only a name' do
146
- @feature.name = 'a name'
140
+ it 'contains a background only if one is present' do
141
+ tests = [:test_1, :test_2]
142
+ background = nil
143
+ everything = tests
147
144
 
148
- expect { @feature.to_s }.to_not raise_error
145
+ feature.background = background
146
+ feature.tests = tests
147
+
148
+ feature.contains.should =~ everything
149
149
  end
150
150
 
151
- it 'can output a feature that has only a description' do
152
- @feature.description_text = 'a description'
151
+ it 'starts with no background' do
152
+ feature.background.should == nil
153
+ end
153
154
 
154
- expect { @feature.to_s }.to_not raise_error
155
+ it 'starts with no tests' do
156
+ feature.tests.should == []
155
157
  end
156
158
 
157
- it 'can output a feature that has only a tags' do
158
- @feature.tags = ['a tag']
159
+ describe 'feature output edge cases' do
160
+
161
+ it 'is a String' do
162
+ feature.to_s.should be_a(String)
163
+ end
164
+
165
+
166
+ context 'a new feature object' do
167
+
168
+ let(:feature) { clazz.new }
169
+
170
+
171
+ it 'can output an empty feature' do
172
+ expect { feature.to_s }.to_not raise_error
173
+ end
174
+
175
+ it 'can output a feature that has only a name' do
176
+ feature.name = 'a name'
177
+
178
+ expect { feature.to_s }.to_not raise_error
179
+ end
180
+
181
+ it 'can output a feature that has only a description' do
182
+ feature.description_text = 'a description'
183
+
184
+ expect { feature.to_s }.to_not raise_error
185
+ end
186
+
187
+ it 'can output a feature that has only tags' do
188
+ feature.tags = ['a tag']
189
+
190
+ expect { feature.to_s }.to_not raise_error
191
+ end
192
+
193
+ end
159
194
 
160
- expect { @feature.to_s }.to_not raise_error
161
195
  end
162
196
 
163
197
  end