plugin_test_helper 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGELOG → CHANGELOG.rdoc} +13 -22
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/{README → README.rdoc} +6 -6
- data/Rakefile +44 -36
- data/generators/plugin_test_console/USAGE +10 -0
- data/generators/plugin_test_console/plugin_test_console_generator.rb +1 -1
- data/generators/plugin_test_controller/USAGE +13 -0
- data/generators/plugin_test_helper/USAGE +11 -0
- data/generators/plugin_test_helper/plugin_test_helper_generator.rb +7 -2
- data/generators/plugin_test_migration/USAGE +13 -0
- data/generators/plugin_test_model/USAGE +14 -0
- data/generators/plugin_test_structure/USAGE +19 -0
- data/lib/plugin_test_helper.rb +2 -2
- data/lib/plugin_test_helper/console_with_fixtures.rb +1 -0
- data/lib/plugin_test_helper/extensions/initializer.rb +26 -11
- data/lib/plugin_test_helper/generator.rb +4 -1
- data/lib/plugin_test_helper/plugin_locator.rb +1 -0
- data/test/functional/plugin_test_console_generator_test.rb +21 -0
- data/test/functional/plugin_test_controller_generator_test.rb +25 -0
- data/test/functional/plugin_test_helper_generator_test.rb +21 -0
- data/test/functional/plugin_test_migration_generator_test.rb +23 -0
- data/test/functional/plugin_test_model_generator_test.rb +31 -0
- data/test/functional/plugin_test_structure_generator_test.rb +57 -0
- data/test/test_helper.rb +5 -0
- metadata +25 -9
- data/lib/plugin_test_helper/extensions/routing.rb +0 -49
@@ -1,58 +1,49 @@
|
|
1
|
-
|
1
|
+
== master
|
2
2
|
|
3
|
-
|
3
|
+
== 0.1.5 / 2008-07-13
|
4
|
+
|
5
|
+
* Don't load ActiveSupport before the environment has been initialized since it can hide problems in the plugin being tested
|
6
|
+
* Simplify how to determine which routing file to use
|
7
|
+
|
8
|
+
== 0.1.4 / 2008-06-22
|
4
9
|
|
5
10
|
* Remove log files from gems
|
6
11
|
|
7
|
-
|
12
|
+
== 0.1.3 / 2008-05-05
|
8
13
|
|
9
14
|
* Update documentation
|
10
|
-
|
11
15
|
* Update to be compatible with Rails 2.1
|
12
|
-
|
13
16
|
* Add PluginAWeek::PluginTestHelper::PluginLocator so that you don't have to explicitly define config.plugins if the test app has anything under vendor/plugins
|
14
|
-
|
15
17
|
* Add default routes
|
16
18
|
|
17
|
-
|
19
|
+
== 0.1.2 / 2007-10-15
|
18
20
|
|
19
21
|
* Don't create vendor/plugins in the plugin_test_structure generator
|
20
|
-
|
21
22
|
* Don't load actionwebservice by default
|
22
|
-
|
23
23
|
* Remove unnecessary configuration options from environment
|
24
24
|
|
25
|
-
|
25
|
+
== 0.1.1 / 2007-09-18
|
26
26
|
|
27
27
|
* Allow RAILS_FRAMEWORK_ROOT to be specified
|
28
|
-
|
29
28
|
* fixture_path should be a string, not an array
|
30
|
-
|
31
29
|
* Move test fixtures out of the test application root directory
|
32
30
|
|
33
|
-
|
31
|
+
== 0.1.0 / 2007-09-05
|
34
32
|
|
35
33
|
* Fixtures are now expected to be in plugin_root/test/fixtures instead of plugin_root/test/app_root/test/fixtures
|
36
|
-
|
37
34
|
* Add support for running a console on the test application
|
38
|
-
|
39
35
|
* Add basic functional tests
|
40
|
-
|
41
36
|
* Convert dos newlines to unix newlines
|
42
37
|
|
43
|
-
|
38
|
+
== 0.0.2 / 2007-08-15
|
44
39
|
|
45
40
|
* Autoload plugin even if the plugin doesn't define an app_root
|
46
|
-
|
47
41
|
* A proxy plugin for the plugin being tested is no longer needed in favor of doing selective plugin loading.
|
48
|
-
|
49
42
|
* Make sure RAILS_ROOT is in the load path
|
50
|
-
|
51
43
|
* Automate setting of the fixtures path
|
52
|
-
|
53
44
|
* Load test_help instead of test/unit so that additional libraries are automatically loaded like they are in your application's tests
|
54
45
|
|
55
|
-
|
46
|
+
== 0.0.1 / 2007-05-31
|
56
47
|
|
57
48
|
* Initial release
|
58
49
|
|
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/{README → README.rdoc}
RENAMED
@@ -5,21 +5,21 @@ environment that simulates its usage in a real application.
|
|
5
5
|
|
6
6
|
== Resources
|
7
7
|
|
8
|
-
Wiki
|
9
|
-
|
10
|
-
* http://wiki.pluginaweek.org/Plugin_test_helper
|
11
|
-
|
12
8
|
API
|
13
9
|
|
14
10
|
* http://api.pluginaweek.org/plugin_test_helper
|
15
11
|
|
12
|
+
Bugs
|
13
|
+
|
14
|
+
* http://pluginaweek.lighthouseapp.com/projects/13283-plugin_test_helper
|
15
|
+
|
16
16
|
Development
|
17
17
|
|
18
|
-
* http://
|
18
|
+
* http://github.com/pluginaweek/plugin_test_helper
|
19
19
|
|
20
20
|
Source
|
21
21
|
|
22
|
-
*
|
22
|
+
* git://github.com/pluginaweek/plugin_test_helper.git
|
23
23
|
|
24
24
|
== Description
|
25
25
|
|
data/Rakefile
CHANGED
@@ -3,46 +3,54 @@ require 'rake/rdoctask'
|
|
3
3
|
require 'rake/gempackagetask'
|
4
4
|
require 'rake/contrib/sshpublisher'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.name = 'plugin_test_helper'
|
8
|
+
s.version = '0.1.5'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.'
|
11
|
+
|
12
|
+
s.files = FileList['{generators,lib,test}/**/*'].to_a - FileList['generators/plugin_test_structure/templates/app_root/log/*'].to_a + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc)
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.test_files = Dir['test/**/*_test.rb']
|
16
|
+
|
17
|
+
s.author = 'Aaron Pfeifer'
|
18
|
+
s.email = 'aaron@pluginaweek.org'
|
19
|
+
s.homepage = 'http://www.pluginaweek.org'
|
20
|
+
s.rubyforge_project = 'pluginaweek'
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Default: run all tests.'
|
12
24
|
task :default => :test
|
13
25
|
|
14
|
-
desc
|
26
|
+
desc "Test the #{spec.name} plugin."
|
15
27
|
Rake::TestTask.new(:test) do |t|
|
16
28
|
t.libs << 'lib'
|
17
|
-
t.
|
29
|
+
t.test_files = spec.test_files
|
18
30
|
t.verbose = true
|
19
31
|
end
|
20
32
|
|
21
|
-
|
33
|
+
begin
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
namespace :test do
|
36
|
+
desc "Test the #{spec.name} plugin with Rcov."
|
37
|
+
Rcov::RcovTask.new(:rcov) do |t|
|
38
|
+
t.libs << 'lib'
|
39
|
+
t.test_files = spec.test_files
|
40
|
+
t.rcov_opts << '--exclude="^(?!lib/|generators/.*/.*_generator.rb)"'
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Generate documentation for the #{spec.name} plugin."
|
22
48
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
23
49
|
rdoc.rdoc_dir = 'rdoc'
|
24
|
-
rdoc.title =
|
50
|
+
rdoc.title = spec.name
|
25
51
|
rdoc.template = '../rdoc_template.rb'
|
26
52
|
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
-
rdoc.rdoc_files.include('README')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
-
end
|
30
|
-
|
31
|
-
spec = Gem::Specification.new do |s|
|
32
|
-
s.name = PKG_NAME
|
33
|
-
s.version = PKG_VERSION
|
34
|
-
s.platform = Gem::Platform::RUBY
|
35
|
-
s.summary = 'Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.'
|
36
|
-
|
37
|
-
s.files = FileList['{generators,lib,test}/**/*'].to_a - FileList['generators/plugin_test_structure/templates/app_root/log/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
|
38
|
-
s.require_path = 'lib'
|
39
|
-
s.autorequire = 'plugin_test_helper'
|
40
|
-
s.has_rdoc = true
|
41
|
-
s.test_files = Dir['test/**/*_test.rb']
|
42
|
-
|
43
|
-
s.author = 'Aaron Pfeifer'
|
44
|
-
s.email = 'aaron@pluginaweek.org'
|
45
|
-
s.homepage = 'http://www.pluginaweek.org'
|
53
|
+
rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
|
46
54
|
end
|
47
55
|
|
48
56
|
Rake::GemPackageTask.new(spec) do |p|
|
@@ -51,14 +59,14 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
51
59
|
p.need_zip = true
|
52
60
|
end
|
53
61
|
|
54
|
-
desc 'Publish the beta gem'
|
62
|
+
desc 'Publish the beta gem.'
|
55
63
|
task :pgem => [:package] do
|
56
|
-
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{
|
64
|
+
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
|
57
65
|
end
|
58
66
|
|
59
|
-
desc 'Publish the API documentation'
|
67
|
+
desc 'Publish the API documentation.'
|
60
68
|
task :pdoc => [:rdoc] do
|
61
|
-
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{
|
69
|
+
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
|
62
70
|
end
|
63
71
|
|
64
72
|
desc 'Publish the API docs and gem'
|
@@ -71,10 +79,10 @@ task :release => [:gem, :package] do
|
|
71
79
|
ruby_forge = RubyForge.new.configure
|
72
80
|
ruby_forge.login
|
73
81
|
|
74
|
-
%w(
|
75
|
-
file = "pkg/#{
|
82
|
+
%w(gem tgz zip).each do |ext|
|
83
|
+
file = "pkg/#{spec.name}-#{spec.version}.#{ext}"
|
76
84
|
puts "Releasing #{File.basename(file)}..."
|
77
85
|
|
78
|
-
ruby_forge.add_release(
|
86
|
+
ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
|
79
87
|
end
|
80
88
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
Creates a script that will allow the test app to be run via the ruby console. Pass the plugin name, under_scored.
|
3
|
+
|
4
|
+
The console script is generated in test/app_root/script.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
`./script/generate plugin_test_console has_comments`
|
8
|
+
|
9
|
+
creates an console script:
|
10
|
+
Console: test/app_root/script/console
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new controller and its views within a plugin. Pass the plugin name,
|
3
|
+
controller name (either CamelCased or under_scored) and a list of views as arguments.
|
4
|
+
|
5
|
+
This generates a controller class in app_root/app/controllers and view
|
6
|
+
templates in app_root/app/views/controller_name.
|
7
|
+
|
8
|
+
Example:
|
9
|
+
`./script/generate plugin_test_controller has_comments Posts index show`
|
10
|
+
|
11
|
+
Post controller with URLs like /posts/index.
|
12
|
+
Controller: app/controllers/posts_controller.rb
|
13
|
+
Views: app/views/posts/index.html.erb [...]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Creates the test helper that should be required for every unit/functional test.
|
3
|
+
Pass the plugin name, under_scored.
|
4
|
+
|
5
|
+
The test helper is generated in test/.
|
6
|
+
|
7
|
+
Example:
|
8
|
+
`./script/generate plugin_test_helper has_comments`
|
9
|
+
|
10
|
+
creates an test helper:
|
11
|
+
Test Helper: test/test_helper.rb
|
@@ -2,8 +2,13 @@
|
|
2
2
|
class PluginTestHelperGenerator < Rails::Generator::NamedBase
|
3
3
|
def manifest #:nodoc:
|
4
4
|
record do |m|
|
5
|
-
|
6
|
-
|
5
|
+
plugin_root = "vendor/plugins/#{name}"
|
6
|
+
|
7
|
+
# Test directory
|
8
|
+
m.directory File.join(plugin_root, 'test')
|
9
|
+
|
10
|
+
# Test helper
|
11
|
+
m.file 'test_helper.rb', File.join(plugin_root, 'test/test_helper.rb')
|
7
12
|
end
|
8
13
|
end
|
9
14
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new database migration. Pass the plugin name, migration name
|
3
|
+
(either CamelCased or under_scored), and an optional list of attribute pairs
|
4
|
+
as arguments.
|
5
|
+
|
6
|
+
A migration class is generated in test/app_root/db/migrate prefixed by a
|
7
|
+
timestamp of the current date and time.
|
8
|
+
|
9
|
+
Example:
|
10
|
+
`./script/generate plugin_test_migration has_comments AddPosts`
|
11
|
+
|
12
|
+
If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddPosts migration
|
13
|
+
db/migrate/20080514090912_add_posts.rb
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new model. Pass the plugin name, model name, either CamelCased or
|
3
|
+
under_scored, and an optional list of attribute pairs as arguments.
|
4
|
+
|
5
|
+
This generates a model class in test/app_root/app/models, a test fixture in
|
6
|
+
test/fixtures/singular_name.yml, and a migration in test/app_root/db/migrate.
|
7
|
+
|
8
|
+
Examples:
|
9
|
+
`./script/generate plugin_test_model has_comments post`
|
10
|
+
|
11
|
+
creates an Post model, fixture, and migration:
|
12
|
+
Model: test/app_root/app/models/post.rb
|
13
|
+
Fixtures: test/fixtures/posts.yml
|
14
|
+
Migration: test/app_root/db/migrate/XXX_add_posts.rb
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new test application. Pass the plugin name, under_scored.
|
3
|
+
|
4
|
+
This generates the application structure in test/app_root
|
5
|
+
|
6
|
+
Examples:
|
7
|
+
`./script/generate plugin_test_structure has_comments`
|
8
|
+
|
9
|
+
creates a controller and application configurations:
|
10
|
+
Controller: test/app_root/app/controllers/application.rb
|
11
|
+
Configurations: test/app_root/config/boot.rb
|
12
|
+
test/app_root/config/database.yml
|
13
|
+
test/app_root/config/environment.rb
|
14
|
+
test/app_root/config/routes.rb
|
15
|
+
test/app_root/config/environments/in_memory.rb
|
16
|
+
test/app_root/config/environments/mysql.rb
|
17
|
+
test/app_root/config/environments/postgresql.rb
|
18
|
+
test/app_root/config/environments/sqlite.rb
|
19
|
+
test/app_root/config/environments/sqlite3.rb
|
data/lib/plugin_test_helper.rb
CHANGED
@@ -16,8 +16,8 @@ require 'config/boot'
|
|
16
16
|
require 'plugin_test_helper/extensions/initializer'
|
17
17
|
|
18
18
|
# Load the Rails environment and testing framework
|
19
|
-
|
20
|
-
|
19
|
+
require 'config/environment'
|
20
|
+
require 'test_help'
|
21
21
|
|
22
22
|
# Undo changes to RAILS_ENV
|
23
23
|
silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# Loads fixtures into the database when running the test app via the console
|
1
2
|
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
|
2
3
|
Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
|
3
4
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'active_support'
|
2
1
|
require 'plugin_test_helper/plugin_locator'
|
3
2
|
|
4
3
|
module PluginAWeek #:nodoc:
|
@@ -9,7 +8,8 @@ module PluginAWeek #:nodoc:
|
|
9
8
|
module Initializer
|
10
9
|
def self.included(base)
|
11
10
|
base.class_eval do
|
12
|
-
|
11
|
+
alias_method :require_frameworks_without_test_helper, :require_frameworks
|
12
|
+
alias_method :require_frameworks, :require_frameworks_with_test_helper
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -18,7 +18,6 @@ module PluginAWeek #:nodoc:
|
|
18
18
|
require_frameworks_without_test_helper
|
19
19
|
|
20
20
|
require 'plugin_test_helper/generator'
|
21
|
-
require 'plugin_test_helper/extensions/routing'
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -27,13 +26,23 @@ module PluginAWeek #:nodoc:
|
|
27
26
|
# using the helper
|
28
27
|
module Configuration
|
29
28
|
def self.included(base) #:nodoc:
|
30
|
-
base
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
36
|
+
end
|
37
|
+
|
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
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
@@ -62,6 +71,12 @@ module PluginAWeek #:nodoc:
|
|
62
71
|
File.exists?(database_file) ? database_file : File.join(HELPER_RAILS_ROOT, 'config/database.yml')
|
63
72
|
end
|
64
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
|
+
|
65
80
|
# Add the helper's controllers path
|
66
81
|
def default_controller_paths_with_test_helper
|
67
82
|
paths = default_controller_paths_without_test_helper
|
@@ -77,7 +92,7 @@ module PluginAWeek #:nodoc:
|
|
77
92
|
# Add the helper's vendor/plugins path
|
78
93
|
def default_plugin_paths_with_test_helper
|
79
94
|
paths = default_plugin_paths_without_test_helper
|
80
|
-
paths << File.join(HELPER_RAILS_ROOT, '
|
95
|
+
paths << File.join(HELPER_RAILS_ROOT, 'vendor/plugins')
|
81
96
|
end
|
82
97
|
end
|
83
98
|
end
|
@@ -2,7 +2,8 @@ require 'rails_generator'
|
|
2
2
|
|
3
3
|
module PluginAWeek #:nodoc:
|
4
4
|
module PluginTestHelper
|
5
|
-
# The base generator for creating parts of the test application
|
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.
|
6
7
|
class Generator < Rails::Generator::NamedBase
|
7
8
|
attr_accessor :plugin_name
|
8
9
|
|
@@ -12,10 +13,12 @@ module PluginAWeek #:nodoc:
|
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
16
|
+
# The root path of the plugin's test directory
|
15
17
|
def plugin_test_root
|
16
18
|
"vendor/plugins/#{plugin_name}/test"
|
17
19
|
end
|
18
20
|
|
21
|
+
# The root path of the plugin's test app
|
19
22
|
def plugin_app_root
|
20
23
|
"#{plugin_test_root}/app_root"
|
21
24
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module PluginAWeek #:nodoc:
|
2
2
|
module PluginTestHelper
|
3
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
|
4
5
|
class PluginLocator < Rails::Plugin::Locator
|
5
6
|
def plugins
|
6
7
|
[Rails::Plugin.new(File.expand_path('.'))]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestConsoleGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_console, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_console', 'acts_as_foo'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_console
|
14
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/script/console")
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
teardown_app
|
19
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestControllerGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_controller, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_controller', 'acts_as_foo', 'site', 'index'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_controller
|
14
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/app/controllers/site_controller.rb")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_create_view
|
18
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/app/views/site/index.html.erb")
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
teardown_app
|
23
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestHelperGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_helper, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_helper', 'acts_as_foo'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_test_helper
|
14
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/test_helper.rb")
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
teardown_app
|
19
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestMigrationGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_migration, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_migration', 'acts_as_foo', 'create_bars'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_migration
|
14
|
+
migration_path = Dir["#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/db/migrate/*"].first
|
15
|
+
assert_not_nil migration_path
|
16
|
+
assert_match /^.*_create_bars.rb$/, migration_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
teardown_app
|
21
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestModelGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_model, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_model', 'acts_as_foo', 'bar'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_model
|
14
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/app/models/bar.rb")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_create_migration
|
18
|
+
migration_path = Dir["#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/db/migrate/*"].first
|
19
|
+
assert_not_nil migration_path
|
20
|
+
assert_match /^.*_create_bars.rb$/, migration_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_should_create_fixtures
|
24
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/fixtures/bars.yml")
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
teardown_app
|
29
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class PluginTestStructureGeneratorTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_app('empty')
|
6
|
+
|
7
|
+
require 'rails_generator'
|
8
|
+
require 'rails_generator/scripts/generate'
|
9
|
+
Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:plugin_test_structure, "#{Rails.root}/../../generators")
|
10
|
+
Rails::Generator::Scripts::Generate.new.run(['plugin_test_structure', 'acts_as_foo'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_create_application_controller
|
14
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/app/controllers/application.rb")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_create_in_memory_environment
|
18
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environments/in_memory.rb")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_create_mysql_environment
|
22
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environments/mysql.rb")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_create_postgresql_environment
|
26
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environments/postgresql.rb")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_create_sqlite_environment
|
30
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environments/sqlite.rb")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_should_create_sqlite3_environment
|
34
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environments/sqlite3.rb")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_create_boot_file
|
38
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/boot.rb")
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_create_database_configuration
|
42
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/database.yml")
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_should_create_environment_configuration
|
46
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/environment.rb")
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_create_routes
|
50
|
+
assert File.exists?("#{Rails.root}/vendor/plugins/acts_as_foo/test/app_root/config/routes.rb")
|
51
|
+
end
|
52
|
+
|
53
|
+
def teardown
|
54
|
+
teardown_app
|
55
|
+
FileUtils.rm_r(Dir.glob('test/app_root/*'))
|
56
|
+
end
|
57
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -26,5 +26,10 @@ class Test::Unit::TestCase
|
|
26
26
|
ActiveRecord::Base.reset_subclasses
|
27
27
|
Dependencies.clear
|
28
28
|
ActiveRecord::Base.clear_reloadable_connections!
|
29
|
+
|
30
|
+
# Forget that the environment files were loaded so that a new app environment
|
31
|
+
# can be set up again
|
32
|
+
$".delete('config/environment.rb')
|
33
|
+
$".delete('test_help.rb')
|
29
34
|
end
|
30
35
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plugin_test_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-07-13 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,17 +26,18 @@ files:
|
|
26
26
|
- generators/plugin_test_console/plugin_test_console_generator.rb
|
27
27
|
- generators/plugin_test_console/templates
|
28
28
|
- generators/plugin_test_console/templates/console
|
29
|
+
- generators/plugin_test_console/USAGE
|
29
30
|
- generators/plugin_test_helper
|
30
31
|
- generators/plugin_test_helper/templates
|
31
32
|
- generators/plugin_test_helper/templates/test_helper.rb
|
32
33
|
- generators/plugin_test_helper/plugin_test_helper_generator.rb
|
34
|
+
- generators/plugin_test_helper/USAGE
|
33
35
|
- generators/plugin_test_structure
|
34
36
|
- generators/plugin_test_structure/templates
|
35
37
|
- generators/plugin_test_structure/templates/app_root
|
36
38
|
- generators/plugin_test_structure/templates/app_root/app
|
37
39
|
- generators/plugin_test_structure/templates/app_root/app/controllers
|
38
40
|
- generators/plugin_test_structure/templates/app_root/app/controllers/application.rb
|
39
|
-
- generators/plugin_test_structure/templates/app_root/lib
|
40
41
|
- generators/plugin_test_structure/templates/app_root/config
|
41
42
|
- generators/plugin_test_structure/templates/app_root/config/environment.rb
|
42
43
|
- generators/plugin_test_structure/templates/app_root/config/environments
|
@@ -50,27 +51,30 @@ files:
|
|
50
51
|
- generators/plugin_test_structure/templates/app_root/config/database.yml
|
51
52
|
- generators/plugin_test_structure/templates/app_root/log
|
52
53
|
- generators/plugin_test_structure/plugin_test_structure_generator.rb
|
54
|
+
- generators/plugin_test_structure/USAGE
|
53
55
|
- generators/plugin_test_migration
|
54
56
|
- generators/plugin_test_migration/templates
|
55
57
|
- generators/plugin_test_migration/templates/migration.rb
|
56
58
|
- generators/plugin_test_migration/plugin_test_migration_generator.rb
|
59
|
+
- generators/plugin_test_migration/USAGE
|
57
60
|
- generators/plugin_test_controller
|
58
61
|
- generators/plugin_test_controller/templates
|
59
62
|
- generators/plugin_test_controller/templates/controller.rb
|
60
63
|
- generators/plugin_test_controller/templates/view.html.erb
|
61
64
|
- generators/plugin_test_controller/plugin_test_controller_generator.rb
|
65
|
+
- generators/plugin_test_controller/USAGE
|
62
66
|
- generators/plugin_test_model
|
63
67
|
- generators/plugin_test_model/plugin_test_model_generator.rb
|
64
68
|
- generators/plugin_test_model/templates
|
65
69
|
- generators/plugin_test_model/templates/model.rb
|
66
70
|
- generators/plugin_test_model/templates/fixtures.yml
|
67
71
|
- generators/plugin_test_model/templates/migration.rb
|
72
|
+
- generators/plugin_test_model/USAGE
|
68
73
|
- lib/plugin_test_helper.rb
|
69
74
|
- lib/plugin_test_helper
|
70
75
|
- lib/plugin_test_helper/console_with_fixtures.rb
|
71
76
|
- lib/plugin_test_helper/plugin_locator.rb
|
72
77
|
- lib/plugin_test_helper/extensions
|
73
|
-
- lib/plugin_test_helper/extensions/routing.rb
|
74
78
|
- lib/plugin_test_helper/extensions/initializer.rb
|
75
79
|
- lib/plugin_test_helper/generator.rb
|
76
80
|
- test/app_root
|
@@ -78,6 +82,12 @@ files:
|
|
78
82
|
- test/fixtures/people.yml
|
79
83
|
- test/functional
|
80
84
|
- test/functional/plugin_test_helper_test.rb
|
85
|
+
- test/functional/plugin_test_migration_generator_test.rb
|
86
|
+
- test/functional/plugin_test_controller_generator_test.rb
|
87
|
+
- test/functional/plugin_test_model_generator_test.rb
|
88
|
+
- test/functional/plugin_test_console_generator_test.rb
|
89
|
+
- test/functional/plugin_test_helper_generator_test.rb
|
90
|
+
- test/functional/plugin_test_structure_generator_test.rb
|
81
91
|
- test/test_helper.rb
|
82
92
|
- test/app_roots
|
83
93
|
- test/app_roots/with_model
|
@@ -126,11 +136,11 @@ files:
|
|
126
136
|
- test/app_roots/with_custom_application_controller/app/controllers/application.rb
|
127
137
|
- test/unit
|
128
138
|
- test/unit/plugin_locator_test.rb
|
129
|
-
- CHANGELOG
|
139
|
+
- CHANGELOG.rdoc
|
130
140
|
- init.rb
|
131
|
-
-
|
141
|
+
- LICENSE
|
132
142
|
- Rakefile
|
133
|
-
- README
|
143
|
+
- README.rdoc
|
134
144
|
has_rdoc: true
|
135
145
|
homepage: http://www.pluginaweek.org
|
136
146
|
post_install_message:
|
@@ -152,11 +162,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
162
|
version:
|
153
163
|
requirements: []
|
154
164
|
|
155
|
-
rubyforge_project:
|
165
|
+
rubyforge_project: pluginaweek
|
156
166
|
rubygems_version: 1.1.1
|
157
167
|
signing_key:
|
158
168
|
specification_version: 2
|
159
169
|
summary: Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.
|
160
170
|
test_files:
|
161
171
|
- test/functional/plugin_test_helper_test.rb
|
172
|
+
- test/functional/plugin_test_migration_generator_test.rb
|
173
|
+
- test/functional/plugin_test_controller_generator_test.rb
|
174
|
+
- test/functional/plugin_test_model_generator_test.rb
|
175
|
+
- test/functional/plugin_test_console_generator_test.rb
|
176
|
+
- test/functional/plugin_test_helper_generator_test.rb
|
177
|
+
- test/functional/plugin_test_structure_generator_test.rb
|
162
178
|
- test/unit/plugin_locator_test.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module PluginAWeek #:nodoc:
|
2
|
-
module PluginTestHelper
|
3
|
-
module Extensions #:nodoc:
|
4
|
-
# Overrides where the path of the application routes is located so that
|
5
|
-
# it defaults to this helper's implementation or can be overridden by the
|
6
|
-
# plugin using this helper
|
7
|
-
module Routing
|
8
|
-
def self.included(base)
|
9
|
-
base.class_eval do
|
10
|
-
alias_method_chain :reload, :test_helper
|
11
|
-
alias_method_chain :load_routes!, :test_helper
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# Load routes from either the helper or the plugin
|
16
|
-
def reload_with_test_helper
|
17
|
-
if @routes_last_modified && defined?(Rails.root)
|
18
|
-
routes_path = File.join("#{Rails.root}/config/routes.rb")
|
19
|
-
routes_path = File.join("#{HELPER_RAILS_ROOT}/config/routes.rb") unless File.exists?(routes_path)
|
20
|
-
|
21
|
-
mtime = File.stat(routes_path).mtime
|
22
|
-
# if it hasn't been changed, then just return
|
23
|
-
return if mtime == @routes_last_modified
|
24
|
-
# if it has changed then record the new time and fall to the load! below
|
25
|
-
@routes_last_modified = mtime
|
26
|
-
end
|
27
|
-
load!
|
28
|
-
end
|
29
|
-
|
30
|
-
# Load routes from either the helper or the plugin
|
31
|
-
def load_routes_with_test_helper!
|
32
|
-
if defined?(Rails.root) && defined?(::ActionController::Routing::Routes) && self == ::ActionController::Routing::Routes
|
33
|
-
routes_path = File.join("#{Rails.root}/config/routes.rb")
|
34
|
-
routes_path = File.join("#{HELPER_RAILS_ROOT}/config/routes.rb") unless File.exists?(routes_path)
|
35
|
-
|
36
|
-
load File.join(routes_path)
|
37
|
-
@routes_last_modified = File.stat(routes_path).mtime
|
38
|
-
else
|
39
|
-
add_route ":controller/:action/:id"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
ActionController::Routing::RouteSet.class_eval do
|
48
|
-
include PluginAWeek::PluginTestHelper::Extensions::Routing
|
49
|
-
end
|