Skip to content
This repository
Browse code

Revert "Update plugin loading tests to reflect changes in plugin fixt…

…ures."

This reverts commit eef9002.
  • Loading branch information...
commit 1d09ccd949eb113601ee84c10a508d36c63c62b7 1 parent eef9002
Joshua Peek authored April 21, 2008
49  railties/test/initializer_test.rb
@@ -38,27 +38,27 @@ def setup
38 38
     end
39 39
     config.after_initialize do
40 40
       $test_after_initialize_block2 = "congratulations"
41  
-    end
  41
+    end    
42 42
     assert_nil $test_after_initialize_block1
43  
-    assert_nil $test_after_initialize_block2
  43
+    assert_nil $test_after_initialize_block2    
44 44
 
45 45
     Rails::Initializer.run(:after_initialize, config)
46 46
   end
47  
-
  47
+  
48 48
   def teardown
49 49
     $test_after_initialize_block1 = nil
50  
-    $test_after_initialize_block2 = nil
  50
+    $test_after_initialize_block2 = nil    
51 51
   end
52 52
 
53 53
   def test_should_have_called_the_first_after_initialize_block
54 54
     assert_equal "success", $test_after_initialize_block1
55 55
   end
56  
-
  56
+  
57 57
   def test_should_have_called_the_second_after_initialize_block
58 58
     assert_equal "congratulations", $test_after_initialize_block2
59 59
   end
60 60
 end
61  
-
  61
+  
62 62
 class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase
63 63
 
64 64
   def setup
@@ -69,7 +69,7 @@ def setup
69 69
     config.after_initialize # don't pass a block, this is what we're testing!
70 70
     config.after_initialize do
71 71
       $test_after_initialize_block2 = "congratulations"
72  
-    end
  72
+    end    
73 73
     assert_nil $test_after_initialize_block1
74 74
 
75 75
     Rails::Initializer.run(:after_initialize, config)
@@ -77,7 +77,7 @@ def setup
77 77
 
78 78
   def teardown
79 79
     $test_after_initialize_block1 = nil
80  
-    $test_after_initialize_block2 = nil
  80
+    $test_after_initialize_block2 = nil    
81 81
   end
82 82
 
83 83
   def test_should_have_called_the_first_after_initialize_block
@@ -95,7 +95,7 @@ class ConfigurationFrameworkPathsTests < Test::Unit::TestCase
95 95
     def setup
96 96
       @config = Rails::Configuration.new
97 97
       @config.frameworks.clear
98  
-
  98
+      
99 99
       File.stubs(:directory?).returns(true)
100 100
       @config.stubs(:framework_root_path).returns('')
101 101
     end
@@ -112,7 +112,7 @@ def test_minimal
112 112
     def test_actioncontroller_or_actionview_add_actionpack
113 113
       @config.frameworks << :action_controller
114 114
       assert_framework_path '/actionpack/lib'
115  
-
  115
+      
116 116
       @config.frameworks = [:action_view]
117 117
       assert_framework_path '/actionpack/lib'
118 118
     end
@@ -162,7 +162,7 @@ def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
162 162
     end
163 163
 
164 164
     def test_only_the_specified_plugins_are_located_in_the_order_listed
165  
-      plugin_names = [:plugin_with_no_lib_dir]
  165
+      plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon]
166 166
       only_load_the_following_plugins! plugin_names
167 167
       load_plugins!
168 168
       assert_plugins plugin_names, @initializer.loaded_plugins
@@ -171,27 +171,27 @@ def test_only_the_specified_plugins_are_located_in_the_order_listed
171 171
     def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
172 172
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
173 173
       load_plugins!
174  
-      assert_plugins [:plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
  174
+      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
175 175
     end
176 176
 
177 177
     def test_all_plugins_loaded_when_all_is_used
178  
-      plugin_names = [:stubby, :all]
  178
+      plugin_names = [:stubby, :acts_as_chunky_bacon, :all]
179 179
       only_load_the_following_plugins! plugin_names
180 180
       load_plugins!
181 181
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
182  
-      assert_plugins [:stubby, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
  182
+      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
183 183
     end
184 184
 
185 185
     def test_all_plugins_loaded_after_all
186  
-      plugin_names = [:all, :stubby]
  186
+      plugin_names = [:stubby, :all, :acts_as_chunky_bacon]
187 187
       only_load_the_following_plugins! plugin_names
188 188
       load_plugins!
189 189
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
190  
-      assert_plugins [:plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
  190
+      assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
191 191
     end
192 192
 
193 193
     def test_plugin_names_may_be_strings
194  
-      plugin_names = ['stubby', :plugin_with_no_lib_dir]
  194
+      plugin_names = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
195 195
       only_load_the_following_plugins! plugin_names
196 196
       load_plugins!
197 197
       failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
@@ -204,21 +204,22 @@ def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
204 204
         load_plugins!
205 205
       end
206 206
     end
207  
-
  207
+    
208 208
     def test_should_ensure_all_loaded_plugins_load_paths_are_added_to_the_load_path
209  
-      only_load_the_following_plugins! [:stubby]
  209
+      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
210 210
 
211 211
       @initializer.add_plugin_load_paths
212  
-
  212
+      
213 213
       assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
  214
+      assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
214 215
     end
215  
-
  216
+    
216 217
     private
217  
-
  218
+    
218 219
       def load_plugins!
219 220
         @initializer.add_plugin_load_paths
220 221
         @initializer.load_plugins
221 222
       end
222 223
   end
223  
-
224  
-end
  224
+  
  225
+end  
89  railties/test/plugin_loader_test.rb
@@ -11,18 +11,18 @@ def self.configuration
11 11
 
12 12
   class TestPluginLoader < Test::Unit::TestCase
13 13
     ORIGINAL_LOAD_PATH = $LOAD_PATH.dup
14  
-
  14
+    
15 15
     def setup
16 16
       reset_load_path!
17  
-
  17
+      
18 18
       @configuration     = Rails::Configuration.new
19 19
       @configuration.plugin_paths << plugin_fixture_root_path
20 20
       @initializer       = Rails::Initializer.new(@configuration)
21 21
       @valid_plugin_path = plugin_fixture_path('default/stubby')
22 22
       @empty_plugin_path = plugin_fixture_path('default/empty')
23  
-
  23
+      
24 24
       @failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
25  
-
  25
+      
26 26
       @loader = Rails::Plugin::Loader.new(@initializer)
27 27
     end
28 28
 
@@ -34,106 +34,109 @@ def test_should_locate_plugins_by_asking_each_locator_specifed_in_configuration_
34 34
       @configuration.plugin_locators = [locator_class_1, locator_class_2]
35 35
       assert_equal [:a, :b, :c, :d, :e, :f], @loader.send(:locate_plugins)
36 36
     end
37  
-
  37
+    
38 38
     def test_should_memoize_the_result_of_locate_plugins_as_all_plugins
39 39
       plugin_list = [:a, :b, :c]
40 40
       @loader.expects(:locate_plugins).once.returns(plugin_list)
41 41
       assert_equal plugin_list, @loader.all_plugins
42 42
       assert_equal plugin_list, @loader.all_plugins # ensuring that locate_plugins isn't called again
43 43
     end
44  
-
  44
+    
45 45
     def test_should_return_empty_array_if_configuration_plugins_is_empty
46 46
       @configuration.plugins = []
47 47
       assert_equal [], @loader.plugins
48 48
     end
49  
-
  49
+    
50 50
     def test_should_find_all_availble_plugins_and_return_as_all_plugins
51  
-      assert_plugins [:stubby, :plugin_with_no_lib_dir], @loader.all_plugins.reverse, @failure_tip
  51
+      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.all_plugins.reverse, @failure_tip
52 52
     end
53 53
 
54 54
     def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
55  
-      assert_plugins [:plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
  55
+      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
56 56
     end
57  
-
  57
+    
58 58
     def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
59 59
       @configuration.plugins = nil
60  
-      assert_plugins [:plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
  60
+      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
61 61
     end
62 62
 
63 63
     def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
64  
-      plugin_names = [:stubby]
  64
+      plugin_names = [:acts_as_chunky_bacon, :stubby]
65 65
       only_load_the_following_plugins! plugin_names
66 66
       assert_plugins plugin_names, @loader.plugins
67 67
     end
68  
-
  68
+    
69 69
     def test_should_respect_the_order_of_plugins_given_in_configuration
70  
-      plugin_names = [:stubby]
  70
+      plugin_names = [:stubby, :acts_as_chunky_bacon]
71 71
       only_load_the_following_plugins! plugin_names
72  
-      assert_plugins plugin_names, @loader.plugins
  72
+      assert_plugins plugin_names, @loader.plugins      
73 73
     end
74  
-
  74
+    
75 75
     def test_should_load_all_plugins_in_natural_order_when_all_is_used
76 76
       only_load_the_following_plugins! [:all]
77  
-      assert_plugins [:plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
  77
+      assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
78 78
     end
79  
-
  79
+    
80 80
     def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
81  
-      only_load_the_following_plugins! [:stubby, :all]
82  
-      assert_plugins [:stubby, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
  81
+      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
  82
+      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
83 83
     end
84  
-
  84
+    
85 85
     def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
86  
-      only_load_the_following_plugins!  [:stubby, :all]
87  
-      assert_plugins [:stubby, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
  86
+      only_load_the_following_plugins!  [:stubby, :all, :acts_as_chunky_bacon]
  87
+      assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
88 88
     end
89 89
 
90 90
     def test_should_accept_plugin_names_given_as_strings
91  
-      only_load_the_following_plugins! ['stubby', :plugin_with_no_lib_dir]
92  
-      assert_plugins [:stubby, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
  91
+      only_load_the_following_plugins! ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
  92
+      assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
93 93
     end
94  
-
  94
+    
95 95
     def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array
96  
-      only_load_the_following_plugins! [:stubby]
  96
+      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
97 97
       stubbed_application_lib_index_in_LOAD_PATHS = 5
98 98
       @loader.stubs(:application_lib_index).returns(stubbed_application_lib_index_in_LOAD_PATHS)
99  
-
  99
+      
100 100
       @loader.add_plugin_load_paths
101  
-
  101
+      
102 102
       assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
103  
-    end
104  
-
  103
+      assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS    
  104
+    end   
  105
+    
105 106
     def test_should_add_plugin_load_paths_to_Dependencies_load_paths
106  
-      only_load_the_following_plugins! [:stubby]
  107
+      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
107 108
 
108 109
       @loader.add_plugin_load_paths
109  
-
  110
+      
110 111
       assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
  112
+      assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))    
111 113
     end
112  
-
  114
+    
113 115
     def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
114  
-      only_load_the_following_plugins! [:stubby]
  116
+      only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
115 117
 
116 118
       @loader.add_plugin_load_paths
117  
-
  119
+      
118 120
       assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
  121
+      assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))    
119 122
     end
120  
-
  123
+    
121 124
     def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array
122 125
       plugin_load_paths = ["a", "b"]
123 126
       plugin = stub(:load_paths => plugin_load_paths)
124 127
       @loader.stubs(:plugins).returns([plugin])
125  
-
  128
+      
126 129
       @loader.add_plugin_load_paths
127  
-
  130
+      
128 131
       plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
129 132
     end
130  
-
  133
+    
131 134
     private
132  
-
  135
+    
133 136
       def reset_load_path!
134 137
         $LOAD_PATH.clear
135  
-        ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path }
  138
+        ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path }        
136 139
       end
137 140
   end
138  
-
  141
+    
139 142
 end
27  railties/test/plugin_locator_test.rb
@@ -3,13 +3,13 @@
3 3
 uses_mocha "Plugin Locator Tests" do
4 4
 
5 5
   class PluginLocatorTest < Test::Unit::TestCase
6  
-
  6
+  
7 7
     def test_should_require_subclasses_to_implement_the_plugins_method
8 8
       assert_raises(RuntimeError) do
9 9
         Rails::Plugin::Locator.new(nil).plugins
10 10
       end
11 11
     end
12  
-
  12
+  
13 13
     def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each
14 14
       locator = Rails::Plugin::Locator.new(nil)
15 15
       locator.stubs(:plugins).returns([:a, :b, :c])
@@ -17,12 +17,12 @@ def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each
17 17
       plugin_consumer.expects(:consume).with(:a)
18 18
       plugin_consumer.expects(:consume).with(:b)
19 19
       plugin_consumer.expects(:consume).with(:c)
20  
-
  20
+    
21 21
       locator.each do |plugin|
22 22
         plugin_consumer.consume(plugin)
23 23
       end
24 24
     end
25  
-
  25
+  
26 26
   end
27 27
 
28 28
 
@@ -39,22 +39,25 @@ def setup
39 39
     end
40 40
 
41 41
     def test_should_return_rails_plugin_instances_when_calling_create_plugin_with_a_valid_plugin_directory
42  
-      assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path)
  42
+      assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path)  
43 43
     end
44  
-
  44
+  
45 45
     def test_should_return_nil_when_calling_create_plugin_with_an_invalid_plugin_directory
46  
-      assert_nil @locator.send(:create_plugin, @empty_plugin_path)
  46
+      assert_nil @locator.send(:create_plugin, @empty_plugin_path)  
47 47
     end
48  
-
  48
+  
49 49
     def test_should_return_all_plugins_found_under_the_set_plugin_paths
50  
-      assert_equal ["plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
  50
+      assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
51 51
     end
52  
-
  52
+  
53 53
     def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
54 54
       @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
55  
-      assert_equal ["plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
  55
+      assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
  56
+    
  57
+      @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
  58
+      assert_equal ["a"], @locator.plugins.map(&:name)
56 59
     end
57  
-
  60
+  
58 61
     def test_should_not_raise_any_error_and_return_no_plugins_if_the_plugin_path_value_does_not_exist
59 62
       @configuration.plugin_paths = ["some_missing_directory"]
60 63
       assert_nothing_raised do

0 notes on commit 1d09ccd

Please sign in to comment.
Something went wrong with that request. Please try again.