plugin_test_helper 0.0.1 → 0.0.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  *SVN*
2
2
 
3
+ *0.0.2* (August 15th, 2007)
4
+
5
+ * Autoload plugin even if the plugin doesn't define an app_root
6
+
7
+ * A proxy plugin for the plugin being tested is no longer needed in favor of doing selective plugin loading.
8
+
9
+ * Make sure RAILS_ROOT is in the load path
10
+
11
+ * Automate setting of the fixtures path
12
+
13
+ * Load test_help instead of test/unit so that additional libraries are automatically loaded like they are in your application's tests
14
+
3
15
  *0.0.1* (May 31st, 2007)
4
16
 
5
- * Initial release
17
+ * Initial release
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2006 Aaron Pfeifer & Neil Abraham
1
+ Copyright (c) 2006-2007 Aaron Pfeifer & Neil Abraham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -67,6 +67,14 @@ The following generators are available:
67
67
  * plugin_test_controller
68
68
  * plugin_test_migration
69
69
 
70
+ +NOTE+ that you +DO NOT+ need to generate the entire application structure. All
71
+ that is required is that your test helper load plugin_test_helper. If you do
72
+ not define a part of the test application (such as the environment
73
+ configurations or the database configuration), then it will use the existing
74
+ implementation in plugin_test_helper/generators/plugin_test_structure/templates.
75
+ +However+, you can override any of these files by simply defining them in your
76
+ plugin, using the same directory structure.
77
+
70
78
  === plugin_test_helper
71
79
 
72
80
  Generates a test helper file that should be required by all unit/functional/integration
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  require 'rake/contrib/sshpublisher'
5
5
 
6
6
  PKG_NAME = 'plugin_test_helper'
7
- PKG_VERSION = '0.0.1'
7
+ PKG_VERSION = '0.0.2'
8
8
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
9
9
  RUBY_FORGE_PROJECT = 'pluginaweek'
10
10
 
@@ -31,7 +31,7 @@ spec = Gem::Specification.new do |s|
31
31
  s.name = PKG_NAME
32
32
  s.version = PKG_VERSION
33
33
  s.platform = Gem::Platform::RUBY
34
- s.summary = ''
34
+ s.summary = 'Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.'
35
35
 
36
36
  s.files = FileList['{generators,lib}/**/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
37
37
  s.require_path = 'lib'
@@ -2,13 +2,8 @@
2
2
  # ENV['RAILS_ENV'] ||= 'your_env'
3
3
 
4
4
  # Load the plugin testing framework
5
+ require 'rubygems'
5
6
  require 'plugin_test_helper'
6
7
 
7
- # Load the Rails environment
8
- require 'config/environment'
9
-
10
- # Load the unit testing framework
11
- require 'test/unit'
12
-
13
8
  # Run the migrations (optional)
14
9
  ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
@@ -6,6 +6,8 @@ Rails::Initializer.run do |config|
6
6
  config.whiny_nils = true
7
7
  config.breakpoint_server = true
8
8
  config.load_paths << "#{RAILS_ROOT}/../../lib"
9
+ config.plugin_paths << '..'
10
+ config.plugins = [File.basename(File.expand_path('.'))]
9
11
  end
10
12
 
11
- Dependencies.log_activity = true
13
+ Dependencies.log_activity = true
@@ -2,6 +2,20 @@
2
2
  HELPER_RAILS_ROOT = "#{File.dirname(__FILE__)}/../generators/plugin_test_structure/templates/app_root"
3
3
  $:.unshift(HELPER_RAILS_ROOT)
4
4
 
5
+ # Determine the plugin's root test directory and add it to the load path
6
+ unless defined?(RAILS_ROOT)
7
+ root_path = File.join(File.expand_path('.'), 'test/app_root')
8
+
9
+ unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
10
+ require 'pathname'
11
+ root_path = Pathname.new(root_path).cleanpath(true).to_s
12
+ end
13
+
14
+ RAILS_ROOT = root_path
15
+ end
16
+
17
+ $:.unshift(RAILS_ROOT)
18
+
5
19
  # Set the default environment to sqlite3's in_memory database
6
20
  ENV['RAILS_ENV'] ||= 'in_memory'
7
21
 
@@ -16,6 +30,15 @@ require 'plugin_test_helper/generator'
16
30
  require 'plugin_test_helper/extensions/initializer'
17
31
  require 'plugin_test_helper/extensions/routing'
18
32
 
19
- # Load the Rails environment and unit testing framework
33
+ # Load the Rails environment and testing framework
20
34
  require 'config/environment'
21
- require 'test/unit'
35
+ require 'test_help'
36
+
37
+ # Undo changes to RAILS_ENV
38
+ silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
39
+
40
+ # Set default fixture loading properties
41
+ class Test::Unit::TestCase #:nodoc:
42
+ self.use_transactional_fixtures = true
43
+ self.use_instantiated_fixtures = false
44
+ end
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: plugin_test_helper
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2007-05-31 00:00:00 -04:00
8
- summary: ""
6
+ version: 0.0.2
7
+ date: 2007-08-15 00:00:00 -04:00
8
+ summary: Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application.
9
9
  require_paths:
10
10
  - lib
11
11
  email: info@pluginaweek.org
@@ -30,53 +30,51 @@ authors:
30
30
  - Aaron Pfeifer, Neil Abraham
31
31
  files:
32
32
  - generators/plugin_test_migration
33
- - generators/plugin_test_model
34
33
  - generators/plugin_test_helper
35
- - generators/plugin_test_structure
34
+ - generators/plugin_test_model
36
35
  - generators/plugin_test_controller
37
- - generators/plugin_test_migration/plugin_test_migration_generator.rb
36
+ - generators/plugin_test_structure
38
37
  - generators/plugin_test_migration/templates
38
+ - generators/plugin_test_migration/plugin_test_migration_generator.rb
39
39
  - generators/plugin_test_migration/templates/migration.rb
40
- - generators/plugin_test_model/plugin_test_model_generator.rb
41
- - generators/plugin_test_model/templates
42
- - generators/plugin_test_model/templates/fixtures.yml
43
- - generators/plugin_test_model/templates/model.rb
44
- - generators/plugin_test_model/templates/migration.rb
45
- - generators/plugin_test_helper/templates
46
40
  - generators/plugin_test_helper/plugin_test_helper_generator.rb
41
+ - generators/plugin_test_helper/templates
47
42
  - generators/plugin_test_helper/templates/test_helper.rb
48
- - generators/plugin_test_structure/plugin_test_structure_generator.rb
43
+ - generators/plugin_test_model/templates
44
+ - generators/plugin_test_model/plugin_test_model_generator.rb
45
+ - generators/plugin_test_model/templates/migration.rb
46
+ - generators/plugin_test_model/templates/model.rb
47
+ - generators/plugin_test_model/templates/fixtures.yml
48
+ - generators/plugin_test_controller/templates
49
+ - generators/plugin_test_controller/plugin_test_controller_generator.rb
50
+ - generators/plugin_test_controller/templates/controller.rb
51
+ - generators/plugin_test_controller/templates/view.rhtml
49
52
  - generators/plugin_test_structure/templates
53
+ - generators/plugin_test_structure/plugin_test_structure_generator.rb
50
54
  - generators/plugin_test_structure/templates/app_root
55
+ - generators/plugin_test_structure/templates/app_root/lib
51
56
  - generators/plugin_test_structure/templates/app_root/vendor
52
57
  - generators/plugin_test_structure/templates/app_root/config
53
58
  - generators/plugin_test_structure/templates/app_root/app
54
- - generators/plugin_test_structure/templates/app_root/lib
55
59
  - generators/plugin_test_structure/templates/app_root/vendor/plugins
56
- - generators/plugin_test_structure/templates/app_root/vendor/plugins/plugin_proxy
57
- - generators/plugin_test_structure/templates/app_root/vendor/plugins/plugin_proxy/init.rb
58
- - generators/plugin_test_structure/templates/app_root/config/environments
59
60
  - generators/plugin_test_structure/templates/app_root/config/routes.rb
61
+ - generators/plugin_test_structure/templates/app_root/config/environments
60
62
  - generators/plugin_test_structure/templates/app_root/config/boot.rb
61
- - generators/plugin_test_structure/templates/app_root/config/environment.rb
62
63
  - generators/plugin_test_structure/templates/app_root/config/database.yml
64
+ - generators/plugin_test_structure/templates/app_root/config/environment.rb
63
65
  - generators/plugin_test_structure/templates/app_root/config/environments/sqlite.rb
64
- - generators/plugin_test_structure/templates/app_root/config/environments/sqlite3.rb
65
66
  - generators/plugin_test_structure/templates/app_root/config/environments/mysql.rb
67
+ - generators/plugin_test_structure/templates/app_root/config/environments/sqlite3.rb
66
68
  - generators/plugin_test_structure/templates/app_root/config/environments/in_memory.rb
67
69
  - generators/plugin_test_structure/templates/app_root/config/environments/postgresql.rb
68
70
  - generators/plugin_test_structure/templates/app_root/app/controllers
69
71
  - generators/plugin_test_structure/templates/app_root/app/controllers/application.rb
70
- - generators/plugin_test_controller/plugin_test_controller_generator.rb
71
- - generators/plugin_test_controller/templates
72
- - generators/plugin_test_controller/templates/view.rhtml
73
- - generators/plugin_test_controller/templates/controller.rb
74
- - lib/plugin_test_helper.rb
75
72
  - lib/plugin_test_helper
73
+ - lib/plugin_test_helper.rb
76
74
  - lib/plugin_test_helper/extensions
77
75
  - lib/plugin_test_helper/generator.rb
78
- - lib/plugin_test_helper/extensions/initializer.rb
79
76
  - lib/plugin_test_helper/extensions/routing.rb
77
+ - lib/plugin_test_helper/extensions/initializer.rb
80
78
  - CHANGELOG
81
79
  - init.rb
82
80
  - MIT-LICENSE
@@ -1,4 +0,0 @@
1
- # Automatically load the plugin being tested as if it were being loaded in an
2
- # actual application
3
- init_path = "#{RAILS_ROOT}/../../init.rb"
4
- silence_warnings { eval(IO.read(init_path), binding, init_path) } if File.exists?(init_path)