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,55 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('TableRow') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'TableRow, Unit' do
6
+
7
+ clazz = CukeModeler::TableRow
8
+
9
+ it_should_behave_like 'a nested element', clazz
10
+ it_should_behave_like 'a bare bones element', clazz
11
+ it_should_behave_like 'a prepopulated element', clazz
12
+ it_should_behave_like 'a sourced element', clazz
13
+ it_should_behave_like 'a raw element', clazz
14
+
15
+ it 'can be parsed from stand alone text' do
16
+ source = '| a | row |'
17
+
18
+ expect { @element = clazz.new(source) }.to_not raise_error
19
+
20
+ # Sanity check in case instantiation failed in a non-explosive manner
21
+ @element.cells.should == ['a', 'row']
22
+ end
23
+
24
+ before(:each) do
25
+ @row = clazz.new
26
+ end
27
+
28
+ it 'has cells' do
29
+ @row.should respond_to(:cells)
30
+ end
31
+
32
+ it 'can get and set its cells' do
33
+ @row.cells = :some_cells
34
+ @row.cells.should == :some_cells
35
+ @row.cells = :some_other_cells
36
+ @row.cells.should == :some_other_cells
37
+ end
38
+
39
+ it 'starts with no cells' do
40
+ @row.cells.should == []
41
+ end
42
+
43
+ context 'table row output edge cases' do
44
+
45
+ it 'is a String' do
46
+ @row.to_s.should be_a(String)
47
+ end
48
+
49
+ it 'can output an empty table row' do
50
+ expect { @row.to_s }.to_not raise_error
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Table') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Table, Unit' do
6
+
7
+ clazz = CukeModeler::Table
8
+
9
+ it_should_behave_like 'a nested element', clazz
10
+ it_should_behave_like 'a bare bones element', clazz
11
+ it_should_behave_like 'a prepopulated element', clazz
12
+ it_should_behave_like 'a raw element', clazz
13
+
14
+ it 'can be parsed from stand alone text' do
15
+ source = '| a table |'
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.row_elements.collect { |row| row.cells }.should == [['a table']]
21
+ # todo - remove once #contents is no longer supported
22
+ @element.contents.should == [['a table']]
23
+ end
24
+
25
+ before(:each) do
26
+ @table = clazz.new
27
+ end
28
+
29
+ # todo - remove once #contents is no longer supported
30
+ it 'has contents - #contents' do
31
+ @table.should respond_to(:contents)
32
+ end
33
+
34
+ # todo - remove once #contents is no longer supported
35
+ it 'can get and set its contents - #contents, #contents=' do
36
+ @table.contents = :some_contents
37
+ @table.contents.should == :some_contents
38
+ @table.contents = :some_other_contents
39
+ @table.contents.should == :some_other_contents
40
+ end
41
+
42
+ # todo - remove once #contents is no longer supported
43
+ it 'starts with no contents' do
44
+ @table.contents.should == []
45
+ end
46
+
47
+ it 'has row elements' do
48
+ @table.should respond_to(:row_elements)
49
+ end
50
+
51
+ it 'can get and set its row elements' do
52
+ @table.row_elements = :some_row_elements
53
+ @table.row_elements.should == :some_row_elements
54
+ @table.row_elements = :some_other_row_elements
55
+ @table.row_elements.should == :some_other_row_elements
56
+ end
57
+
58
+ it 'starts with no row elements' do
59
+ @table.row_elements.should == []
60
+ end
61
+
62
+ # todo - remove once #contents is no longer supported
63
+ it 'stores its contents as a nested array of strings' do
64
+ source = "| cell 1 | cell 2 |\n| cell 3 | cell 4 |"
65
+ table = CukeModeler::Table.new(source)
66
+
67
+ contents = table.contents
68
+
69
+ contents.is_a?(Array).should be_true
70
+
71
+ contents.each do |row|
72
+ row.is_a?(Array).should be_true
73
+ row.each { |cell| cell.is_a?(String).should be_true }
74
+ end
75
+ end
76
+
77
+ context 'table output edge cases' do
78
+
79
+ it 'is a String' do
80
+ @table.to_s.should be_a(String)
81
+ end
82
+
83
+ it 'can output an empty table' do
84
+ expect { @table.to_s }.to_not raise_error
85
+ end
86
+
87
+ # todo - remove once #contents is no longer supported
88
+ it 'can output a table that only has contents' do
89
+ @table.contents = ['some contents']
90
+
91
+ expect { @table.to_s }.to_not raise_error
92
+ end
93
+
94
+ end
95
+
96
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Tag, Unit' do
6
+
7
+ clazz = CukeModeler::Tag
8
+
9
+ it_should_behave_like 'a nested element', clazz
10
+ it_should_behave_like 'a bare bones element', clazz
11
+ it_should_behave_like 'a prepopulated element', clazz
12
+ it_should_behave_like 'a sourced element', clazz
13
+ it_should_behave_like 'a raw element', clazz
14
+
15
+
16
+ it 'can be parsed from stand alone text' do
17
+ source = '@a_tag'
18
+
19
+ expect { @element = clazz.new(source) }.to_not raise_error
20
+ @element.name.should == '@a_tag'
21
+ end
22
+
23
+ before(:each) do
24
+ @element = clazz.new
25
+ end
26
+
27
+
28
+ it 'has a name' do
29
+ @element.should respond_to(:name)
30
+ end
31
+
32
+ it 'can get and set its name' do
33
+ @element.name = :some_name
34
+ @element.name.should == :some_name
35
+ @element.name = :some_other_name
36
+ @element.name.should == :some_other_name
37
+ end
38
+
39
+ context 'tag output edge cases' do
40
+
41
+ it 'is a String' do
42
+ @element.to_s.should be_a(String)
43
+ end
44
+
45
+ it 'can output an empty tag' do
46
+ expect { @element.to_s }.to_not raise_error
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('Taggable') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'Taggable, Unit' do
6
+
7
+ nodule = CukeModeler::Taggable
8
+
9
+ before(:each) do
10
+ @element = Object.new.extend(nodule)
11
+
12
+ def @element.parent_element
13
+ @parent_element
14
+ end
15
+
16
+ def @element.parent_element=(parent)
17
+ @parent_element = parent
18
+ end
19
+ end
20
+
21
+
22
+ it 'has tags' do
23
+ @element.should respond_to(:tags)
24
+ @element.should respond_to(:tag_elements)
25
+ end
26
+
27
+ it 'can get and set its tags' do
28
+ @element.tags = :some_tags
29
+ @element.tags.should == :some_tags
30
+ @element.tags = :some_other_tags
31
+ @element.tags.should == :some_other_tags
32
+
33
+ @element.tag_elements = :some_tag_elements
34
+ @element.tag_elements.should == :some_tag_elements
35
+ @element.tag_elements = :some_other_tag_elements
36
+ @element.tag_elements.should == :some_other_tag_elements
37
+ end
38
+
39
+ it 'has applied tags' do
40
+ @element.should respond_to(:applied_tags)
41
+ @element.should respond_to(:applied_tag_elements)
42
+ end
43
+
44
+ it 'inherits its applied tags from its ancestors' do
45
+ all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
46
+ all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
47
+ parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
48
+
49
+ @element.parent_element = parent
50
+
51
+ @element.applied_tags.should == all_parent_tags
52
+ @element.applied_tag_elements.should == all_parent_tag_elements
53
+ end
54
+
55
+ it 'knows all of its applicable tags' do
56
+ all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
57
+ all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
58
+ own_tags = ['@tag_1', '@tag_2']
59
+ own_tag_elements = [:tag_element_1, :tag_element_2]
60
+
61
+ parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
62
+
63
+ @element.parent_element = parent
64
+ @element.tags = own_tags
65
+ @element.tag_elements = own_tag_elements
66
+
67
+ @element.all_tags.should == all_parent_tags + own_tags
68
+ @element.all_tag_elements.should == all_parent_tag_elements + own_tag_elements
69
+ end
70
+
71
+ it 'may have no applied tags' do
72
+ @element.parent_element = :not_a_tagged_object
73
+
74
+ @element.applied_tags.should == []
75
+ @element.applied_tag_elements.should == []
76
+ end
77
+
78
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a tagged element' do |clazz|
4
+
5
+ before(:each) do
6
+ @element = clazz.new
7
+ end
8
+
9
+ it 'has tags' do
10
+ @element.should respond_to(:tags)
11
+ @element.should respond_to(:tag_elements)
12
+ end
13
+
14
+ it 'can get and set its tags' do
15
+ @element.tags = :some_tags
16
+ @element.tags.should == :some_tags
17
+ @element.tags = :some_other_tags
18
+ @element.tags.should == :some_other_tags
19
+
20
+ @element.tag_elements = :some_tag_elements
21
+ @element.tag_elements.should == :some_tag_elements
22
+ @element.tag_elements = :some_other_tag_elements
23
+ @element.tag_elements.should == :some_other_tag_elements
24
+ end
25
+
26
+ it 'starts with no tags' do
27
+ @element.tags.should == []
28
+ @element.tag_elements.should == []
29
+ end
30
+
31
+ it 'has applied tags' do
32
+ @element.should respond_to(:applied_tags)
33
+ @element.should respond_to(:applied_tag_elements)
34
+ end
35
+
36
+ it 'inherits its applied tags from its ancestors' do
37
+ all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
38
+ all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
39
+ parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
40
+
41
+ @element.parent_element = parent
42
+
43
+ @element.applied_tags.should == all_parent_tags
44
+ @element.applied_tag_elements.should == all_parent_tag_elements
45
+ end
46
+
47
+ it 'knows all of its applicable tags' do
48
+ all_parent_tag_elements = [:parent_tag_element_1, :parent_tag_element_2, :grandparent_tag_element_1]
49
+ all_parent_tags = ['@parent_tag_1', '@parent_tag_2', '@grandparent_tag_1']
50
+ own_tags = ['@tag_1', '@tag_2']
51
+ own_tag_elements = [:tag_element_1, :tag_element_2]
52
+
53
+ parent = double(:all_tags => all_parent_tags, :all_tag_elements => all_parent_tag_elements)
54
+
55
+ @element.parent_element = parent
56
+ @element.tags = own_tags
57
+ @element.tag_elements = own_tag_elements
58
+
59
+ @element.all_tags.should == all_parent_tags + own_tags
60
+ @element.all_tag_elements.should == all_parent_tag_elements + own_tag_elements
61
+ end
62
+
63
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('TestElement') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'TestElement, Unit' do
6
+
7
+ clazz = CukeModeler::TestElement
8
+
9
+ it_should_behave_like 'a test element', clazz
10
+ it_should_behave_like 'a feature element', clazz
11
+ it_should_behave_like 'a nested element', clazz
12
+ it_should_behave_like 'a prepopulated element', clazz
13
+ it_should_behave_like 'a bare bones element', clazz
14
+
15
+
16
+ before(:each) do
17
+ @element = clazz.new
18
+ end
19
+
20
+ it 'contains only steps - #contains' do
21
+ steps = [:step_1, :step_2, :step_3]
22
+ @element.steps = steps
23
+
24
+ @element.contains.should =~ steps
25
+ end
26
+
27
+ it 'can determine its equality with another TestElement - #==' do
28
+ element_1 = clazz.new
29
+ element_2 = clazz.new
30
+ element_3 = clazz.new
31
+
32
+ element_1.steps = :some_steps
33
+ element_2.steps = :some_steps
34
+ element_3.steps = :some_other_steps
35
+
36
+ (element_1 == element_2).should be_true
37
+ (element_1 == element_3).should be_false
38
+ end
39
+
40
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a test element' do |clazz|
4
+
5
+ before(:each) do
6
+ @element = clazz.new
7
+ end
8
+
9
+ it 'has steps - #steps' do
10
+ @element.should respond_to(:steps)
11
+ end
12
+
13
+ it 'can get and set its steps - #steps, #steps=' do
14
+ @element.steps = :some_steps
15
+ @element.steps.should == :some_steps
16
+ @element.steps = :some_other_steps
17
+ @element.steps.should == :some_other_steps
18
+ end
19
+
20
+ it 'starts with no steps' do
21
+ @element.steps.should == []
22
+ end
23
+
24
+ it 'contains steps - #contains' do
25
+ steps = [:step_1, :step_2, :step_3]
26
+ @element.steps = steps
27
+
28
+ steps.each { |step| @element.contains.should include(step) }
29
+ end
30
+
31
+ end
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+
3
+ SimpleCov.command_name('World') unless RUBY_VERSION.to_s < '1.9.0'
4
+
5
+ describe 'World, Unit' do
6
+
7
+ before(:each) do
8
+ @world = CukeModeler::World
9
+ @world.loaded_step_patterns.clear
10
+ @world.delimiter = nil
11
+ end
12
+
13
+ it 'has left and right delimiters used for step argument parsing - #left_delimiter, #right_delimiter' do
14
+ @world.should respond_to(:left_delimiter)
15
+ @world.should respond_to(:right_delimiter)
16
+ end
17
+
18
+ it 'can get and set the delimiters used for step argument parsing' do
19
+ @world.left_delimiter = '"'
20
+ @world.right_delimiter = '"'
21
+ @world.left_delimiter.should == '"'
22
+ @world.right_delimiter.should == '"'
23
+
24
+ @world.left_delimiter = '!'
25
+ @world.right_delimiter = '!'
26
+ @world.left_delimiter.should == '!'
27
+ @world.right_delimiter.should == '!'
28
+ end
29
+
30
+ it 'can have different left and right delimiters' do
31
+ @world.left_delimiter = '"'
32
+ @world.right_delimiter = '*'
33
+
34
+ (@world.left_delimiter != @world.right_delimiter).should be_true
35
+ end
36
+
37
+ it 'can set both of its delimiters at once - #delimiter=' do
38
+ @world.delimiter = '*'
39
+
40
+ @world.left_delimiter.should == '*'
41
+ @world.right_delimiter.should == '*'
42
+ end
43
+
44
+ it 'starts with no delimiters' do
45
+ @world.left_delimiter.should == nil
46
+ @world.right_delimiter.should == nil
47
+ end
48
+
49
+ context 'step patterns' do
50
+
51
+ it 'can load step patterns - #load_step_pattern' do
52
+ @world.should respond_to(:load_step_pattern)
53
+ end
54
+
55
+ it 'starts with no patterns loaded' do
56
+ @world.loaded_step_patterns.should == []
57
+ end
58
+
59
+ it 'keeps track of loaded step patterns - #loaded_step_patterns' do
60
+ patterns = [/a pattern/, /another pattern/]
61
+
62
+ patterns.each do |pattern|
63
+ @world.load_step_pattern(pattern)
64
+ end
65
+
66
+ @world.loaded_step_patterns.should =~ patterns
67
+ end
68
+
69
+ it 'can load step definition files - #load_step_file' do
70
+ file_path = "#{@default_file_directory}/step_file.rb"
71
+ patterns = [/a pattern/, /another pattern/]
72
+
73
+ File.open(file_path, 'w') { |file|
74
+ patterns.each do |pattern|
75
+ file.puts "Given #{pattern.inspect} do end"
76
+ end
77
+ }
78
+
79
+ @world.load_step_file(file_path)
80
+
81
+ @world.loaded_step_patterns.should =~ patterns
82
+ end
83
+
84
+ it 'can handle different step keywords - #load_step_file' do
85
+ file_path = "#{@default_file_directory}/step_file.rb"
86
+ patterns = [/given pattern/, /when pattern/, /then pattern/, /and pattern/, /but pattern/]
87
+
88
+ File.open(file_path, 'w') { |file|
89
+ file.puts "Given #{patterns[0].inspect} do end"
90
+ file.puts "When #{patterns[1].inspect} do end"
91
+ file.puts "Then #{patterns[2].inspect} do end"
92
+ file.puts "And #{patterns[3].inspect} do end"
93
+ file.puts "But #{patterns[4].inspect} do end"
94
+ }
95
+
96
+ @world.load_step_file(file_path)
97
+
98
+ @world.loaded_step_patterns.should =~ patterns
99
+ end
100
+
101
+ it 'can handle a variety of declaration structures - #load_step_file' do
102
+ file_path = "#{@default_file_directory}/step_file.rb"
103
+ patterns = [/parentheses pattern/, /no parentheses pattern/, /excess whitespace pattern/]
104
+
105
+ File.open(file_path, 'w') { |file|
106
+ file.puts "Given(#{patterns[0].inspect}) do end"
107
+ file.puts "Given #{patterns[1].inspect} do end"
108
+ file.puts "Given #{patterns[2].inspect} do end"
109
+ }
110
+
111
+ @world.load_step_file(file_path)
112
+
113
+ @world.loaded_step_patterns.should =~ patterns
114
+ end
115
+
116
+ it 'can clear its loaded step patterns - #clear_step_patterns' do
117
+ patterns = [/a pattern/, /another pattern/]
118
+
119
+ patterns.each do |pattern|
120
+ @world.load_step_pattern(pattern)
121
+ end
122
+
123
+ @world.loaded_step_patterns.should =~ patterns
124
+ @world.clear_step_patterns
125
+ @world.loaded_step_patterns.should == []
126
+ end
127
+
128
+ end
129
+
130
+ end