cuke_modeler 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.simplecov +8 -0
  4. data/Gemfile +4 -0
  5. data/History.rdoc +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +73 -0
  8. data/Rakefile +38 -0
  9. data/cuke_modeler.gemspec +29 -0
  10. data/features/analysis/test_comparison.feature +123 -0
  11. data/features/analysis/test_manipulation.feature +37 -0
  12. data/features/modeling/background_modeling.feature +75 -0
  13. data/features/modeling/background_output.feature +130 -0
  14. data/features/modeling/directory_modeling.feature +120 -0
  15. data/features/modeling/directory_output.feature +13 -0
  16. data/features/modeling/doc_string_modeling.feature +63 -0
  17. data/features/modeling/doc_string_output.feature +71 -0
  18. data/features/modeling/example_modeling.feature +111 -0
  19. data/features/modeling/example_output.feature +192 -0
  20. data/features/modeling/feature_file_modeling.feature +64 -0
  21. data/features/modeling/feature_file_output.feature +13 -0
  22. data/features/modeling/feature_modeling.feature +164 -0
  23. data/features/modeling/feature_output.feature +244 -0
  24. data/features/modeling/outline_modeling.feature +100 -0
  25. data/features/modeling/outline_output.feature +197 -0
  26. data/features/modeling/row_modeling.feature +77 -0
  27. data/features/modeling/row_output.feature +27 -0
  28. data/features/modeling/scenario_modeling.feature +89 -0
  29. data/features/modeling/scenario_output.feature +147 -0
  30. data/features/modeling/step_modeling.feature +85 -0
  31. data/features/modeling/step_output.feature +52 -0
  32. data/features/modeling/table_modeling.feature +52 -0
  33. data/features/modeling/table_output.feature +42 -0
  34. data/features/modeling/table_row_modeling.feature +67 -0
  35. data/features/modeling/table_row_output.feature +27 -0
  36. data/features/modeling/tag_modeling.feature +58 -0
  37. data/features/modeling/tag_output.feature +16 -0
  38. data/features/step_definitions/action_steps.rb +3 -0
  39. data/features/step_definitions/background_steps.rb +81 -0
  40. data/features/step_definitions/directory_steps.rb +52 -0
  41. data/features/step_definitions/doc_string_steps.rb +63 -0
  42. data/features/step_definitions/feature_file_steps.rb +41 -0
  43. data/features/step_definitions/feature_steps.rb +96 -0
  44. data/features/step_definitions/outline_steps.rb +252 -0
  45. data/features/step_definitions/setup_steps.rb +50 -0
  46. data/features/step_definitions/spec_steps.rb +18 -0
  47. data/features/step_definitions/step_steps.rb +159 -0
  48. data/features/step_definitions/table_steps.rb +54 -0
  49. data/features/step_definitions/tag_steps.rb +61 -0
  50. data/features/step_definitions/test_steps.rb +114 -0
  51. data/features/step_definitions/verification_steps.rb +9 -0
  52. data/features/support/env.rb +27 -0
  53. data/features/support/transforms.rb +3 -0
  54. data/lib/cuke_modeler.rb +29 -0
  55. data/lib/cuke_modeler/background.rb +38 -0
  56. data/lib/cuke_modeler/containing.rb +18 -0
  57. data/lib/cuke_modeler/directory.rb +86 -0
  58. data/lib/cuke_modeler/doc_string.rb +87 -0
  59. data/lib/cuke_modeler/example.rb +184 -0
  60. data/lib/cuke_modeler/feature.rb +147 -0
  61. data/lib/cuke_modeler/feature_element.rb +73 -0
  62. data/lib/cuke_modeler/feature_file.rb +77 -0
  63. data/lib/cuke_modeler/nested.rb +34 -0
  64. data/lib/cuke_modeler/outline.rb +68 -0
  65. data/lib/cuke_modeler/parsing.rb +32 -0
  66. data/lib/cuke_modeler/raw.rb +20 -0
  67. data/lib/cuke_modeler/row.rb +64 -0
  68. data/lib/cuke_modeler/scenario.rb +45 -0
  69. data/lib/cuke_modeler/sourceable.rb +20 -0
  70. data/lib/cuke_modeler/step.rb +214 -0
  71. data/lib/cuke_modeler/table.rb +90 -0
  72. data/lib/cuke_modeler/table_row.rb +64 -0
  73. data/lib/cuke_modeler/tag.rb +62 -0
  74. data/lib/cuke_modeler/taggable.rb +54 -0
  75. data/lib/cuke_modeler/test_element.rb +77 -0
  76. data/lib/cuke_modeler/version.rb +3 -0
  77. data/lib/cuke_modeler/world.rb +113 -0
  78. data/spec/integration/background_integration_spec.rb +72 -0
  79. data/spec/integration/directory_integration_spec.rb +48 -0
  80. data/spec/integration/doc_string_integration_spec.rb +66 -0
  81. data/spec/integration/example_integration_spec.rb +94 -0
  82. data/spec/integration/feature_file_integration_spec.rb +44 -0
  83. data/spec/integration/feature_integration_spec.rb +152 -0
  84. data/spec/integration/outline_integration_spec.rb +92 -0
  85. data/spec/integration/scenario_integration_spec.rb +80 -0
  86. data/spec/integration/step_integration_spec.rb +184 -0
  87. data/spec/integration/table_integration_spec.rb +86 -0
  88. data/spec/integration/table_row_integration_spec.rb +68 -0
  89. data/spec/integration/tag_integration_spec.rb +67 -0
  90. data/spec/integration/world_integration_spec.rb +13 -0
  91. data/spec/spec_helper.rb +30 -0
  92. data/spec/unit/background_unit_spec.rb +55 -0
  93. data/spec/unit/bare_bones_unit_specs.rb +13 -0
  94. data/spec/unit/containing_element_unit_specs.rb +17 -0
  95. data/spec/unit/directory_unit_spec.rb +103 -0
  96. data/spec/unit/doc_string_unit_spec.rb +109 -0
  97. data/spec/unit/example_unit_spec.rb +251 -0
  98. data/spec/unit/feature_element_unit_spec.rb +19 -0
  99. data/spec/unit/feature_element_unit_specs.rb +46 -0
  100. data/spec/unit/feature_file_unit_spec.rb +94 -0
  101. data/spec/unit/feature_unit_spec.rb +135 -0
  102. data/spec/unit/nested_element_unit_specs.rb +36 -0
  103. data/spec/unit/nested_unit_spec.rb +37 -0
  104. data/spec/unit/outline_unit_spec.rb +91 -0
  105. data/spec/unit/parsing_unit_spec.rb +21 -0
  106. data/spec/unit/prepopulated_unit_specs.rb +13 -0
  107. data/spec/unit/raw_element_unit_specs.rb +24 -0
  108. data/spec/unit/raw_unit_spec.rb +25 -0
  109. data/spec/unit/row_unit_spec.rb +55 -0
  110. data/spec/unit/scenario_unit_spec.rb +71 -0
  111. data/spec/unit/sourceable_unit_spec.rb +17 -0
  112. data/spec/unit/sourced_element_unit_specs.rb +18 -0
  113. data/spec/unit/step_unit_spec.rb +259 -0
  114. data/spec/unit/table_row_unit_spec.rb +55 -0
  115. data/spec/unit/table_unit_spec.rb +96 -0
  116. data/spec/unit/tag_unit_spec.rb +51 -0
  117. data/spec/unit/taggable_unit_spec.rb +78 -0
  118. data/spec/unit/tagged_element_unit_specs.rb +63 -0
  119. data/spec/unit/test_element_unit_spec.rb +40 -0
  120. data/spec/unit/test_element_unit_specs.rb +31 -0
  121. data/spec/unit/world_unit_spec.rb +130 -0
  122. metadata +364 -0
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('FeatureElement') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'FeatureElement, Unit' do
6
+
7
+ clazz = CukeModeler::FeatureElement
8
+
9
+ it_should_behave_like 'a feature element', clazz
10
+ it_should_behave_like 'a nested element', clazz
11
+ it_should_behave_like 'a prepopulated element', clazz
12
+ it_should_behave_like 'a bare bones element', clazz
13
+
14
+
15
+ before(:each) do
16
+ @element = clazz.new
17
+ end
18
+
19
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a feature element' do |clazz|
4
+
5
+ before(:each) do
6
+ @element = clazz.new
7
+ end
8
+
9
+ it 'has a name - #name' do
10
+ @element.should respond_to(:name)
11
+ end
12
+
13
+ it 'can get and set its name - #name, #name=' do
14
+ @element.name = :some_name
15
+ @element.name.should == :some_name
16
+ @element.name = :some_other_name
17
+ @element.name.should == :some_other_name
18
+ end
19
+
20
+ it 'has a description' do
21
+ @element.should respond_to(:description)
22
+ @element.should respond_to(:description_text)
23
+ end
24
+
25
+ it 'can get and set its description' do
26
+ @element.description = :some_description
27
+ @element.description.should == :some_description
28
+ @element.description = :some_other_description
29
+ @element.description.should == :some_other_description
30
+
31
+ @element.description_text = :some_description
32
+ @element.description_text.should == :some_description
33
+ @element.description_text = :some_other_description
34
+ @element.description_text.should == :some_other_description
35
+ end
36
+
37
+ it 'starts with no name' do
38
+ @element.name.should == ''
39
+ end
40
+
41
+ it 'starts with no description' do
42
+ @element.description.should == []
43
+ @element.description_text.should == ''
44
+ end
45
+
46
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'FeatureFile, Unit' do
6
+
7
+ clazz = CukeModeler::FeatureFile
8
+
9
+ it_should_behave_like 'a nested element', clazz
10
+ it_should_behave_like 'a containing element', clazz
11
+ it_should_behave_like 'a bare bones element', clazz
12
+ it_should_behave_like 'a prepopulated element', clazz
13
+
14
+
15
+ before(:each) do
16
+ @feature_file = clazz.new
17
+ end
18
+
19
+ it 'cannot model a non-existent directory' do
20
+ path = "#{@default_file_directory}/missing_file.txt"
21
+
22
+ expect { CukeModeler::FeatureFile.new(path) }.to raise_error(ArgumentError)
23
+ end
24
+
25
+ it 'knows the name of the file that it is modeling' do
26
+ path = "#{@default_file_directory}/#{@default_feature_file_name}"
27
+ File.open(path, "w") {}
28
+
29
+ feature = CukeModeler::FeatureFile.new(path)
30
+
31
+ feature.name.should == @default_feature_file_name
32
+ end
33
+
34
+ it 'knows the path of the file that it is modeling' do
35
+ path = "#{@default_file_directory}/#{@default_feature_file_name}"
36
+ File.open(path, "w") {}
37
+
38
+ directory = CukeModeler::FeatureFile.new(path)
39
+
40
+ directory.path.should == path
41
+ end
42
+
43
+ it 'has features - #features' do
44
+ @feature_file.should respond_to(:features)
45
+ end
46
+
47
+ it 'can get and set its features - #features, #features=' do
48
+ @feature_file.features = :some_features
49
+ @feature_file.features.should == :some_features
50
+ @feature_file.features = :some_other_features
51
+ @feature_file.features.should == :some_other_features
52
+ end
53
+
54
+ it 'knows how many features it has - #feature_count' do
55
+ @feature_file.features = [:a_feature]
56
+ @feature_file.feature_count.should == 1
57
+ @feature_file.features = []
58
+ @feature_file.feature_count.should == 0
59
+ end
60
+
61
+ it 'starts with no features' do
62
+ @feature_file.features.should == []
63
+ end
64
+
65
+ it 'contains features' do
66
+ features = [:a_feature]
67
+ everything = features
68
+
69
+ @feature_file.features = features
70
+
71
+ @feature_file.contains.should =~ everything
72
+ end
73
+
74
+ it 'can easily access its sole feature' do
75
+ @feature_file.features = []
76
+ @feature_file.feature.should be_nil
77
+
78
+ @feature_file.features = [:a_feature]
79
+ @feature_file.feature.should == :a_feature
80
+ end
81
+
82
+ context 'feature file output edge cases' do
83
+
84
+ it 'is a String' do
85
+ @feature_file.to_s.should be_a(String)
86
+ end
87
+
88
+ it 'can output an empty feature file' do
89
+ expect { @feature_file.to_s }.to_not raise_error
90
+ end
91
+
92
+ end
93
+
94
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Feature, Unit' do
6
+
7
+ clazz = CukeModeler::Feature
8
+
9
+ it_should_behave_like 'a feature element', clazz
10
+ it_should_behave_like 'a nested element', clazz
11
+ it_should_behave_like 'a containing element', clazz
12
+ it_should_behave_like 'a tagged element', clazz
13
+ it_should_behave_like 'a bare bones element', clazz
14
+ it_should_behave_like 'a prepopulated element', clazz
15
+ it_should_behave_like 'a sourced element', clazz
16
+ it_should_behave_like 'a raw element', clazz
17
+
18
+ before(:each) do
19
+ @feature = clazz.new
20
+ end
21
+
22
+ it 'can be parsed from stand alone text' do
23
+ source = 'Feature: test feature'
24
+
25
+ expect { @element = clazz.new(source) }.to_not raise_error
26
+
27
+ # Sanity check in case instantiation failed in a non-explosive manner
28
+ @element.name.should == 'test feature'
29
+ end
30
+
31
+ it 'will complain about unknown element types' do
32
+ parsed_element = {'description' => '',
33
+ 'elements' => [{'keyword' => 'Scenario', 'description' => ''},
34
+ {'keyword' => 'New Type', 'description' => ''}]}
35
+
36
+ expect { clazz.new(parsed_element) }.to raise_error(ArgumentError)
37
+ end
38
+
39
+ it 'has a background - #background' do
40
+ @feature.should respond_to(:background)
41
+ end
42
+
43
+ it 'can get and set its background - #background, #background=' do
44
+ @feature.background = :some_background
45
+ @feature.background.should == :some_background
46
+ @feature.background = :some_other_background
47
+ @feature.background.should == :some_other_background
48
+ end
49
+
50
+ it 'knows whether or not it presently has a background - has_background?' do
51
+ @feature.background = :a_background
52
+ @feature.has_background?.should be_true
53
+ @feature.background = nil
54
+ @feature.has_background?.should be_false
55
+ end
56
+
57
+ it 'has tests - #tests' do
58
+ @feature.should respond_to(:tests)
59
+ end
60
+
61
+ it 'can get and set its tests - #tests, #tests=' do
62
+ @feature.tests = :some_tests
63
+ @feature.tests.should == :some_tests
64
+ @feature.tests = :some_other_tests
65
+ @feature.tests.should == :some_other_tests
66
+ end
67
+
68
+ it 'knows how many tests it has - #test_count' do
69
+ @feature.tests = []
70
+ @feature.test_count.should == 0
71
+ @feature.tests = [:test_1, :test_2]
72
+ @feature.test_count.should == 2
73
+ end
74
+
75
+ it 'contains backgrounds and tests' do
76
+ tests = [:test_1, :test_2]
77
+ background = :a_background
78
+ everything = [background] + tests
79
+
80
+ @feature.background = background
81
+ @feature.tests = tests
82
+
83
+ @feature.contains.should =~ everything
84
+ end
85
+
86
+ it 'contains a background only if one is present' do
87
+ tests = [:test_1, :test_2]
88
+ background = nil
89
+ everything = tests
90
+
91
+ @feature.background = background
92
+ @feature.tests = tests
93
+
94
+ @feature.contains.should =~ everything
95
+ end
96
+
97
+ it 'starts with no background' do
98
+ @feature.background.should == nil
99
+ end
100
+
101
+ it 'starts with no tests' do
102
+ @feature.tests.should == []
103
+ end
104
+
105
+ context 'feature output edge cases' do
106
+
107
+ it 'is a String' do
108
+ @feature.to_s.should be_a(String)
109
+ end
110
+
111
+ it 'can output an empty feature' do
112
+ expect { @feature.to_s }.to_not raise_error
113
+ end
114
+
115
+ it 'can output a feature that has only a name' do
116
+ @feature.name = 'a name'
117
+
118
+ expect { @feature.to_s }.to_not raise_error
119
+ end
120
+
121
+ it 'can output a feature that has only a description' do
122
+ @feature.description_text = 'a description'
123
+
124
+ expect { @feature.to_s }.to_not raise_error
125
+ end
126
+
127
+ it 'can output a feature that has only a tags' do
128
+ @feature.tags = ['a tag']
129
+
130
+ expect { @feature.to_s }.to_not raise_error
131
+ end
132
+
133
+ end
134
+
135
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a nested element' do |clazz|
4
+
5
+ before(:each) do
6
+ @nested_element = clazz.new
7
+ end
8
+
9
+ it 'has a parent element - #parent_element' do
10
+ @nested_element.should respond_to(:parent_element)
11
+ end
12
+
13
+ it 'can get and set its parent element - #parent_element, #parent_element=' do
14
+ @nested_element.parent_element = :some_parent_element
15
+ @nested_element.parent_element.should == :some_parent_element
16
+ @nested_element.parent_element = :some_other_parent_element
17
+ @nested_element.parent_element.should == :some_other_parent_element
18
+ end
19
+
20
+ it 'starts with no parent element' do
21
+ @nested_element.parent_element.should == nil
22
+ end
23
+
24
+ it 'has access to its ancestors' do
25
+ @nested_element.should respond_to(:get_ancestor)
26
+ end
27
+
28
+ it 'gets an ancestor based on type' do
29
+ (clazz.instance_method(:get_ancestor).arity == 1).should be_true
30
+ end
31
+
32
+ it 'raises and exception if an unknown ancestor type is requested' do
33
+ expect { @nested_element.get_ancestor(:bad_ancestor_type) }.to raise_exception(ArgumentError)
34
+ end
35
+
36
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Nested') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Nested, Unit' do
6
+
7
+ nodule = CukeModeler::Nested
8
+
9
+ before(:each) do
10
+ @nested_element = Object.new.extend(nodule)
11
+ end
12
+
13
+
14
+ it 'has a parent element - #parent_element' do
15
+ @nested_element.should respond_to(:parent_element)
16
+ end
17
+
18
+ it 'can get and set its parent element - #parent_element, #parent_element=' do
19
+ @nested_element.parent_element = :some_parent_element
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
24
+
25
+ it 'has access to its ancestors' do
26
+ @nested_element.should respond_to(:get_ancestor)
27
+ end
28
+
29
+ it 'gets an ancestor based on type' do
30
+ (nodule.instance_method(:get_ancestor).arity == 1).should be_true
31
+ end
32
+
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
+ end
36
+
37
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Outline') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Outline, Unit' do
6
+
7
+ clazz = CukeModeler::Outline
8
+
9
+ it_should_behave_like 'a feature element', clazz
10
+ it_should_behave_like 'a nested element', clazz
11
+ it_should_behave_like 'a containing element', clazz
12
+ it_should_behave_like 'a tagged element', clazz
13
+ it_should_behave_like 'a bare bones element', clazz
14
+ it_should_behave_like 'a prepopulated element', clazz
15
+ it_should_behave_like 'a test element', clazz
16
+ it_should_behave_like 'a sourced element', clazz
17
+ it_should_behave_like 'a raw element', clazz
18
+
19
+
20
+ it 'can be parsed from stand alone text' do
21
+ source = 'Scenario Outline: test outline'
22
+
23
+ expect { @element = clazz.new(source) }.to_not raise_error
24
+
25
+ # Sanity check in case instantiation failed in a non-explosive manner
26
+ @element.name.should == 'test outline'
27
+ end
28
+
29
+
30
+ before(:each) do
31
+ @outline = clazz.new
32
+ end
33
+
34
+
35
+ it 'has examples - #examples' do
36
+ @outline.should respond_to(:examples)
37
+ end
38
+
39
+ it 'can get and set its examples - #examples, #examples=' do
40
+ @outline.examples = :some_examples
41
+ @outline.examples.should == :some_examples
42
+ @outline.examples = :some_other_examples
43
+ @outline.examples.should == :some_other_examples
44
+ end
45
+
46
+ it 'starts with no examples' do
47
+ @outline.examples.should == []
48
+ end
49
+
50
+ it 'contains steps and examples' do
51
+ steps = [:step_1, :step_2, :step_3]
52
+ examples = [:example_1, :example_2, :example_3]
53
+ everything = steps + examples
54
+
55
+ @outline.steps = steps
56
+ @outline.examples = examples
57
+
58
+ @outline.contains.should =~ everything
59
+ end
60
+
61
+ context 'outline output edge cases' do
62
+
63
+ it 'is a String' do
64
+ @outline.to_s.should be_a(String)
65
+ end
66
+
67
+ it 'can output an empty outline' do
68
+ expect { @outline.to_s }.to_not raise_error
69
+ end
70
+
71
+ it 'can output an outline that has only a name' do
72
+ @outline.name = 'a name'
73
+
74
+ expect { @outline.to_s }.to_not raise_error
75
+ end
76
+
77
+ it 'can output an outline that has only a description' do
78
+ @outline.description_text = 'a description'
79
+
80
+ expect { @outline.to_s }.to_not raise_error
81
+ end
82
+
83
+ it 'can output an outline that has only a tags' do
84
+ @outline.tags = ['a tag']
85
+
86
+ expect { @outline.to_s }.to_not raise_error
87
+ end
88
+
89
+ end
90
+
91
+ end