plugin_test_helper 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  == master
2
2
 
3
+ == 0.2.0 / 2008-12-14
4
+
5
+ * Remove the PluginAWeek namespace
6
+
3
7
  == 0.1.6 / 2008-12-06
4
8
 
5
9
  * Remove all dependencies on plugin_test_helper when using the plugin_test_structure generator
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = 'plugin_test_helper'
8
- s.version = '0.1.6'
8
+ s.version = '0.2.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.'
11
11
 
@@ -1,5 +1,5 @@
1
1
  # Generates the class and view for a controller in a plugin's test application
2
- class PluginTestControllerGenerator < PluginAWeek::PluginTestHelper::Generator
2
+ class PluginTestControllerGenerator < PluginTestHelper::Generator
3
3
  def manifest #:nodoc:
4
4
  record do |m|
5
5
  # Check for class naming collisions
@@ -1,5 +1,5 @@
1
1
  # Generates migrations for a plugin's test application
2
- class PluginTestMigrationGenerator < PluginAWeek::PluginTestHelper::Generator
2
+ class PluginTestMigrationGenerator < PluginTestHelper::Generator
3
3
  def manifest #:nodoc:
4
4
  record do |m|
5
5
  m.migration_template 'migration.rb', "#{plugin_app_root}/db/migrate"
@@ -1,5 +1,5 @@
1
1
  # Generates the class, fixtures, and migration for a model in a plugin's test application
2
- class PluginTestModelGenerator < PluginAWeek::PluginTestHelper::Generator
2
+ class PluginTestModelGenerator < PluginTestHelper::Generator
3
3
  default_options :skip_migration => false
4
4
 
5
5
  def manifest #:nodoc:
@@ -9,5 +9,5 @@ Rails::Initializer.run do |config|
9
9
  [Rails::Plugin.new(File.expand_path('.'))]
10
10
  end
11
11
  end
12
- ) unless defined?(PluginAWeek::PluginTestHelper::PluginLocator)
12
+ ) unless defined?(PluginTestHelper::PluginLocator)
13
13
  end
@@ -1,108 +1,106 @@
1
1
  require 'plugin_test_helper/plugin_locator'
2
2
 
3
- module PluginAWeek #:nodoc:
4
- module PluginTestHelper
5
- module Extensions #:nodoc:
6
- # Adds in hooks for extending other parts of the Rails framework *after*
7
- # Rails has loaded those frameworks
8
- module Initializer
9
- def self.included(base)
10
- base.class_eval do
11
- alias_method :require_frameworks_without_test_helper, :require_frameworks
12
- alias_method :require_frameworks, :require_frameworks_with_test_helper
13
- end
3
+ module PluginTestHelper
4
+ module Extensions #:nodoc:
5
+ # Adds in hooks for extending other parts of the Rails framework *after*
6
+ # Rails has loaded those frameworks
7
+ module Initializer
8
+ def self.included(base)
9
+ base.class_eval do
10
+ alias_method :require_frameworks_without_test_helper, :require_frameworks
11
+ alias_method :require_frameworks, :require_frameworks_with_test_helper
14
12
  end
13
+ end
14
+
15
+ # Load the needed frameworks and then our extensions to them
16
+ def require_frameworks_with_test_helper
17
+ require_frameworks_without_test_helper
15
18
 
16
- # Load the needed frameworks and then our extensions to them
17
- def require_frameworks_with_test_helper
18
- require_frameworks_without_test_helper
19
-
20
- require 'plugin_test_helper/generator'
19
+ require 'plugin_test_helper/generator'
20
+ end
21
+ end
22
+
23
+ # Overrides some of the default values in the Rails configuration so that
24
+ # files can be reused from this test helper or overridden by the plugin
25
+ # using the helper
26
+ module Configuration
27
+ def self.included(base) #:nodoc:
28
+ alias_method_chain base, :environment_path, :test_helper
29
+ alias_method_chain base, :default_load_paths, :test_helper
30
+ alias_method_chain base, :default_database_configuration_file, :test_helper
31
+ alias_method_chain base, :default_routes_configuration_file, :test_helper
32
+ alias_method_chain base, :default_controller_paths, :test_helper
33
+ alias_method_chain base, :default_plugin_locators, :test_helper
34
+ alias_method_chain base, :default_plugin_paths, :test_helper
35
+ end
36
+
37
+ # Defines a "lite" version of ActiveSupport's alias chaining extensions.
38
+ # This is defined here and acts on a particular class so as to not conflict
39
+ # with other classes that we have no control over
40
+ def self.alias_method_chain(klass, target, feature)
41
+ with_method, without_method = "#{target}_with_#{feature}", "#{target}_without_#{feature}"
42
+ klass.class_eval do
43
+ alias_method without_method, target
44
+ alias_method target, with_method
21
45
  end
22
46
  end
23
47
 
24
- # Overrides some of the default values in the Rails configuration so that
25
- # files can be reused from this test helper or overridden by the plugin
26
- # using the helper
27
- module Configuration
28
- def self.included(base) #:nodoc:
29
- alias_method_chain base, :environment_path, :test_helper
30
- alias_method_chain base, :default_load_paths, :test_helper
31
- alias_method_chain base, :default_database_configuration_file, :test_helper
32
- alias_method_chain base, :default_routes_configuration_file, :test_helper
33
- alias_method_chain base, :default_controller_paths, :test_helper
34
- alias_method_chain base, :default_plugin_locators, :test_helper
35
- alias_method_chain base, :default_plugin_paths, :test_helper
48
+ # Load the environment file from the plugin or the helper
49
+ def environment_path_with_test_helper
50
+ environment_path = environment_path_without_test_helper
51
+ File.exists?(environment_path) ? environment_path : "#{HELPER_RAILS_ROOT}/config/environments/#{environment}.rb"
52
+ end
53
+
54
+ private
55
+ # Add the helper's load paths
56
+ def default_load_paths_with_test_helper
57
+ paths = default_load_paths_without_test_helper
58
+ paths.concat %w(
59
+ app
60
+ app/controllers
61
+ config
62
+ lib
63
+ vendor
64
+ ).map {|dir| "#{HELPER_RAILS_ROOT}/#{dir}"}
36
65
  end
37
66
 
38
- # Defines a "lite" version of ActiveSupport's alias chaining extensions.
39
- # This is defined here and acts on a particular class so as to not conflict
40
- # with other classes that we have no control over
41
- def self.alias_method_chain(klass, target, feature)
42
- with_method, without_method = "#{target}_with_#{feature}", "#{target}_without_#{feature}"
43
- klass.class_eval do
44
- alias_method without_method, target
45
- alias_method target, with_method
46
- end
67
+ # Load the database configuration from the plugin or the helper
68
+ def default_database_configuration_file_with_test_helper
69
+ database_file = default_database_configuration_file_without_test_helper
70
+ File.exists?(database_file) ? database_file : File.join(HELPER_RAILS_ROOT, 'config/database.yml')
47
71
  end
48
72
 
49
- # Load the environment file from the plugin or the helper
50
- def environment_path_with_test_helper
51
- environment_path = environment_path_without_test_helper
52
- File.exists?(environment_path) ? environment_path : "#{HELPER_RAILS_ROOT}/config/environments/#{environment}.rb"
73
+ # Load the routes configuration file from the plugin or the helper
74
+ def default_routes_configuration_file_with_test_helper
75
+ routes_file = default_routes_configuration_file_without_test_helper
76
+ File.exists?(routes_file) ? routes_file : File.join(HELPER_RAILS_ROOT, 'config/routes.rb')
53
77
  end
54
78
 
55
- private
56
- # Add the helper's load paths
57
- def default_load_paths_with_test_helper
58
- paths = default_load_paths_without_test_helper
59
- paths.concat %w(
60
- app
61
- app/controllers
62
- config
63
- lib
64
- vendor
65
- ).map {|dir| "#{HELPER_RAILS_ROOT}/#{dir}"}
66
- end
67
-
68
- # Load the database configuration from the plugin or the helper
69
- def default_database_configuration_file_with_test_helper
70
- database_file = default_database_configuration_file_without_test_helper
71
- File.exists?(database_file) ? database_file : File.join(HELPER_RAILS_ROOT, 'config/database.yml')
72
- end
73
-
74
- # Load the routes configuration file from the plugin or the helper
75
- def default_routes_configuration_file_with_test_helper
76
- routes_file = default_routes_configuration_file_without_test_helper
77
- File.exists?(routes_file) ? routes_file : File.join(HELPER_RAILS_ROOT, 'config/routes.rb')
78
- end
79
-
80
- # Add the helper's controllers path
81
- def default_controller_paths_with_test_helper
82
- paths = default_controller_paths_without_test_helper
83
- paths << File.join(HELPER_RAILS_ROOT, 'app/controllers')
84
- end
85
-
86
- # Adds a custom plugin locator for loading the plugin being tested
87
- def default_plugin_locators_with_test_helper
88
- locators = default_plugin_locators_without_test_helper
89
- locators.unshift(PluginAWeek::PluginTestHelper::PluginLocator)
90
- end
91
-
92
- # Add the helper's vendor/plugins path
93
- def default_plugin_paths_with_test_helper
94
- paths = default_plugin_paths_without_test_helper
95
- paths << File.join(HELPER_RAILS_ROOT, 'vendor/plugins')
96
- end
97
- end
79
+ # Add the helper's controllers path
80
+ def default_controller_paths_with_test_helper
81
+ paths = default_controller_paths_without_test_helper
82
+ paths << File.join(HELPER_RAILS_ROOT, 'app/controllers')
83
+ end
84
+
85
+ # Adds a custom plugin locator for loading the plugin being tested
86
+ def default_plugin_locators_with_test_helper
87
+ locators = default_plugin_locators_without_test_helper
88
+ locators.unshift(PluginTestHelper::PluginLocator)
89
+ end
90
+
91
+ # Add the helper's vendor/plugins path
92
+ def default_plugin_paths_with_test_helper
93
+ paths = default_plugin_paths_without_test_helper
94
+ paths << File.join(HELPER_RAILS_ROOT, 'vendor/plugins')
95
+ end
98
96
  end
99
97
  end
100
98
  end
101
99
 
102
100
  Rails::Initializer.class_eval do
103
- include PluginAWeek::PluginTestHelper::Extensions::Initializer
101
+ include PluginTestHelper::Extensions::Initializer
104
102
  end
105
103
 
106
104
  Rails::Configuration.class_eval do
107
- include PluginAWeek::PluginTestHelper::Extensions::Configuration
105
+ include PluginTestHelper::Extensions::Configuration
108
106
  end
@@ -1,27 +1,25 @@
1
1
  require 'rails_generator'
2
2
 
3
- module PluginAWeek #:nodoc:
4
- module PluginTestHelper
5
- # The base generator for creating parts of the test application. The first
6
- # argument of the generator is always the name of the plugin.
7
- class Generator < Rails::Generator::NamedBase
8
- attr_accessor :plugin_name
9
-
10
- def initialize(*runtime_args) #:nodoc:
11
- @plugin_name = runtime_args.first.shift if runtime_args.first.is_a?(Array)
12
- super(*runtime_args)
3
+ module PluginTestHelper
4
+ # The base generator for creating parts of the test application. The first
5
+ # argument of the generator is always the name of the plugin.
6
+ class Generator < Rails::Generator::NamedBase
7
+ attr_accessor :plugin_name
8
+
9
+ def initialize(*runtime_args) #:nodoc:
10
+ @plugin_name = runtime_args.first.shift if runtime_args.first.is_a?(Array)
11
+ super(*runtime_args)
12
+ end
13
+
14
+ private
15
+ # The root path of the plugin's test directory
16
+ def plugin_test_root
17
+ "vendor/plugins/#{plugin_name}/test"
13
18
  end
14
19
 
15
- private
16
- # The root path of the plugin's test directory
17
- def plugin_test_root
18
- "vendor/plugins/#{plugin_name}/test"
19
- end
20
-
21
- # The root path of the plugin's test app
22
- def plugin_app_root
23
- "#{plugin_test_root}/app_root"
24
- end
25
- end
20
+ # The root path of the plugin's test app
21
+ def plugin_app_root
22
+ "#{plugin_test_root}/app_root"
23
+ end
26
24
  end
27
25
  end
@@ -1,11 +1,9 @@
1
- module PluginAWeek #:nodoc:
2
- module PluginTestHelper
3
- # Assists in the initialization process by locating the plugin being tested
4
- # so that it is tested as if the plugin were loaded in a regular app
5
- class PluginLocator < Rails::Plugin::Locator
6
- def plugins
7
- [Rails::Plugin.new(File.expand_path('.'))]
8
- end
1
+ module PluginTestHelper
2
+ # Assists in the initialization process by locating the plugin being tested
3
+ # so that it is tested as if the plugin were loaded in a regular app
4
+ class PluginLocator < Rails::Plugin::Locator
5
+ def plugins
6
+ [Rails::Plugin.new(File.expand_path('.'))]
9
7
  end
10
8
  end
11
9
  end
@@ -1,4 +1,2 @@
1
- module PluginAWeek
2
- module ActsAsFoo
3
- end
1
+ module ActsAsFoo
4
2
  end
@@ -24,7 +24,7 @@ class PluginTestHelperTest < Test::Unit::TestCase
24
24
  def test_should_load_with_custom_config
25
25
  setup_app('with_custom_config')
26
26
 
27
- assert_not_nil PluginAWeek::ActsAsFoo
27
+ assert_not_nil ActsAsFoo
28
28
  end
29
29
 
30
30
  def test_should_load_with_controller
@@ -7,7 +7,7 @@ class PluginLocatorTest < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def test_should_locate_plugin_being_tested
10
- locator = PluginAWeek::PluginTestHelper::PluginLocator.new(nil)
10
+ locator = PluginTestHelper::PluginLocator.new(nil)
11
11
  assert_equal ['plugin_test_helper'], locator.plugins.map(&:name)
12
12
  end
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plugin_test_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-06 00:00:00 -05:00
12
+ date: 2008-12-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -135,6 +135,7 @@ files:
135
135
  - test/app_roots/with_migration/app/models/person.rb
136
136
  - test/unit
137
137
  - test/unit/plugin_locator_test.rb
138
+ - test/app_root
138
139
  - CHANGELOG.rdoc
139
140
  - init.rb
140
141
  - LICENSE