enginex 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/Rakefile +1 -1
- data/lib/enginex.rb +31 -8
- data/lib/templates/root/Gemfile.tt +6 -2
- data/lib/templates/root/MIT-LICENSE.tt +20 -0
- data/lib/templates/root/README.rdoc.tt +3 -0
- data/lib/templates/root/Rakefile.tt +11 -1
- data/lib/templates/spec/%underscored%_spec.rb.tt +7 -0
- data/lib/templates/spec/integration/navigation_spec.rb.tt +9 -0
- data/lib/templates/spec/spec_helper.rb +28 -0
- data/lib/templates/{root/test → test}/%underscored%_test.rb.tt +0 -0
- data/lib/templates/{root/test → test}/integration/navigation_test.rb.tt +0 -0
- data/lib/templates/{root/test → test}/test_helper.rb +0 -0
- data/test/enginex/1/demo_engine/lib/demo_engine.rb +2 -0
- data/test/enginex/1/demo_engine/spec/demo_engine_spec.rb +7 -0
- data/test/enginex/1/demo_engine/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/test/enginex/1/demo_engine/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/application.rb +46 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/boot.rb +9 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/environment.rb +5 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/environments/development.rb +19 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/environments/production.rb +42 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/environments/test.rb +32 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/initializers/cookie_verification_secret.rb +7 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/initializers/inflections.rb +10 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/initializers/session_store.rb +10 -0
- data/test/enginex/1/demo_engine/spec/dummy/config/routes.rb +58 -0
- data/test/enginex/1/demo_engine/spec/integration/navigation_spec.rb +9 -0
- data/test/enginex/1/demo_engine/spec/spec_helper.rb +28 -0
- data/test/enginex_test.rb +24 -4
- data/test/test_helper.rb +8 -2
- metadata +29 -6
data/README.rdoc
CHANGED
@@ -8,6 +8,8 @@ Enginex is going to be used in José Valim's upcoming book for Rails 3.
|
|
8
8
|
|
9
9
|
$ enginex ENGINE_NAME
|
10
10
|
|
11
|
+
Give --help to see supported options.
|
12
|
+
|
11
13
|
== Bugs and Feedback
|
12
14
|
|
13
15
|
If you discover any bugs, feel free to send me a message or create an issue on GitHub tracker:
|
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ begin
|
|
23
23
|
require 'jeweler'
|
24
24
|
Jeweler::Tasks.new do |s|
|
25
25
|
s.name = "enginex"
|
26
|
-
s.version = Enginex::VERSION
|
26
|
+
s.version = Enginex::VERSION.dup
|
27
27
|
s.summary = "Creates a Rails 3 engine with Rakefile, Gemfile and running tests"
|
28
28
|
s.email = "jose.valim@plataformatec.com.br"
|
29
29
|
s.homepage = "http://github.com/josevalim/enginex"
|
data/lib/enginex.rb
CHANGED
@@ -4,10 +4,10 @@ require "active_support/version"
|
|
4
4
|
require "active_support/core_ext/string"
|
5
5
|
|
6
6
|
require "rails/generators"
|
7
|
-
require "generators/rails/app/app_generator"
|
7
|
+
require "rails/generators/rails/app/app_generator"
|
8
8
|
|
9
9
|
class Enginex < Thor::Group
|
10
|
-
VERSION = "0.
|
10
|
+
VERSION = "0.4.0".freeze
|
11
11
|
|
12
12
|
include Thor::Actions
|
13
13
|
check_unknown_options!
|
@@ -29,6 +29,9 @@ class Enginex < Thor::Group
|
|
29
29
|
argument :path, :type => :string,
|
30
30
|
:desc => "Path to the engine to be created"
|
31
31
|
|
32
|
+
class_option :test_framework, :default => "test_unit", :aliases => "-t",
|
33
|
+
:desc => "Test framework to use. test_unit or rspec."
|
34
|
+
|
32
35
|
desc "Creates a Rails 3 engine with Rakefile, Gemfile and running tests."
|
33
36
|
|
34
37
|
say_step "Creating gem skeleton"
|
@@ -41,6 +44,10 @@ class Enginex < Thor::Group
|
|
41
44
|
FileUtils.cd(destination_root)
|
42
45
|
end
|
43
46
|
|
47
|
+
def create_tests_or_specs
|
48
|
+
directory test_path
|
49
|
+
end
|
50
|
+
|
44
51
|
def copy_gitignore
|
45
52
|
copy_file "gitignore", ".gitignore"
|
46
53
|
end
|
@@ -49,16 +56,16 @@ class Enginex < Thor::Group
|
|
49
56
|
|
50
57
|
def invoke_rails_app_generator
|
51
58
|
invoke Rails::Generators::AppGenerator,
|
52
|
-
[ File.expand_path(
|
59
|
+
[ File.expand_path(dummy_path, destination_root) ]
|
53
60
|
end
|
54
61
|
|
55
62
|
say_step "Configuring Rails application"
|
56
63
|
|
57
64
|
def change_config_files
|
58
65
|
store_application_definition!
|
59
|
-
template "rails/boot.rb", "
|
60
|
-
template "rails/application.rb", "
|
61
|
-
gsub_file "
|
66
|
+
template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
|
67
|
+
template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
|
68
|
+
gsub_file "#{dummy_path}/config/environments/test.rb", "end\n", <<-CONTENT
|
62
69
|
|
63
70
|
# Remove show exceptions middleware from tests, so we always Ruby failures.
|
64
71
|
config.middleware.delete "ActionDispatch::ShowExceptions"
|
@@ -69,7 +76,7 @@ end
|
|
69
76
|
say_step "Removing unneeded files"
|
70
77
|
|
71
78
|
def remove_uneeded_rails_files
|
72
|
-
inside
|
79
|
+
inside dummy_path do
|
73
80
|
remove_file ".gitignore"
|
74
81
|
remove_file "db/seeds.rb"
|
75
82
|
remove_file "doc"
|
@@ -87,13 +94,29 @@ end
|
|
87
94
|
|
88
95
|
protected
|
89
96
|
|
97
|
+
def rspec?
|
98
|
+
options[:test_framework] == "rspec"
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_unit?
|
102
|
+
options[:test_framework] == "test_unit"
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_path
|
106
|
+
rspec? ? "spec" : "test"
|
107
|
+
end
|
108
|
+
|
109
|
+
def dummy_path
|
110
|
+
"#{test_path}/dummy"
|
111
|
+
end
|
112
|
+
|
90
113
|
def self.banner
|
91
114
|
self_task.formatted_usage(self, false)
|
92
115
|
end
|
93
116
|
|
94
117
|
def application_definition
|
95
118
|
@application_definition ||= begin
|
96
|
-
contents = File.read(File.expand_path("
|
119
|
+
contents = File.read(File.expand_path("#{dummy_path}/config/application.rb", destination_root))
|
97
120
|
contents[(contents.index("module Dummy"))..-1]
|
98
121
|
end
|
99
122
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
source "http://gemcutter.org"
|
2
2
|
|
3
3
|
gem "rails", "<%= ActiveSupport::VERSION::STRING %>"
|
4
|
-
gem "capybara", "0.3.
|
4
|
+
gem "capybara", "0.3.6"
|
5
5
|
gem "sqlite3-ruby", :require => "sqlite3"
|
6
6
|
|
7
7
|
if RUBY_VERSION < '1.9'
|
8
8
|
gem "ruby-debug", ">= 0.10.3"
|
9
|
-
end
|
9
|
+
end
|
10
|
+
|
11
|
+
<% if rspec? %>
|
12
|
+
gem "rspec-rails", ">= 2.0.0.beta"
|
13
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright <%= Date.today.year %> YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,15 +1,25 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
3
|
require 'rake/rdoctask'
|
5
4
|
require 'rake/gempackagetask'
|
6
5
|
|
6
|
+
<% if rspec? -%>
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
|
10
|
+
Rspec::Core::RakeTask.new(:spec)
|
11
|
+
<% else -%>
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
7
14
|
Rake::TestTask.new(:test) do |t|
|
8
15
|
t.libs << 'lib'
|
9
16
|
t.libs << 'test'
|
10
17
|
t.pattern = 'test/**/*_test.rb'
|
11
18
|
t.verbose = false
|
12
19
|
end
|
20
|
+
<% end -%>
|
21
|
+
|
22
|
+
task :default => :<%= test_path %>
|
13
23
|
|
14
24
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
15
25
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
ActionMailer::Base.delivery_method = :test
|
8
|
+
ActionMailer::Base.perform_deliveries = true
|
9
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
require "capybara/rails"
|
14
|
+
Capybara.default_driver = :rack_test
|
15
|
+
|
16
|
+
require 'rspec/rails'
|
17
|
+
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
Rspec.configure do |config|
|
21
|
+
# Remove this line if you don't want Rspec's should and should_not
|
22
|
+
# methods or matchers
|
23
|
+
require 'rspec/expectations'
|
24
|
+
config.include Rspec::Matchers
|
25
|
+
|
26
|
+
# == Mock Framework
|
27
|
+
config.mock_with :rspec
|
28
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "demo_engine"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Add additional load paths for your own custom dirs
|
19
|
+
# config.load_paths += %W( #{config.root}/extras )
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# Configure generators values. Many other options are available, be sure to check the documentation.
|
37
|
+
# config.generators do |g|
|
38
|
+
# g.orm :active_record
|
39
|
+
# g.template_engine :erb
|
40
|
+
# g.test_framework :test_unit, :fixture => true
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
44
|
+
config.filter_parameters << :password
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Disable request forgery protection in test environment
|
18
|
+
config.action_controller.allow_forgery_protection = false
|
19
|
+
|
20
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
21
|
+
# The :test delivery method accumulates sent emails in the
|
22
|
+
# ActionMailer::Base.deliveries array.
|
23
|
+
config.action_mailer.delivery_method = :test
|
24
|
+
|
25
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
26
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
27
|
+
# like if you have constraints or database-specific column types
|
28
|
+
# config.active_record.schema_format = :sql
|
29
|
+
|
30
|
+
# Remove show exceptions middleware from tests, so we always Ruby failures.
|
31
|
+
config.middleware.delete "ActionDispatch::ShowExceptions"
|
32
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Rails.application.config.cookie_secret = '29f0bc895a00b0101744606e9d08d58f20719a2a49fb965eeb1ebd906c3bfae71dc8e7b555f1f064a854d5f3f24905d61a5d150d27db31a97b8eb6696b04d2f3'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Rails.application.config.session_store :cookie_store, {
|
4
|
+
:key => '_dummy_session',
|
5
|
+
}
|
6
|
+
|
7
|
+
# Use the database for sessions instead of the cookie-based default,
|
8
|
+
# which shouldn't be used to store highly confidential information
|
9
|
+
# (create the session table with "rake db:sessions:create")
|
10
|
+
# Rails.application.config.session_store :active_record_store
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get :short
|
20
|
+
# post :toggle
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get :sold
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get :recent, :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => "welcome#index"
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id(.:format)))'
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
ActionMailer::Base.delivery_method = :test
|
8
|
+
ActionMailer::Base.perform_deliveries = true
|
9
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
require "capybara/rails"
|
14
|
+
Capybara.default_driver = :rack_test
|
15
|
+
|
16
|
+
require 'rspec/rails'
|
17
|
+
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
Rspec.configure do |config|
|
21
|
+
# Remove this line if you don't want Rspec's should and should_not
|
22
|
+
# methods or matchers
|
23
|
+
require 'rspec/expectations'
|
24
|
+
config.include Rspec::Matchers
|
25
|
+
|
26
|
+
# == Mock Framework
|
27
|
+
config.mock_with :rspec
|
28
|
+
end
|
data/test/enginex_test.rb
CHANGED
@@ -11,17 +11,31 @@ class EnginexTest < ActiveSupport::TestCase
|
|
11
11
|
# Lib
|
12
12
|
assert_file "lib/demo_engine.rb", /module DemoEngine\nend/
|
13
13
|
|
14
|
-
#
|
14
|
+
# Vendored Rails
|
15
|
+
assert_file "test/dummy/config/application.rb"
|
16
|
+
assert_file "test/dummy/config/environments/test.rb", /ActionDispatch::ShowExceptions/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
test "enginex skeleton with test_unit" do
|
21
|
+
run_enginex do
|
15
22
|
assert_file "test/test_helper.rb"
|
16
23
|
assert_directory "test/support/"
|
17
24
|
assert_directory "test/integration/"
|
18
25
|
|
19
26
|
assert_file "test/demo_engine_test.rb", /assert_kind_of Module, DemoEngine/
|
20
27
|
assert_file "test/integration/navigation_test.rb", /assert_kind_of Dummy::Application, Rails.application/
|
28
|
+
end
|
29
|
+
end
|
21
30
|
|
22
|
-
|
23
|
-
|
24
|
-
assert_file "
|
31
|
+
test "enginex skeleton with rspec" do
|
32
|
+
run_enginex(:rspec) do
|
33
|
+
assert_file "spec/spec_helper.rb"
|
34
|
+
assert_directory "spec/support/"
|
35
|
+
assert_directory "spec/integration/"
|
36
|
+
|
37
|
+
assert_file "spec/demo_engine_spec.rb", /DemoEngine.should be_a\(Module\)/
|
38
|
+
assert_file "spec/integration/navigation_spec.rb", /Rails.application.should be_a\(Dummy::Application\)/
|
25
39
|
end
|
26
40
|
end
|
27
41
|
|
@@ -37,4 +51,10 @@ class EnginexTest < ActiveSupport::TestCase
|
|
37
51
|
assert_match /2 tests, 2 assertions, 0 failures, 0 errors/, execute("rake test")
|
38
52
|
end
|
39
53
|
end
|
54
|
+
|
55
|
+
test "enginex can run specs" do
|
56
|
+
run_enginex(:rspec) do
|
57
|
+
assert_match /2 examples, 0 failures/, execute("rake spec")
|
58
|
+
end
|
59
|
+
end
|
40
60
|
end
|
data/test/test_helper.rb
CHANGED
@@ -22,9 +22,15 @@ $:.unshift LIB_PATH
|
|
22
22
|
require 'enginex'
|
23
23
|
|
24
24
|
class ActiveSupport::TestCase
|
25
|
-
def run_enginex
|
25
|
+
def run_enginex(suite = :test_unit)
|
26
|
+
if suite == :rspec
|
27
|
+
option = '--test-framework=rspec'
|
28
|
+
else
|
29
|
+
option = '--test-framework=test_unit'
|
30
|
+
end
|
31
|
+
|
26
32
|
$counter += 1
|
27
|
-
`ruby -I#{LIB_PATH} -rrubygems #{BIN_PATH} #{destination_root}`
|
33
|
+
`ruby -I#{LIB_PATH} -rrubygems #{BIN_PATH} #{destination_root} #{option}`
|
28
34
|
yield
|
29
35
|
FileUtils.rm_rf(File.dirname(destination_root))
|
30
36
|
rescue Exception => e
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 4
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Jos\xC3\xA9 Valim"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-04 00:00:00 +02:00
|
18
18
|
default_executable: enginex
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -89,11 +89,16 @@ files:
|
|
89
89
|
- lib/templates/rails/application.rb
|
90
90
|
- lib/templates/rails/boot.rb
|
91
91
|
- lib/templates/root/Gemfile.tt
|
92
|
+
- lib/templates/root/MIT-LICENSE.tt
|
93
|
+
- lib/templates/root/README.rdoc.tt
|
92
94
|
- lib/templates/root/Rakefile.tt
|
93
95
|
- lib/templates/root/lib/%underscored%.rb.tt
|
94
|
-
- lib/templates/
|
95
|
-
- lib/templates/
|
96
|
-
- lib/templates/
|
96
|
+
- lib/templates/spec/%underscored%_spec.rb.tt
|
97
|
+
- lib/templates/spec/integration/navigation_spec.rb.tt
|
98
|
+
- lib/templates/spec/spec_helper.rb
|
99
|
+
- lib/templates/test/%underscored%_test.rb.tt
|
100
|
+
- lib/templates/test/integration/navigation_test.rb.tt
|
101
|
+
- lib/templates/test/test_helper.rb
|
97
102
|
has_rdoc: true
|
98
103
|
homepage: http://github.com/josevalim/enginex
|
99
104
|
licenses: []
|
@@ -125,5 +130,23 @@ signing_key:
|
|
125
130
|
specification_version: 3
|
126
131
|
summary: Creates a Rails 3 engine with Rakefile, Gemfile and running tests
|
127
132
|
test_files:
|
133
|
+
- test/enginex/1/demo_engine/lib/demo_engine.rb
|
134
|
+
- test/enginex/1/demo_engine/spec/demo_engine_spec.rb
|
135
|
+
- test/enginex/1/demo_engine/spec/dummy/app/controllers/application_controller.rb
|
136
|
+
- test/enginex/1/demo_engine/spec/dummy/app/helpers/application_helper.rb
|
137
|
+
- test/enginex/1/demo_engine/spec/dummy/config/application.rb
|
138
|
+
- test/enginex/1/demo_engine/spec/dummy/config/boot.rb
|
139
|
+
- test/enginex/1/demo_engine/spec/dummy/config/environment.rb
|
140
|
+
- test/enginex/1/demo_engine/spec/dummy/config/environments/development.rb
|
141
|
+
- test/enginex/1/demo_engine/spec/dummy/config/environments/production.rb
|
142
|
+
- test/enginex/1/demo_engine/spec/dummy/config/environments/test.rb
|
143
|
+
- test/enginex/1/demo_engine/spec/dummy/config/initializers/backtrace_silencers.rb
|
144
|
+
- test/enginex/1/demo_engine/spec/dummy/config/initializers/cookie_verification_secret.rb
|
145
|
+
- test/enginex/1/demo_engine/spec/dummy/config/initializers/inflections.rb
|
146
|
+
- test/enginex/1/demo_engine/spec/dummy/config/initializers/mime_types.rb
|
147
|
+
- test/enginex/1/demo_engine/spec/dummy/config/initializers/session_store.rb
|
148
|
+
- test/enginex/1/demo_engine/spec/dummy/config/routes.rb
|
149
|
+
- test/enginex/1/demo_engine/spec/integration/navigation_spec.rb
|
150
|
+
- test/enginex/1/demo_engine/spec/spec_helper.rb
|
128
151
|
- test/enginex_test.rb
|
129
152
|
- test/test_helper.rb
|