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 prepopulated 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 take an argument' do
12
11
  (clazz.instance_method(:initialize).arity != 0).should be_true
@@ -4,23 +4,24 @@ shared_examples_for 'a raw 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 an underlying implementation representation - #raw_element' do
12
- @element.should respond_to(:raw_element)
10
+ it 'has an underlying implementation representation' do
11
+ element.should respond_to(:raw_element)
13
12
  end
14
13
 
15
- it 'can get and set its underlying implementation representation - #raw_element, #raw_element=' do
16
- @element.raw_element = :some_raw_element
17
- @element.raw_element.should == :some_raw_element
18
- @element.raw_element = :some_other_raw_element
19
- @element.raw_element.should == :some_other_raw_element
14
+ it 'can change its underlying implementation representation' do
15
+ expect(element).to respond_to(:raw_element=)
16
+
17
+ element.raw_element = :some_raw_element
18
+ element.raw_element.should == :some_raw_element
19
+ element.raw_element = :some_other_raw_element
20
+ element.raw_element.should == :some_other_raw_element
20
21
  end
21
22
 
22
23
  it 'starts with no underlying implementation representation' do
23
- @element.raw_element.should == nil
24
+ element.raw_element.should == nil
24
25
  end
25
26
 
26
27
  end
@@ -4,22 +4,25 @@ SimpleCov.command_name('Raw') unless RUBY_VERSION.to_s < '1.9.0'
4
4
 
5
5
  describe 'Raw, Unit' do
6
6
 
7
- nodule = CukeModeler::Raw
7
+ let(:nodule) { CukeModeler::Raw }
8
+ let(:element) { Object.new.extend(nodule) }
8
9
 
9
- before(:each) do
10
- @element = Object.new.extend(nodule)
11
- end
12
10
 
11
+ describe 'unique behavior' do
13
12
 
14
- it 'has a raw element - #raw_element' do
15
- @element.should respond_to(:raw_element)
16
- end
13
+ it 'has a raw element' do
14
+ element.should respond_to(:raw_element)
15
+ end
16
+
17
+ it 'can change its raw element' do
18
+ expect(element).to respond_to(:raw_element=)
19
+
20
+ element.raw_element = :some_raw_element
21
+ element.raw_element.should == :some_raw_element
22
+ element.raw_element = :some_other_raw_element
23
+ element.raw_element.should == :some_other_raw_element
24
+ end
17
25
 
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
26
  end
24
27
 
25
28
  end
@@ -5,80 +5,96 @@ SimpleCov.command_name('Row') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Row, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::Row }
8
+ let(:row) { 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 sourced element'
13
- it_should_behave_like 'a raw element'
14
10
 
15
- it 'can be parsed from stand alone text' do
16
- source = '| a | row |'
11
+ describe 'common behavior' do
17
12
 
18
- expect { @element = clazz.new(source) }.to_not raise_error
13
+ it_should_behave_like 'a nested element'
14
+ it_should_behave_like 'a bare bones element'
15
+ it_should_behave_like 'a prepopulated element'
16
+ it_should_behave_like 'a sourced element'
17
+ it_should_behave_like 'a raw element'
19
18
 
20
- # Sanity check in case instantiation failed in a non-explosive manner
21
- @element.cells.should == ['a', 'row']
22
19
  end
23
20
 
24
- it 'provides a descriptive filename when being parsed from stand alone text' do
25
- source = " |bad |row| text| \n @foo "
26
21
 
27
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_row\.feature'/)
28
- end
22
+ describe 'unique behavior' do
29
23
 
30
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
31
- example_row = clazz.new("| a | row |")
32
- raw_data = example_row.raw_element
24
+ it 'can be parsed from stand alone text' do
25
+ source = '| a | row |'
33
26
 
34
- expect(raw_data.keys).to match_array([:type, :location, :cells])
35
- expect(raw_data[:type]).to eq(:TableRow)
36
- end
27
+ expect { @element = clazz.new(source) }.to_not raise_error
37
28
 
38
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
39
- example_row = clazz.new("| a | row |")
40
- raw_data = example_row.raw_element
29
+ # Sanity check in case instantiation failed in a non-explosive manner
30
+ @element.cells.should == ['a', 'row']
31
+ end
41
32
 
42
- expect(raw_data.keys).to match_array([:type, :location, :cells])
43
- expect(raw_data[:type]).to eq('TableRow')
44
- end
33
+ it 'provides a descriptive filename when being parsed from stand alone text' do
34
+ source = " |bad |row| text| \n @foo "
45
35
 
46
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
47
- example_row = clazz.new("| a | row |")
48
- raw_data = example_row.raw_element
36
+ expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_row\.feature'/)
37
+ end
49
38
 
50
- expect(raw_data.keys).to match_array(['cells', 'line', 'id'])
51
- expect(raw_data['cells']).to eq(['a', 'row'])
52
- end
39
+ it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
40
+ example_row = clazz.new("| a | row |")
41
+ raw_data = example_row.raw_element
53
42
 
43
+ expect(raw_data.keys).to match_array([:type, :location, :cells])
44
+ expect(raw_data[:type]).to eq(:TableRow)
45
+ end
54
46
 
55
- before(:each) do
56
- @row = clazz.new
57
- end
47
+ it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
48
+ example_row = clazz.new("| a | row |")
49
+ raw_data = example_row.raw_element
58
50
 
59
- it 'has cells - #cells' do
60
- @row.should respond_to(:cells)
61
- end
51
+ expect(raw_data.keys).to match_array([:type, :location, :cells])
52
+ expect(raw_data[:type]).to eq('TableRow')
53
+ end
62
54
 
63
- it 'can get and set its cells - #cells, #cells=' do
64
- @row.cells = :some_cells
65
- @row.cells.should == :some_cells
66
- @row.cells = :some_other_cells
67
- @row.cells.should == :some_other_cells
68
- end
55
+ it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
56
+ example_row = clazz.new("| a | row |")
57
+ raw_data = example_row.raw_element
69
58
 
70
- it 'starts with no cells' do
71
- @row.cells.should == []
72
- end
59
+ expect(raw_data.keys).to match_array(['cells', 'line', 'id'])
60
+ expect(raw_data['cells']).to eq(['a', 'row'])
61
+ end
73
62
 
74
- context 'row output edge cases' do
63
+ it 'has cells' do
64
+ row.should respond_to(:cells)
65
+ end
66
+
67
+ it 'can change its cells' do
68
+ expect(row).to respond_to(:cells=)
69
+
70
+ row.cells = :some_cells
71
+ row.cells.should == :some_cells
72
+ row.cells = :some_other_cells
73
+ row.cells.should == :some_other_cells
74
+ end
75
75
 
76
- it 'is a String' do
77
- @row.to_s.should be_a(String)
76
+ it 'starts with no cells' do
77
+ row.cells.should == []
78
78
  end
79
79
 
80
- it 'can output an empty row' do
81
- expect { @row.to_s }.to_not raise_error
80
+ describe 'row output edge cases' do
81
+
82
+ it 'is a String' do
83
+ row.to_s.should be_a(String)
84
+ end
85
+
86
+
87
+ context 'a new row object' do
88
+
89
+ let(:row) { clazz.new }
90
+
91
+
92
+ it 'can output an empty row' do
93
+ expect { row.to_s }.to_not raise_error
94
+ end
95
+
96
+ end
97
+
82
98
  end
83
99
 
84
100
  end
@@ -5,96 +5,110 @@ SimpleCov.command_name('Scenario') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Scenario, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::Scenario }
8
+ let(:scenario) { 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
 
19
- it 'can be parsed from stand alone text' do
20
- source = 'Scenario: test scenario'
11
+ describe 'common behavior' do
21
12
 
22
- 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 test element'
20
+ it_should_behave_like 'a sourced element'
21
+ it_should_behave_like 'a raw element'
23
22
 
24
- # Sanity check in case instantiation failed in a non-explosive manner
25
- @element.name.should == 'test scenario'
26
23
  end
27
24
 
28
- it 'provides a descriptive filename when being parsed from stand alone text' do
29
- source = "bad scenario text \n Scenario:\n And a step\n @foo "
30
25
 
31
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_scenario\.feature'/)
32
- end
26
+ describe 'unique behavior' do
33
27
 
34
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
35
- scenario = clazz.new("Scenario: test scenario")
36
- raw_data = scenario.raw_element
28
+ it 'can be parsed from stand alone text' do
29
+ source = 'Scenario: test scenario'
37
30
 
38
- expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps])
39
- expect(raw_data[:type]).to eq(:Scenario)
40
- end
31
+ expect { @element = clazz.new(source) }.to_not raise_error
41
32
 
42
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
43
- scenario = clazz.new("Scenario: test scenario")
44
- raw_data = scenario.raw_element
33
+ # Sanity check in case instantiation failed in a non-explosive manner
34
+ @element.name.should == 'test scenario'
35
+ end
45
36
 
46
- expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps])
47
- expect(raw_data[:type]).to eq(:Scenario)
48
- end
37
+ it 'provides a descriptive filename when being parsed from stand alone text' do
38
+ source = "bad scenario text \n Scenario:\n And a step\n @foo "
49
39
 
50
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
51
- scenario = clazz.new("Scenario: test scenario")
52
- raw_data = scenario.raw_element
40
+ expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_scenario\.feature'/)
41
+ end
53
42
 
54
- expect(raw_data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type'])
55
- expect(raw_data['keyword']).to eq('Scenario')
56
- end
43
+ it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
44
+ scenario = clazz.new("Scenario: test scenario")
45
+ raw_data = scenario.raw_element
57
46
 
47
+ expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps])
48
+ expect(raw_data[:type]).to eq(:Scenario)
49
+ end
58
50
 
59
- before(:each) do
60
- @scenario = clazz.new
61
- end
51
+ it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
52
+ scenario = clazz.new("Scenario: test scenario")
53
+ raw_data = scenario.raw_element
62
54
 
63
- it 'contains only steps' do
64
- steps = [:step_1, :step_2]
65
- everything = steps
55
+ expect(raw_data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps])
56
+ expect(raw_data[:type]).to eq(:Scenario)
57
+ end
66
58
 
67
- @scenario.steps = steps
59
+ it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
60
+ scenario = clazz.new("Scenario: test scenario")
61
+ raw_data = scenario.raw_element
68
62
 
69
- @scenario.contains.should =~ everything
70
- end
63
+ expect(raw_data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type'])
64
+ expect(raw_data['keyword']).to eq('Scenario')
65
+ end
71
66
 
72
- context 'scenario output edge cases' do
67
+ it 'contains only steps' do
68
+ steps = [:step_1, :step_2]
69
+ everything = steps
73
70
 
74
- it 'is a String' do
75
- @scenario.to_s.should be_a(String)
76
- end
71
+ scenario.steps = steps
77
72
 
78
- it 'can output an empty scenario' do
79
- expect { @scenario.to_s }.to_not raise_error
73
+ scenario.contains.should =~ everything
80
74
  end
81
75
 
82
- it 'can output a scenario that has only a name' do
83
- @scenario.name = 'a name'
76
+ describe 'scenario output edge cases' do
84
77
 
85
- expect { @scenario.to_s }.to_not raise_error
86
- end
78
+ it 'is a String' do
79
+ scenario.to_s.should be_a(String)
80
+ end
87
81
 
88
- it 'can output a scenario that has only a description' do
89
- @scenario.description_text = 'a description'
90
82
 
91
- expect { @scenario.to_s }.to_not raise_error
92
- end
83
+ context 'a new scenario object' do
84
+
85
+ let(:scenario) { clazz.new }
86
+
87
+
88
+ it 'can output an empty scenario' do
89
+ expect { scenario.to_s }.to_not raise_error
90
+ end
91
+
92
+ it 'can output a scenario that has only a name' do
93
+ scenario.name = 'a name'
94
+
95
+ expect { scenario.to_s }.to_not raise_error
96
+ end
97
+
98
+ it 'can output a scenario that has only a description' do
99
+ scenario.description_text = 'a description'
100
+
101
+ expect { scenario.to_s }.to_not raise_error
102
+ end
103
+
104
+ it 'can output a scenario that has only tags' do
105
+ scenario.tags = ['a tag']
106
+
107
+ expect { scenario.to_s }.to_not raise_error
108
+ end
93
109
 
94
- it 'can output a scenario that has only a tags' do
95
- @scenario.tags = ['a tag']
110
+ end
96
111
 
97
- expect { @scenario.to_s }.to_not raise_error
98
112
  end
99
113
 
100
114
  end
@@ -4,14 +4,16 @@ SimpleCov.command_name('Sourceable') unless RUBY_VERSION.to_s < '1.9.0'
4
4
 
5
5
  describe 'Sourceable, Unit' do
6
6
 
7
- nodule = CukeModeler::Sourceable
7
+ let(:nodule) { CukeModeler::Sourceable }
8
+ let(:element) { Object.new.extend(nodule) }
8
9
 
9
- before(:each) do
10
- @element = Object.new.extend(nodule)
11
- end
12
10
 
13
- it 'has a source line - #source_line' do
14
- @element.should respond_to(:source_line)
11
+ describe 'unique behavior' do
12
+
13
+ it 'has a source line' do
14
+ element.should respond_to(:source_line)
15
+ end
16
+
15
17
  end
16
18
 
17
19
  end
@@ -4,17 +4,15 @@ shared_examples_for 'a sourced 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 }
10
8
 
11
9
 
12
- it 'has a source line - #source_line' do
13
- @element.should respond_to(:source_line)
10
+ it 'has a source line' do
11
+ element.should respond_to(:source_line)
14
12
  end
15
13
 
16
14
  it 'starts with no source line' do
17
- @element.source_line.should == nil
15
+ element.source_line.should == nil
18
16
  end
19
17
 
20
18
  end