padrino-gen 0.12.9 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/bin/padrino-gen +2 -2
- data/lib/padrino-gen/generators/actions.rb +5 -17
- data/lib/padrino-gen/generators/app/app.rb.tt +2 -3
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +0 -16
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +38 -19
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +0 -1
- data/lib/padrino-gen/generators/components/stylesheets/compass.rb +16 -5
- data/lib/padrino-gen/generators/components/tests/bacon.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/minitest.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/riot.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/rspec.rb +1 -5
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +0 -3
- data/lib/padrino-gen/generators/components/tests/steak.rb +0 -2
- data/lib/padrino-gen/generators/controller.rb +0 -1
- data/lib/padrino-gen/generators/helper.rb +0 -1
- data/lib/padrino-gen/generators/mailer.rb +0 -1
- data/lib/padrino-gen/generators/migration.rb +0 -1
- data/lib/padrino-gen/generators/plugin.rb +1 -1
- data/lib/padrino-gen/generators/project/config/boot.rb +0 -11
- data/lib/padrino-gen/generators/project.rb +2 -3
- data/lib/padrino-gen/generators/runner.rb +0 -1
- data/lib/padrino-gen/generators/task.rb +0 -1
- data/lib/padrino-gen/generators/templates/Gemfile.tt +0 -10
- data/lib/padrino-gen/generators/templates/Rakefile.tt +0 -2
- data/lib/padrino-gen/generators/templates/controller.rb.tt +1 -1
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +10 -16
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +2 -4
- data/lib/padrino-gen/padrino-tasks/sequel.rb +3 -4
- data/test/helper.rb +17 -14
- data/test/test_component_generator.rb +3 -5
- data/test/test_controller_generator.rb +0 -13
- data/test/test_helper_generator.rb +0 -13
- data/test/test_mailer_generator.rb +0 -5
- data/test/test_migration_generator.rb +0 -5
- data/test/test_model_generator.rb +24 -30
- data/test/test_plugin_generator.rb +0 -4
- data/test/test_project_generator.rb +8 -23
- data/test/test_task_generator.rb +0 -5
- metadata +46 -28
- data/lib/padrino-gen/generators/components/tests/testunit.rb +0 -112
data/test/helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'minitest/autorun'
|
|
2
2
|
require 'minitest/pride'
|
3
3
|
require 'mocha/setup'
|
4
4
|
require 'rack/test'
|
5
|
+
require 'webrat'
|
5
6
|
require 'fakeweb'
|
6
7
|
require 'thor/group'
|
7
8
|
require 'padrino-gen'
|
@@ -13,20 +14,14 @@ require 'ext/minitest-spec'
|
|
13
14
|
|
14
15
|
Padrino::Generators.load_components!
|
15
16
|
|
16
|
-
# register fake URL to avoid downloading static files every time tests run
|
17
|
-
fake_uri_base = "https://raw.github.com/padrino/padrino-static/master/"
|
18
|
-
%W[
|
19
|
-
js/dojo.js ujs/dojo.js
|
20
|
-
js/ext.js ujs/ext.js
|
21
|
-
js/jquery.js ujs/jquery.js
|
22
|
-
js/mootools.js ujs/mootools.js
|
23
|
-
js/right.js ujs/right.js
|
24
|
-
js/protopak.js js/lowpro.js ujs/prototype.js
|
25
|
-
].each do |suffix|
|
26
|
-
FakeWeb.register_uri(:get, fake_uri_base + suffix, :body => '')
|
27
|
-
end
|
28
|
-
|
29
17
|
class MiniTest::Spec
|
18
|
+
include Webrat::Methods
|
19
|
+
include Webrat::Matchers
|
20
|
+
|
21
|
+
Webrat.configure do |config|
|
22
|
+
config.mode = :rack
|
23
|
+
end
|
24
|
+
|
30
25
|
def stop_time_for_test
|
31
26
|
time = Time.now
|
32
27
|
Time.stubs(:now).returns(time)
|
@@ -84,7 +79,7 @@ class MiniTest::Spec
|
|
84
79
|
# expects_initializer :test, "# Example"
|
85
80
|
def expects_initializer(name, body,options={})
|
86
81
|
#options.reverse_merge!(:root => "/tmp/sample_project")
|
87
|
-
path = File.join(options[:root],'
|
82
|
+
path = File.join(options[:root],'lib',"#{name}_initializer.rb")
|
88
83
|
instance = mock
|
89
84
|
instance.expects(:invoke!).at_least_once
|
90
85
|
include_text = " register #{name.to_s.camelize}Initializer\n"
|
@@ -98,3 +93,11 @@ class MiniTest::Spec
|
|
98
93
|
Padrino.expects(:bin).with("rake", command, "-c=#{options[:root]}").returns(true)
|
99
94
|
end
|
100
95
|
end
|
96
|
+
|
97
|
+
module Webrat
|
98
|
+
module Logging
|
99
|
+
def logger # # @private
|
100
|
+
@logger = nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -17,7 +17,6 @@ describe "ComponentGenerator" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
describe "add components" do
|
22
21
|
it 'should properly generate default' do
|
23
22
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
@@ -73,10 +72,9 @@ describe "ComponentGenerator" do
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
|
77
75
|
describe "component changes" do
|
78
76
|
it 'should when allow changes, will be applied' do
|
79
|
-
capture_io { generate(:project, 'sample_project', '
|
77
|
+
capture_io { generate(:project, 'sample_project', '--renderer=slim', "--root=#{@apptmp}") }
|
80
78
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
81
79
|
assert_equal 'slim', components_chosen[:renderer]
|
82
80
|
Readline.stubs(:readline).returns('yes').once
|
@@ -85,8 +83,9 @@ describe "ComponentGenerator" do
|
|
85
83
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
86
84
|
assert_equal 'haml', components_chosen[:renderer]
|
87
85
|
end
|
86
|
+
|
88
87
|
it 'should when deny changes, will not be applied' do
|
89
|
-
capture_io { generate(:project, 'sample_project', '
|
88
|
+
capture_io { generate(:project, 'sample_project', '--renderer=slim', "--root=#{@apptmp}") }
|
90
89
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
91
90
|
assert_equal 'slim', components_chosen[:renderer]
|
92
91
|
Readline.stubs(:readline).returns('no').once
|
@@ -96,5 +95,4 @@ describe "ComponentGenerator" do
|
|
96
95
|
assert_equal 'slim', components_chosen[:renderer]
|
97
96
|
end
|
98
97
|
end
|
99
|
-
|
100
98
|
end
|
@@ -22,11 +22,6 @@ describe "ControllerGenerator" do
|
|
22
22
|
assert_no_file_exists("#{@apptmp}/app/controllers/demo.rb")
|
23
23
|
end
|
24
24
|
|
25
|
-
it 'should fail with NameError if given invalid namespace names' do
|
26
|
-
capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
|
27
|
-
assert_raises(::NameError) { capture_io { generate(:controller, "wrong/name", "--root=#{@apptmp}/sample") } }
|
28
|
-
end
|
29
|
-
|
30
25
|
it 'should generate controller within existing project' do
|
31
26
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
|
32
27
|
capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project") }
|
@@ -205,14 +200,6 @@ describe "ControllerGenerator" do
|
|
205
200
|
assert_match_in_file(/Capybara.app = /, "#{@apptmp}/sample_project/features/support/env.rb")
|
206
201
|
end
|
207
202
|
|
208
|
-
it "should generate controller test for testunit" do
|
209
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testunit') }
|
210
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
211
|
-
capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
212
|
-
assert_match_in_file(/class DemoItemsControllerTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/subby/controllers/demo_items_controller_test.rb")
|
213
|
-
end
|
214
|
-
|
215
|
-
|
216
203
|
it 'should correctly generate file names' do
|
217
204
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec') }
|
218
205
|
capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project") }
|
@@ -19,11 +19,6 @@ describe "HelperGenerator" do
|
|
19
19
|
assert_no_file_exists("#{@apptmp}/app/helpers/demo_helper.rb")
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'should fail with NameError if given invalid namespace names' do
|
23
|
-
capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
|
24
|
-
assert_raises(::NameError) { capture_io { generate(:helper, "wrong/name", "--root=#{@apptmp}/sample") } }
|
25
|
-
end
|
26
|
-
|
27
22
|
it 'should generate helper within existing project' do
|
28
23
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
|
29
24
|
capture_io { generate(:helper, 'DemoItems', "-r=#{@apptmp}/sample_project") }
|
@@ -100,14 +95,6 @@ describe "HelperGenerator" do
|
|
100
95
|
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
|
101
96
|
end
|
102
97
|
|
103
|
-
it "should generate helper test for testunit" do
|
104
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none') }
|
105
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
106
|
-
capture_io { generate(:helper, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
107
|
-
assert_match_in_file(/class DemoItemsHelperTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
|
108
|
-
assert_match_in_file(/@helpers\.extend SampleProject::Subby::DemoItemsHelper/m, "#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
|
109
|
-
end
|
110
|
-
|
111
98
|
it 'should correctly generate file names' do
|
112
99
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec') }
|
113
100
|
capture_io { generate(:helper, 'DemoItems', "-r=#{@apptmp}/sample_project") }
|
@@ -17,11 +17,6 @@ describe "MailerGenerator" do
|
|
17
17
|
assert_no_file_exists('/tmp/app/mailers/demo_mailer.rb')
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should fail with NameError if given invalid namespace names' do
|
21
|
-
capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
|
22
|
-
assert_raises(::NameError) { capture_io { generate(:mailer, "wrong/name", "--root=#{@apptmp}/sample") } }
|
23
|
-
end
|
24
|
-
|
25
20
|
it 'should generate mailer in specified app' do
|
26
21
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
|
27
22
|
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
@@ -17,11 +17,6 @@ describe "MigrationGenerator" do
|
|
17
17
|
assert_no_file_exists("#{@apptmp}/db/migrate")
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should fail with NameError if given invalid namespace names' do
|
21
|
-
capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
|
22
|
-
assert_raises(::NameError) { capture_io { generate(:migration, "wrong/name", "--root=#{@apptmp}/sample") } }
|
23
|
-
end
|
24
|
-
|
25
20
|
it 'should fail if we do not use an adapter' do
|
26
21
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
|
27
22
|
assert_raises(SystemExit) { capture_io { generate(:migration, 'AddEmailToUsers', "-r=#{@apptmp}/sample_project") } }
|
@@ -79,14 +79,14 @@ describe "ModelGenerator" do
|
|
79
79
|
it 'should generate a default type value for fields' do
|
80
80
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
81
81
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
|
82
|
-
capture_io { generate(:model, '
|
83
|
-
migration_file_path = "#{@apptmp}/sample_project/db/migrate/
|
84
|
-
assert_match_in_file(/class
|
85
|
-
assert_match_in_file(/ create_table :
|
82
|
+
capture_io { generate(:model, 'person', "name", "age:integer", "email", "-r=#{@apptmp}/sample_project") }
|
83
|
+
migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
|
84
|
+
assert_match_in_file(/class CreatePeople < ActiveRecord::Migration/m, migration_file_path)
|
85
|
+
assert_match_in_file(/ create_table :people/m, migration_file_path)
|
86
86
|
assert_match_in_file(/ t.string :name/m, migration_file_path)
|
87
87
|
assert_match_in_file(/ t.integer :age/m, migration_file_path)
|
88
88
|
assert_match_in_file(/ t.string :email/m, migration_file_path)
|
89
|
-
assert_match_in_file(/ drop_table :
|
89
|
+
assert_match_in_file(/ drop_table :people/m, migration_file_path)
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'should abort if model name already exists' do
|
@@ -149,14 +149,14 @@ describe "ModelGenerator" do
|
|
149
149
|
it 'should generate migration file with given fields' do
|
150
150
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
151
151
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
|
152
|
-
capture_io { generate(:model, '
|
153
|
-
migration_file_path = "#{@apptmp}/sample_project/db/migrate/
|
154
|
-
assert_match_in_file(/class
|
155
|
-
assert_match_in_file(/ create_table :
|
152
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
|
153
|
+
migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
|
154
|
+
assert_match_in_file(/class CreatePeople < ActiveRecord::Migration/m, migration_file_path)
|
155
|
+
assert_match_in_file(/ create_table :people/m, migration_file_path)
|
156
156
|
assert_match_in_file(/ t.string :name/m, migration_file_path)
|
157
157
|
assert_match_in_file(/ t.integer :age/m, migration_file_path)
|
158
158
|
assert_match_in_file(/ t.string :email/m, migration_file_path)
|
159
|
-
assert_match_in_file(/ drop_table :
|
159
|
+
assert_match_in_file(/ drop_table :people/m, migration_file_path)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -214,12 +214,6 @@ describe "ModelGenerator" do
|
|
214
214
|
|
215
215
|
# DATAMAPPER
|
216
216
|
describe "model generator using datamapper" do
|
217
|
-
it 'should add activerecord middleware' do
|
218
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
|
219
|
-
assert_match_in_file(/ use IdentityMap/m, "#{@apptmp}/sample_project/app/app.rb")
|
220
|
-
assert_file_exists("#{@apptmp}/sample_project/lib/identity_map_middleware.rb")
|
221
|
-
end
|
222
|
-
|
223
217
|
it 'should generate model file with camelized name' do
|
224
218
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=datamapper') }
|
225
219
|
capture_io { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
|
@@ -239,12 +233,12 @@ describe "ModelGenerator" do
|
|
239
233
|
it 'should properly generate version numbers' do
|
240
234
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
|
241
235
|
capture_io { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
|
242
|
-
capture_io { generate(:model, '
|
236
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
|
243
237
|
capture_io { generate(:model, 'account', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
|
244
238
|
assert_match_in_file(/class User\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/user.rb")
|
245
239
|
assert_match_in_file(/migration 1, :create_users do/m, "#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
|
246
|
-
assert_match_in_file(/class
|
247
|
-
assert_match_in_file(/migration 2, :
|
240
|
+
assert_match_in_file(/class Person\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/person.rb")
|
241
|
+
assert_match_in_file(/migration 2, :create_people do/m, "#{@apptmp}/sample_project/db/migrate/002_create_people.rb")
|
248
242
|
assert_match_in_file(/class Account\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/account.rb")
|
249
243
|
assert_match_in_file(/migration 3, :create_accounts do/m, "#{@apptmp}/sample_project/db/migrate/003_create_accounts.rb")
|
250
244
|
end
|
@@ -252,15 +246,15 @@ describe "ModelGenerator" do
|
|
252
246
|
it 'should generate migration with given fields' do
|
253
247
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
254
248
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
|
255
|
-
capture_io { generate(:model, '
|
256
|
-
assert_match_in_file(/class
|
257
|
-
migration_file_path = "#{@apptmp}/sample_project/db/migrate/
|
258
|
-
assert_match_in_file(/migration 1, :
|
259
|
-
assert_match_in_file(/create_table :
|
249
|
+
capture_io { generate(:model, 'person', "name:string", "created_at:date_time", "email:string", "-r=#{@apptmp}/sample_project") }
|
250
|
+
assert_match_in_file(/class Person\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/person.rb")
|
251
|
+
migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
|
252
|
+
assert_match_in_file(/migration 1, :create_people do/m, migration_file_path)
|
253
|
+
assert_match_in_file(/create_table :people do/m, migration_file_path)
|
260
254
|
assert_match_in_file(/column :name, DataMapper::Property::String/m, migration_file_path)
|
261
255
|
assert_match_in_file(/column :created_at, DataMapper::Property::DateTime/m, migration_file_path)
|
262
256
|
assert_match_in_file(/column :email, DataMapper::Property::String/m, migration_file_path)
|
263
|
-
assert_match_in_file(/drop_table :
|
257
|
+
assert_match_in_file(/drop_table :people/m, migration_file_path)
|
264
258
|
end
|
265
259
|
end
|
266
260
|
|
@@ -282,15 +276,15 @@ describe "ModelGenerator" do
|
|
282
276
|
it 'should generate migration file with given properties' do
|
283
277
|
current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
|
284
278
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
|
285
|
-
capture_io { generate(:model, '
|
286
|
-
migration_file_path = "#{@apptmp}/sample_project/db/migrate/
|
287
|
-
assert_match_in_file(/class
|
279
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "created:datetime", "-r=#{@apptmp}/sample_project") }
|
280
|
+
migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
|
281
|
+
assert_match_in_file(/class Person < Sequel::Model/m, "#{@apptmp}/sample_project/models/person.rb")
|
288
282
|
assert_match_in_file(/Sequel\.migration do/m, migration_file_path)
|
289
|
-
assert_match_in_file(/create_table :
|
283
|
+
assert_match_in_file(/create_table :people/m, migration_file_path)
|
290
284
|
assert_match_in_file(/String :name/m, migration_file_path)
|
291
285
|
assert_match_in_file(/Integer :age/m, migration_file_path)
|
292
286
|
assert_match_in_file(/DateTime :created/m, migration_file_path)
|
293
|
-
assert_match_in_file(/drop_table :
|
287
|
+
assert_match_in_file(/drop_table :people/m, migration_file_path)
|
294
288
|
end
|
295
289
|
end
|
296
290
|
|
@@ -54,7 +54,6 @@ describe "PluginGenerator" do
|
|
54
54
|
|
55
55
|
it 'should resolve generic url properly' do
|
56
56
|
template_file = 'http://www.example.com/test.rb'
|
57
|
-
FakeWeb.register_uri :get, template_file, :body => ''
|
58
57
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
59
58
|
project_gen.expects(:apply).with(template_file).returns(true).once
|
60
59
|
capture_io { project_gen.invoke_all }
|
@@ -72,7 +71,6 @@ describe "PluginGenerator" do
|
|
72
71
|
it 'should resolve official template' do
|
73
72
|
template_file = 'sampleblog'
|
74
73
|
resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/templates/sampleblog_template.rb"
|
75
|
-
FakeWeb.register_uri :get, resolved_path, :body => template_file
|
76
74
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
77
75
|
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
78
76
|
capture_io { project_gen.invoke_all }
|
@@ -88,7 +86,6 @@ describe "PluginGenerator" do
|
|
88
86
|
it 'should resolve official plugin' do
|
89
87
|
template_file = 'hoptoad'
|
90
88
|
resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/plugins/hoptoad_plugin.rb"
|
91
|
-
FakeWeb.register_uri :get, resolved_path, :body => template_file
|
92
89
|
plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
93
90
|
plugin_gen.expects(:in_app_root?).returns(true).once
|
94
91
|
plugin_gen.expects(:apply).with(resolved_path).returns(true).once
|
@@ -98,7 +95,6 @@ describe "PluginGenerator" do
|
|
98
95
|
it 'should print a warning if template cannot be found' do
|
99
96
|
template_file = 'hwat'
|
100
97
|
resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/plugins/hwat_plugin.rb"
|
101
|
-
FakeWeb.register_uri :get, resolved_path, :status => 404
|
102
98
|
plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
103
99
|
plugin_gen.expects(:in_app_root?).returns(true).once
|
104
100
|
plugin_gen.expects(:say).with("The template at #{resolved_path} could not be found!", :red).returns(true).once
|
@@ -172,7 +172,7 @@ describe "ProjectGenerator" do
|
|
172
172
|
assert_equal 'none', components_chosen[:test]
|
173
173
|
assert_equal 'none', components_chosen[:mock]
|
174
174
|
assert_equal 'none', components_chosen[:script]
|
175
|
-
assert_equal '
|
175
|
+
assert_equal 'none', components_chosen[:renderer]
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'should create components file containing options chosen' do
|
@@ -648,7 +648,7 @@ describe "ProjectGenerator" do
|
|
648
648
|
it 'should properly generate for sass' do
|
649
649
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=sass') }
|
650
650
|
assert_match_in_file(/gem 'sass'/, "#{@apptmp}/sample_project/Gemfile")
|
651
|
-
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/
|
651
|
+
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/sass_initializer.rb")
|
652
652
|
assert_match_in_file(/register SassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
653
653
|
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
654
654
|
end
|
@@ -656,16 +656,16 @@ describe "ProjectGenerator" do
|
|
656
656
|
it 'should properly generate for less' do
|
657
657
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=less') }
|
658
658
|
assert_match_in_file(/gem 'rack-less'/, "#{@apptmp}/sample_project/Gemfile")
|
659
|
-
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/
|
659
|
+
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/lib/less_initializer.rb")
|
660
660
|
assert_match_in_file(/register LessInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
661
661
|
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
662
662
|
end
|
663
663
|
|
664
664
|
it 'should properly generate for compass' do
|
665
665
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=compass') }
|
666
|
-
assert_match_in_file(/gem 'compass
|
667
|
-
assert_match_in_file(/Compass.configure_sass_plugin\!/, "#{@apptmp}/sample_project/
|
668
|
-
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/
|
666
|
+
assert_match_in_file(/gem 'compass'/, "#{@apptmp}/sample_project/Gemfile")
|
667
|
+
assert_match_in_file(/Compass.configure_sass_plugin\!/, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
668
|
+
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
669
669
|
assert_match_in_file(/register CompassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
670
670
|
|
671
671
|
assert_file_exists("#{@apptmp}/sample_project/app/stylesheets/application.scss")
|
@@ -675,8 +675,8 @@ describe "ProjectGenerator" do
|
|
675
675
|
it 'should properly generate for scss' do
|
676
676
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=scss') }
|
677
677
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
678
|
-
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/
|
679
|
-
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/
|
678
|
+
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/scss_initializer.rb")
|
679
|
+
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/lib/scss_initializer.rb")
|
680
680
|
assert_match_in_file(/register ScssInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
681
681
|
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
682
682
|
end
|
@@ -753,20 +753,5 @@ describe "ProjectGenerator" do
|
|
753
753
|
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
754
754
|
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
755
755
|
end
|
756
|
-
|
757
|
-
it "should properly generate for testunit" do
|
758
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none', '--tiny') }
|
759
|
-
assert_match(/applying.*?testunit.*?test/, out)
|
760
|
-
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
761
|
-
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
762
|
-
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
763
|
-
assert_match_in_file(/gem 'test-unit'/, "#{@apptmp}/sample_project/Gemfile")
|
764
|
-
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
765
|
-
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
766
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
767
|
-
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
768
|
-
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
769
|
-
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
770
|
-
end
|
771
756
|
end
|
772
757
|
end
|
data/test/test_task_generator.rb
CHANGED
@@ -17,11 +17,6 @@ describe "TaskGenerator" do
|
|
17
17
|
assert_no_file_exists('/tmp/tasks/foo.rake')
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should fail with NameError if given invalid namespace names' do
|
21
|
-
capture_io { generate(:project, "sample", "--root=#{@apptmp}") }
|
22
|
-
assert_raises(::NameError) { capture_io { generate(:task, "wrong/name", "--root=#{@apptmp}/sample") } }
|
23
|
-
end
|
24
|
-
|
25
20
|
it 'should generate filename properly' do
|
26
21
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
27
22
|
capture_io { generate(:task, 'DemoTask', "--namespace=Sample", "--description='This is a sample'", "-r=#{@apptmp}/sample_project") }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-core
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.13.0.beta1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.13.0.beta1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bundler
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,28 +47,28 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - '='
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.
|
50
|
+
version: 0.13.0.beta1
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - '='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.13.0.beta1
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: padrino-mailer
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - '='
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
64
|
+
version: 0.13.0.beta1
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.
|
71
|
+
version: 0.13.0.beta1
|
72
72
|
description: Generators for easily creating and building padrino applications from
|
73
73
|
the console
|
74
74
|
email: padrinorb@gmail.com
|
@@ -129,7 +129,6 @@ files:
|
|
129
129
|
- lib/padrino-gen/generators/components/tests/rspec.rb
|
130
130
|
- lib/padrino-gen/generators/components/tests/shoulda.rb
|
131
131
|
- lib/padrino-gen/generators/components/tests/steak.rb
|
132
|
-
- lib/padrino-gen/generators/components/tests/testunit.rb
|
133
132
|
- lib/padrino-gen/generators/controller.rb
|
134
133
|
- lib/padrino-gen/generators/helper.rb
|
135
134
|
- lib/padrino-gen/generators/mailer.rb
|
@@ -155,20 +154,6 @@ files:
|
|
155
154
|
- lib/padrino-gen/generators/templates/initializer.rb.tt
|
156
155
|
- lib/padrino-gen/generators/templates/mailer.rb.tt
|
157
156
|
- lib/padrino-gen/generators/templates/project_bin.tt
|
158
|
-
- lib/padrino-gen/generators/templates/static/README.rdoc
|
159
|
-
- lib/padrino-gen/generators/templates/static/js/dojo.js
|
160
|
-
- lib/padrino-gen/generators/templates/static/js/ext.js
|
161
|
-
- lib/padrino-gen/generators/templates/static/js/jquery.js
|
162
|
-
- lib/padrino-gen/generators/templates/static/js/lowpro.js
|
163
|
-
- lib/padrino-gen/generators/templates/static/js/mootools.js
|
164
|
-
- lib/padrino-gen/generators/templates/static/js/protopak.js
|
165
|
-
- lib/padrino-gen/generators/templates/static/js/right.js
|
166
|
-
- lib/padrino-gen/generators/templates/static/ujs/dojo.js
|
167
|
-
- lib/padrino-gen/generators/templates/static/ujs/ext.js
|
168
|
-
- lib/padrino-gen/generators/templates/static/ujs/jquery.js
|
169
|
-
- lib/padrino-gen/generators/templates/static/ujs/mootools.js
|
170
|
-
- lib/padrino-gen/generators/templates/static/ujs/prototype.js
|
171
|
-
- lib/padrino-gen/generators/templates/static/ujs/right.js
|
172
157
|
- lib/padrino-gen/generators/templates/task.rb.tt
|
173
158
|
- lib/padrino-gen/padrino-tasks/activerecord.rb
|
174
159
|
- lib/padrino-gen/padrino-tasks/database.rb
|
@@ -197,6 +182,20 @@ files:
|
|
197
182
|
- test/test_plugin_generator.rb
|
198
183
|
- test/test_project_generator.rb
|
199
184
|
- test/test_task_generator.rb
|
185
|
+
- lib/padrino-gen/generators/templates/static/js/dojo.js
|
186
|
+
- lib/padrino-gen/generators/templates/static/js/ext.js
|
187
|
+
- lib/padrino-gen/generators/templates/static/js/jquery.js
|
188
|
+
- lib/padrino-gen/generators/templates/static/js/lowpro.js
|
189
|
+
- lib/padrino-gen/generators/templates/static/js/mootools.js
|
190
|
+
- lib/padrino-gen/generators/templates/static/js/protopak.js
|
191
|
+
- lib/padrino-gen/generators/templates/static/js/right.js
|
192
|
+
- lib/padrino-gen/generators/templates/static/README.rdoc
|
193
|
+
- lib/padrino-gen/generators/templates/static/ujs/dojo.js
|
194
|
+
- lib/padrino-gen/generators/templates/static/ujs/ext.js
|
195
|
+
- lib/padrino-gen/generators/templates/static/ujs/jquery.js
|
196
|
+
- lib/padrino-gen/generators/templates/static/ujs/mootools.js
|
197
|
+
- lib/padrino-gen/generators/templates/static/ujs/prototype.js
|
198
|
+
- lib/padrino-gen/generators/templates/static/ujs/right.js
|
200
199
|
homepage: http://www.padrinorb.com
|
201
200
|
licenses:
|
202
201
|
- MIT
|
@@ -208,18 +207,37 @@ require_paths:
|
|
208
207
|
- lib
|
209
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
209
|
requirements:
|
211
|
-
- -
|
210
|
+
- - '>='
|
212
211
|
- !ruby/object:Gem::Version
|
213
212
|
version: '0'
|
214
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
214
|
requirements:
|
216
|
-
- -
|
215
|
+
- - '>'
|
217
216
|
- !ruby/object:Gem::Version
|
218
|
-
version: 1.3.
|
217
|
+
version: 1.3.1
|
219
218
|
requirements: []
|
220
219
|
rubyforge_project: padrino-gen
|
221
|
-
rubygems_version: 2.6
|
220
|
+
rubygems_version: 2.0.6
|
222
221
|
signing_key:
|
223
222
|
specification_version: 4
|
224
223
|
summary: Generators for easily creating and building padrino applications
|
225
|
-
test_files:
|
224
|
+
test_files:
|
225
|
+
- test/fixtures/admin_template.rb
|
226
|
+
- test/fixtures/example_template.rb
|
227
|
+
- test/fixtures/git_template.rb
|
228
|
+
- test/fixtures/plugin_template.rb
|
229
|
+
- test/fixtures/rake_template.rb
|
230
|
+
- test/helper.rb
|
231
|
+
- test/test_app_generator.rb
|
232
|
+
- test/test_cli.rb
|
233
|
+
- test/test_component_generator.rb
|
234
|
+
- test/test_controller_generator.rb
|
235
|
+
- test/test_generator.rb
|
236
|
+
- test/test_helper_generator.rb
|
237
|
+
- test/test_mailer_generator.rb
|
238
|
+
- test/test_migration_generator.rb
|
239
|
+
- test/test_model_generator.rb
|
240
|
+
- test/test_plugin_generator.rb
|
241
|
+
- test/test_project_generator.rb
|
242
|
+
- test/test_task_generator.rb
|
243
|
+
has_rdoc:
|