diesel 0.1.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/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+ gem "cucumber"
3
+ gem "aruba"
4
+ gem "rake"
5
+ gem "rspec-rails", :require => false
6
+ gem "rails", ">= 3.0.3", :require => false
7
+ gem "thin"
8
+ gem "sqlite3-ruby", :require => false
9
+
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.3)
19
+ activesupport (= 3.0.3)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4)
22
+ activerecord (3.0.3)
23
+ activemodel (= 3.0.3)
24
+ activesupport (= 3.0.3)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ activesupport (3.0.3)
31
+ arel (2.0.6)
32
+ aruba (0.2.7)
33
+ background_process
34
+ cucumber (~> 0.10.0)
35
+ background_process (1.2)
36
+ builder (2.1.2)
37
+ cucumber (0.10.0)
38
+ builder (>= 2.1.2)
39
+ diff-lcs (~> 1.1.2)
40
+ gherkin (~> 2.3.2)
41
+ json (~> 1.4.6)
42
+ term-ansicolor (~> 1.0.5)
43
+ daemons (1.1.0)
44
+ diff-lcs (1.1.2)
45
+ erubis (2.6.6)
46
+ abstract (>= 1.0.0)
47
+ eventmachine (0.12.10)
48
+ gherkin (2.3.2)
49
+ json (~> 1.4.6)
50
+ term-ansicolor (~> 1.0.5)
51
+ i18n (0.5.0)
52
+ json (1.4.6)
53
+ mail (2.2.12)
54
+ activesupport (>= 2.3.6)
55
+ i18n (>= 0.4.0)
56
+ mime-types (~> 1.16)
57
+ treetop (~> 1.4.8)
58
+ mime-types (1.16)
59
+ polyglot (0.3.1)
60
+ rack (1.2.1)
61
+ rack-mount (0.6.13)
62
+ rack (>= 1.0.0)
63
+ rack-test (0.5.6)
64
+ rack (>= 1.0)
65
+ rails (3.0.3)
66
+ actionmailer (= 3.0.3)
67
+ actionpack (= 3.0.3)
68
+ activerecord (= 3.0.3)
69
+ activeresource (= 3.0.3)
70
+ activesupport (= 3.0.3)
71
+ bundler (~> 1.0)
72
+ railties (= 3.0.3)
73
+ railties (3.0.3)
74
+ actionpack (= 3.0.3)
75
+ activesupport (= 3.0.3)
76
+ rake (>= 0.8.7)
77
+ thor (~> 0.14.4)
78
+ rake (0.8.7)
79
+ rspec (2.3.0)
80
+ rspec-core (~> 2.3.0)
81
+ rspec-expectations (~> 2.3.0)
82
+ rspec-mocks (~> 2.3.0)
83
+ rspec-core (2.3.1)
84
+ rspec-expectations (2.3.0)
85
+ diff-lcs (~> 1.1.2)
86
+ rspec-mocks (2.3.0)
87
+ rspec-rails (2.3.1)
88
+ actionpack (~> 3.0)
89
+ activesupport (~> 3.0)
90
+ railties (~> 3.0)
91
+ rspec (~> 2.3.0)
92
+ sqlite3-ruby (1.3.2)
93
+ term-ansicolor (1.0.5)
94
+ thin (1.2.7)
95
+ daemons (>= 1.0.9)
96
+ eventmachine (>= 0.12.6)
97
+ rack (>= 1.0.0)
98
+ thor (0.14.6)
99
+ treetop (1.4.9)
100
+ polyglot (>= 0.3.1)
101
+ tzinfo (0.3.23)
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ aruba
108
+ cucumber
109
+ rails (>= 3.0.3)
110
+ rake
111
+ rspec-rails
112
+ sqlite3-ruby
113
+ thin
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rake'
4
+ require 'rake/gempackagetask'
5
+ require 'cucumber/rake/task'
6
+
7
+ desc 'Default: run all tests'
8
+ task :default => [:cucumber]
9
+
10
+ Cucumber::Rake::Task.new(:cucumber) do |t|
11
+ t.fork = true
12
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
13
+ end
14
+
15
+ eval("$specification = begin; #{IO.read('diesel.gemspec')}; end")
16
+ Rake::GemPackageTask.new($specification) do |package|
17
+ package.need_zip = true
18
+ package.need_tar = true
19
+ end
20
+
@@ -0,0 +1,64 @@
1
+ @disable-bundler
2
+ Feature: test a diesel engine using cucumber
3
+
4
+ Scenario: create a disel engine and test using cucumber
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "Gemfile" with:
8
+ """
9
+ gem "cucumber-rails", "~> 0.3.2"
10
+ gem "capybara", "~> 0.4.0"
11
+ gem "rails", "~> 3.0.3"
12
+ gem "rspec", "~> 1.3.0"
13
+ gem "sqlite3-ruby"
14
+ """
15
+ When I add this library as a dependency
16
+ When I write to "features/hello.feature" with:
17
+ """
18
+ Feature: say hello
19
+ Scenario: go to the hello page
20
+ When I go to /hello
21
+ Then I should see "hello!"
22
+ """
23
+ When I write to "features/step_definitions/hello_steps.rb" with:
24
+ """
25
+ When /^I go to (\/.+)$/ do |path|
26
+ visit path
27
+ end
28
+
29
+ Then /^I should see "([^"]*)"$/ do |text|
30
+ page.should have_content(text)
31
+ end
32
+ """
33
+ When I write to "features/support/env.rb" with:
34
+ """
35
+ ENV["RAILS_ENV"] ||= "test"
36
+ require 'diesel/testing'
37
+ require 'capybara/rails'
38
+ require 'capybara/cucumber'
39
+ require 'capybara/session'
40
+ """
41
+ When I write to "app/controllers/example_controller.rb" with:
42
+ """
43
+ class ExampleController < ActionController::Base
44
+ def hello
45
+ render
46
+ end
47
+ end
48
+ """
49
+ When I write to "app/views/example/hello.html.erb" with:
50
+ """
51
+ hello!
52
+ """
53
+ When I write to "config/routes.rb" with:
54
+ """
55
+ Rails.application.routes.draw do
56
+ match "/hello", :to => 'example#hello'
57
+ end
58
+ """
59
+ When I run "bundle exec cucumber features/hello.feature"
60
+ Then it should pass with:
61
+ """
62
+ 1 scenario (1 passed)
63
+ """
64
+
@@ -0,0 +1,95 @@
1
+ @disable-bundler
2
+ Feature: reusable features generator
3
+
4
+ Background:
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "testengine.gemspec" with:
8
+ """
9
+ Gem::Specification.new do |s|
10
+ s.name = %q{testengine}
11
+ s.version = '1.0'
12
+ s.files = Dir['**/*']
13
+ s.require_path = 'lib'
14
+ s.add_dependency 'diesel'
15
+ end
16
+ """
17
+ When I write to "app/controllers/examples_controller.rb" with:
18
+ """
19
+ class ExamplesController < ActionController::Base
20
+ def index
21
+ render
22
+ end
23
+ end
24
+ """
25
+ When I write to "app/views/examples/index.html.erb" with:
26
+ """
27
+ Hello there
28
+ """
29
+ When I write to "config/routes.rb" with:
30
+ """
31
+ Rails.application.routes.draw do
32
+ match "/examples", :to => 'examples#index'
33
+ end
34
+ """
35
+ When I write to "lib/testengine.rb" with:
36
+ """
37
+ require 'rails'
38
+ module Testengine
39
+ class Engine < Rails::Engine
40
+ end
41
+ end
42
+ """
43
+ When I write to "lib/generators/testengine/features/features_generator.rb" with:
44
+ """
45
+ require 'diesel/generators/features_base'
46
+
47
+ module Testengine
48
+ module Generators
49
+ class FeaturesGenerator < Diesel::Generators::FeaturesBase
50
+ end
51
+ end
52
+ end
53
+ """
54
+ When I write to "features/engine/examples.feature" with:
55
+ """
56
+ Feature: view examples
57
+ Scenario: go to the examples page
58
+ When I go to the examples page
59
+ Then I should receive a warm greeting
60
+ """
61
+ When I write to "features/step_definitions/engine/example_steps.rb" with:
62
+ """
63
+ Then %{I should receive a warm greeting} do
64
+ Then %{I should see "Hello there"}
65
+ end
66
+ """
67
+ When I cd to ".."
68
+ And I successfully run "rails new testapp"
69
+ And I cd to "testapp"
70
+ And I append to "Gemfile" with:
71
+ """
72
+ gem "cucumber-rails", "~> 0.3.2"
73
+ gem "capybara", "~> 0.4.0"
74
+ gem "rspec", "~> 1.3.0"
75
+
76
+ """
77
+ When I add the "testengine" as a diesel engine
78
+ And I run "bundle install --local"
79
+ And I successfully run "rails generate cucumber:install --trace"
80
+ And I successfully run "rails generate testengine:features --trace"
81
+
82
+ Scenario: copy features into an app from a diesel engine
83
+ When I run "bundle exec cucumber -r features features/testengine/examples.feature"
84
+ Then it should pass with:
85
+ """
86
+ 1 scenario (1 passed)
87
+ """
88
+
89
+ Scenario: view generator descriptions from an app with a diesel engine
90
+ When I successfully run "rails generate testengine:features -h"
91
+ Then the output should contain:
92
+ """
93
+ Copy cucumber feature files for the engine into your application.
94
+ """
95
+
@@ -0,0 +1,112 @@
1
+ @disable-bundler
2
+ Feature: reusable install generator
3
+
4
+ Background:
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "testengine.gemspec" with:
8
+ """
9
+ Gem::Specification.new do |s|
10
+ s.name = %q{testengine}
11
+ s.version = '1.0'
12
+ s.files = Dir['**/*']
13
+ s.require_path = 'lib'
14
+ s.add_dependency 'diesel'
15
+ end
16
+ """
17
+ When I write to "db/migrate/create_examples.rb" with:
18
+ """
19
+ class CreateExamples < ActiveRecord::Migration
20
+ def self.up
21
+ create_table :examples do |table|
22
+ table.string :title
23
+ end
24
+ end
25
+ end
26
+ """
27
+ When I write to "app/models/example.rb" with:
28
+ """
29
+ class Example < ActiveRecord::Base
30
+ end
31
+ """
32
+ When I write to "app/controllers/examples_controller.rb" with:
33
+ """
34
+ class ExamplesController < ActionController::Base
35
+ def index
36
+ Example.create!(:title => "Hello there")
37
+ @examples = Example.all
38
+ render
39
+ end
40
+ end
41
+ """
42
+ When I write to "config/routes.rb" with:
43
+ """
44
+ Rails.application.routes.draw do
45
+ match "/examples", :to => 'examples#index'
46
+ end
47
+ """
48
+ When I write to "lib/testengine.rb" with:
49
+ """
50
+ require 'rails'
51
+ module Testengine
52
+ class Engine < Rails::Engine
53
+ end
54
+ end
55
+ """
56
+ When I write to "lib/generators/testengine/install/install_generator.rb" with:
57
+ """
58
+ require 'diesel/generators/install_base'
59
+
60
+ module Testengine
61
+ module Generators
62
+ class InstallGenerator < Diesel::Generators::InstallBase
63
+ def copy_view
64
+ copy_file "index.html.erb", "app/views/examples/index.html.erb"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ """
70
+ When I write to "lib/generators/testengine/install/templates/index.html.erb" with:
71
+ """
72
+ <% @examples.each do |example| -%>
73
+ <p><%= example.title %></p>
74
+ <% end -%>
75
+ """
76
+ When I cd to ".."
77
+ And I successfully run "rails new testapp"
78
+ And I cd to "testapp"
79
+ And I append to "Gemfile" with:
80
+ """
81
+ gem "cucumber-rails", "~> 0.3.2"
82
+ gem "capybara", "~> 0.4.0"
83
+ gem "rspec", "~> 1.3.0"
84
+
85
+ """
86
+ When I add the "testengine" as a diesel engine
87
+ And I run "bundle install --local"
88
+ And I successfully run "rails generate cucumber:install --trace"
89
+ And I successfully run "rails generate testengine:install --trace"
90
+ And I successfully run "rake db:migrate db:schema:dump db:test:prepare --trace"
91
+
92
+ Scenario: test a generated app with a diesel engine
93
+ When I write to "features/examples.feature" with:
94
+ """
95
+ Feature: view examples
96
+ Scenario: go to the examples page
97
+ When I go to the examples page
98
+ Then I should see "Hello there"
99
+ """
100
+ When I run "bundle exec cucumber features/examples.feature"
101
+ Then it should pass with:
102
+ """
103
+ 1 scenario (1 passed)
104
+ """
105
+
106
+ Scenario: view generator descriptions from an app with a diesel engine
107
+ When I successfully run "rails generate testengine:install -h"
108
+ Then the output should contain:
109
+ """
110
+ Generate configuration, migration, and other essential files.
111
+ """
112
+
@@ -0,0 +1,143 @@
1
+ @disable-bundler
2
+ Feature: integration testing
3
+
4
+ Scenario: test integration of a diesel engine with a generated application
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "testengine.gemspec" with:
8
+ """
9
+ Gem::Specification.new do |s|
10
+ s.name = %q{testengine}
11
+ s.version = '1.0'
12
+ s.files = Dir['**/*']
13
+ s.require_path = 'lib'
14
+ s.add_dependency 'diesel'
15
+ end
16
+ """
17
+ When I write to "Gemfile" with:
18
+ """
19
+ gem "cucumber"
20
+ gem "aruba"
21
+ gem "rspec", "~> 1.3.0"
22
+ """
23
+ When I add this library as a dependency
24
+ And I write to "db/migrate/create_examples.rb" with:
25
+ """
26
+ class CreateExamples < ActiveRecord::Migration
27
+ def self.up
28
+ create_table :examples do |table|
29
+ table.string :title
30
+ end
31
+ end
32
+ end
33
+ """
34
+ When I write to "app/models/example.rb" with:
35
+ """
36
+ class Example < ActiveRecord::Base
37
+ end
38
+ """
39
+ When I write to "app/controllers/examples_controller.rb" with:
40
+ """
41
+ class ExamplesController < ActionController::Base
42
+ def index
43
+ Example.create!(:title => "Hello there")
44
+ @examples = Example.all
45
+ render
46
+ end
47
+ end
48
+ """
49
+ When I write to "app/views/examples/index.html.erb" with:
50
+ """
51
+ <% @examples.each do |example| -%>
52
+ <p><%= example.title %></p>
53
+ <% end -%>
54
+ """
55
+ When I write to "config/routes.rb" with:
56
+ """
57
+ Rails.application.routes.draw do
58
+ match "/examples", :to => 'examples#index'
59
+ end
60
+ """
61
+ When I write to "lib/testengine.rb" with:
62
+ """
63
+ require 'rails'
64
+ module Testengine
65
+ class Engine < Rails::Engine
66
+ end
67
+ end
68
+ """
69
+ When I write to "features/engine/examples.feature" with:
70
+ """
71
+ Feature: view examples
72
+ Scenario: go to the examples page
73
+ When I go to the examples page
74
+ Then I should receive a warm greeting
75
+ """
76
+ When I write to "features/step_definitions/engine/example_steps.rb" with:
77
+ """
78
+ Then %{I should receive a warm greeting} do
79
+ Then %{I should see "Hello there"}
80
+ end
81
+ """
82
+ When I write to "lib/generators/testengine/install/install_generator.rb" with:
83
+ """
84
+ require 'diesel/generators/install_base'
85
+
86
+ module Testengine
87
+ module Generators
88
+ class InstallGenerator < Diesel::Generators::InstallBase
89
+ end
90
+ end
91
+ end
92
+ """
93
+ When I write to "lib/generators/testengine/features/features_generator.rb" with:
94
+ """
95
+ require 'diesel/generators/features_base'
96
+
97
+ module Testengine
98
+ module Generators
99
+ class FeaturesGenerator < Diesel::Generators::FeaturesBase
100
+ end
101
+ end
102
+ end
103
+ """
104
+ When I write to "features/integration.feature" with:
105
+ """
106
+ @disable-bundler @puts @announce
107
+ Feature: integrate with application
108
+ Scenario: generate a Rails app, run the generates, and run the tests
109
+ When I successfully run "rails new testapp"
110
+ And I cd to "testapp"
111
+ And I add the "cucumber-rails" gem
112
+ And I add the "capybara" gem
113
+ And I add the "rspec-rails" gem
114
+ And I add the "testengine" gem from this project
115
+ And I add the "diesel" gem from the diesel project
116
+ And I run "bundle install --local"
117
+ And I successfully run "rails generate cucumber:install"
118
+ And I successfully run "rails generate testengine:install"
119
+ And I successfully run "rails generate testengine:features"
120
+ And I successfully run "rake db:migrate --trace"
121
+ And I successfully run "rake --trace"
122
+ Then the output should contain "1 scenario (1 passed)"
123
+ And the output should not contain "Could not find generator"
124
+ """
125
+ When I write to "features/support/env.rb" with:
126
+ """
127
+ require "diesel/testing/integration"
128
+ """
129
+ When I write to "features/step_definitions/dependency_steps.rb" with:
130
+ """
131
+ # Make sure we use the local diesel
132
+ When /^I add the "([^"]*)" gem from the diesel project$/ do |gem_name|
133
+ append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "../../../../../.."\n})
134
+ end
135
+ """
136
+ When I run "bundle install --local"
137
+ And I run "bundle exec cucumber features/integration.feature"
138
+ Then it should pass with:
139
+ """
140
+ 1 scenario (1 passed)
141
+ """
142
+ Then the output should not contain "undefined"
143
+
@@ -0,0 +1,52 @@
1
+ @disable-bundler
2
+ Feature: test a diesel engine using rspec
3
+
4
+ Scenario: create a disel engine and test using rspec
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "Gemfile" with:
8
+ """
9
+ gem "rspec-rails", "~> 2.3.0"
10
+ gem "rails", "~> 3.0.3"
11
+ gem "sqlite3-ruby"
12
+ """
13
+ When I add this library as a dependency
14
+ And I write to "spec/controllers/example_controller_spec.rb" with:
15
+ """
16
+ ENV["RAILS_ENV"] ||= 'test'
17
+ require "diesel/testing"
18
+ require 'rspec/rails'
19
+
20
+ describe ExampleController do
21
+ it "renders hello" do
22
+ get :hello
23
+ response.should be_success
24
+ response.should render_template("hello")
25
+ end
26
+ end
27
+ """
28
+ When I write to "app/controllers/example_controller.rb" with:
29
+ """
30
+ class ExampleController < ActionController::Base
31
+ def hello
32
+ render
33
+ end
34
+ end
35
+ """
36
+ When I write to "app/views/example/hello.html.erb" with:
37
+ """
38
+ hello!
39
+ """
40
+ When I write to "config/routes.rb" with:
41
+ """
42
+ Rails.application.routes.draw do
43
+ match "/hello", :to => 'example#hello'
44
+ end
45
+ """
46
+ When I run "bundle exec rspec --format documentation spec"
47
+ Then it should pass with:
48
+ """
49
+ 0 failures
50
+ """
51
+ Then at least one example should have run
52
+
@@ -0,0 +1,17 @@
1
+ When /^I add this library as a dependency$/ do
2
+ append_to_file('Gemfile', %{\ngem "diesel", :path => "#{PROJECT_ROOT}"\n})
3
+ end
4
+
5
+ Then /^at least one example should have run$/ do
6
+ Then %{the output should match /[1-9]0? examples?/}
7
+ end
8
+
9
+ When /^I add the "([^"]*)" as a diesel engine$/ do |engine_name|
10
+ When %{I add this library as a dependency}
11
+ append_to_file('Gemfile', <<-GEM)
12
+
13
+ gem "#{engine_name}", :path => "#{PROJECT_ROOT}/tmp/aruba/#{engine_name}"
14
+
15
+ GEM
16
+ end
17
+
@@ -0,0 +1,3 @@
1
+ require 'aruba/cucumber'
2
+
3
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
@@ -0,0 +1,57 @@
1
+ @disable-bundler
2
+ Feature: reusable views generator
3
+
4
+ Background:
5
+ Given a directory named "testengine"
6
+ When I cd to "testengine"
7
+ And I write to "testengine.gemspec" with:
8
+ """
9
+ Gem::Specification.new do |s|
10
+ s.name = %q{testengine}
11
+ s.version = '1.0'
12
+ s.files = Dir['**/*']
13
+ s.require_path = 'lib'
14
+ s.add_dependency 'diesel'
15
+ end
16
+ """
17
+ When I write to "app/views/examples/index.html.erb" with:
18
+ """
19
+ Hello there
20
+ """
21
+ When I write to "lib/testengine.rb" with:
22
+ """
23
+ require 'rails'
24
+ module Testengine
25
+ class Engine < Rails::Engine
26
+ end
27
+ end
28
+ """
29
+ When I write to "lib/generators/testengine/views/views_generator.rb" with:
30
+ """
31
+ require 'diesel/generators/views_base'
32
+
33
+ module Testengine
34
+ module Generators
35
+ class ViewsGenerator < Diesel::Generators::ViewsBase
36
+ end
37
+ end
38
+ end
39
+ """
40
+ When I cd to ".."
41
+ And I successfully run "rails new testapp"
42
+ And I cd to "testapp"
43
+ And I add the "testengine" as a diesel engine
44
+ And I run "bundle install --local"
45
+
46
+ Scenario: copy views into an app from a diesel engine
47
+ When I successfully run "rails generate testengine:views --trace"
48
+ Then the file "app/views/examples/index.html.erb" should contain "Hello there"
49
+
50
+ Scenario: view generator descriptions from an app with a diesel engine
51
+ When I successfully run "rails generate testengine:views -h"
52
+ Then the output should contain:
53
+ """
54
+ Copy view files for the engine into your application.
55
+ """
56
+
57
+
@@ -0,0 +1,56 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/base'
3
+
4
+ module Diesel
5
+ module Generators
6
+ class Base < Rails::Generators::Base
7
+ def self.source_root
8
+ if engine
9
+ @_diesel_source_root ||= engine_root
10
+ end
11
+ end
12
+
13
+ def self.inherited(generator)
14
+ super
15
+ generator.source_paths << generator.template_root if generator.engine
16
+ end
17
+
18
+ def self.template_root
19
+ File.join(engine_root,
20
+ "lib",
21
+ "generators",
22
+ engine_name,
23
+ generator_name,
24
+ 'templates')
25
+ end
26
+
27
+ def self.engine_root
28
+ File.expand_path(engine.root)
29
+ end
30
+
31
+ def self.engine
32
+ @_diesel_engine ||= "#{engine_name.camelize}::Engine".constantize
33
+ rescue NameError
34
+ nil
35
+ end
36
+
37
+ def self.engine_name
38
+ self.name.split('::').first.underscore
39
+ end
40
+
41
+ private
42
+
43
+ def engine_name
44
+ self.class.engine_name
45
+ end
46
+
47
+ def files_within_root(prefix, glob)
48
+ root = "#{self.class.source_root}/#{prefix}"
49
+ Dir["#{root}/#{glob}"].sort.map do |full_path|
50
+ full_path.sub(root, '.').gsub('/./', '/')
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
@@ -0,0 +1,39 @@
1
+ require 'diesel/generators/base'
2
+
3
+ module Diesel
4
+ module Generators
5
+ class FeaturesBase < Diesel::Generators::Base
6
+ def generate_features
7
+ features.each do |feature|
8
+ copy_file "features/engine/#{feature}", "features/#{engine_name}/#{feature}"
9
+ end
10
+ end
11
+
12
+ def generate_step_definitions
13
+ step_definitions.each do |step_definition|
14
+ copy_file "features/step_definitions/engine/#{step_definition}",
15
+ "features/step_definitions/#{engine_name}/#{step_definition}"
16
+ end
17
+ end
18
+
19
+ def self.inherited(generator)
20
+ super
21
+ generator.desc(<<-DESC)
22
+ Copy cucumber feature files for the engine into your application.
23
+ DESC
24
+ end
25
+
26
+ private
27
+
28
+ def features
29
+ files_within_root("features/engine", "*.feature")
30
+ end
31
+
32
+ def step_definitions
33
+ files_within_root("features/step_definitions/engine", "*_steps.rb")
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
@@ -0,0 +1,30 @@
1
+ require 'diesel/generators/base'
2
+ require 'rails/generators/active_record/migration'
3
+
4
+ module Diesel
5
+ module Generators
6
+ class InstallBase < Diesel::Generators::Base
7
+
8
+ include Rails::Generators::Migration
9
+ extend ActiveRecord::Generators::Migration
10
+
11
+ def generate_migrations
12
+ migrations.each do |migration|
13
+ migration_template migration
14
+ end
15
+ end
16
+
17
+ def self.inherited(generator)
18
+ super
19
+ generator.desc %{Generate configuration, migration, and other essential files.}
20
+ end
21
+
22
+ private
23
+
24
+ def migrations
25
+ files_within_root(".", "db/migrate/*.rb")
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,28 @@
1
+ require 'diesel/generators/base'
2
+
3
+ module Diesel
4
+ module Generators
5
+ class ViewsBase < Diesel::Generators::Base
6
+ def generate_views
7
+ views.each do |view|
8
+ copy_file view
9
+ end
10
+ end
11
+
12
+ def self.inherited(generator)
13
+ super
14
+ generator.desc(<<-DESC)
15
+ Copy view files for the engine into your application.
16
+ DESC
17
+ end
18
+
19
+ private
20
+
21
+ def views
22
+ files_within_root(".", "app/views/**/*.*")
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+
@@ -0,0 +1,24 @@
1
+ require 'rails/all'
2
+
3
+ module Diesel
4
+ module Testing
5
+ APP_ROOT = File.expand_path('..', __FILE__).freeze
6
+
7
+ class Application < Rails::Application
8
+ config.encoding = "utf-8"
9
+ config.action_mailer.default_url_options = { :host => 'localhost' }
10
+ config.paths.config.database = "#{APP_ROOT}/database.yml"
11
+ config.paths.log = "tmp/log"
12
+ config.cache_classes = true
13
+ config.whiny_nils = true
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+ config.action_dispatch.show_exceptions = false
17
+ config.action_controller.allow_forgery_protection = false
18
+ config.action_mailer.delivery_method = :test
19
+ config.active_support.deprecation = :stderr
20
+ config.secret_token = "DIESEL" * 5 # so diesel
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,10 @@
1
+ require 'aruba/cucumber'
2
+
3
+ When /^I add the "([^"]*)" gem$/ do |gem_name|
4
+ append_to_file('Gemfile', %{\ngem "#{gem_name}"\n})
5
+ end
6
+
7
+ When /^I add the "([^"]*)" gem from this project$/ do |gem_name|
8
+ append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "../../.."\n})
9
+ end
10
+
@@ -0,0 +1,4 @@
1
+ require 'diesel/testing/application'
2
+
3
+ Diesel::Testing::Application.initialize!
4
+
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diesel
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - thoughtbot, inc.
14
+ - Joe Ferris
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-12-22 00:00:00 -05:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ type: :runtime
24
+ prerelease: false
25
+ name: railties
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 1
32
+ segments:
33
+ - 3
34
+ - 0
35
+ - 3
36
+ version: 3.0.3
37
+ requirement: *id001
38
+ description: Develop your Rails engines like you develop your Rails applications.
39
+ email: support@thoughtbot.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - Gemfile
48
+ - Gemfile.lock
49
+ - Rakefile
50
+ - lib/diesel/generators/base.rb
51
+ - lib/diesel/generators/features_base.rb
52
+ - lib/diesel/generators/install_base.rb
53
+ - lib/diesel/generators/views_base.rb
54
+ - lib/diesel/testing/application.rb
55
+ - lib/diesel/testing/integration.rb
56
+ - lib/diesel/testing.rb
57
+ - features/cucumber_testing.feature
58
+ - features/features_generator.feature
59
+ - features/install_generator.feature
60
+ - features/integration_testing.feature
61
+ - features/rspec_testing.feature
62
+ - features/step_definitions/diesel_steps.rb
63
+ - features/support/env.rb
64
+ - features/views_generator.feature
65
+ has_rdoc: false
66
+ homepage: http://github.com/thoughtbot/diesel
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.3.7
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Diesel makes your engine go.
99
+ test_files:
100
+ - features/cucumber_testing.feature
101
+ - features/features_generator.feature
102
+ - features/install_generator.feature
103
+ - features/integration_testing.feature
104
+ - features/rspec_testing.feature
105
+ - features/step_definitions/diesel_steps.rb
106
+ - features/support/env.rb
107
+ - features/views_generator.feature