padrino-gen 0.13.2 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -2
- data/bin/padrino-gen +2 -2
- data/lib/padrino-gen/generators/actions.rb +3 -3
- data/lib/padrino-gen/generators/component.rb +1 -1
- data/lib/padrino-gen/generators/components/mocks/rr.rb +0 -2
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +1 -0
- data/lib/padrino-gen/generators/project.rb +3 -3
- data/test/helper.rb +4 -4
- data/test/test_controller_generator.rb +0 -27
- data/test/test_helper_generator.rb +0 -14
- data/test/test_model_generator.rb +0 -21
- data/test/test_project_generator.rb +4 -77
- metadata +10 -32
- data/lib/padrino-gen/generators/components/scripts/rightjs.rb +0 -10
- data/lib/padrino-gen/generators/components/tests/riot.rb +0 -119
- data/lib/padrino-gen/generators/components/tests/steak.rb +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce9cad7af3d838b31a0f21ed5e047c2af3ce0b6
|
4
|
+
data.tar.gz: 8aea999b606391dd5ce9229b6a813d171bb6ea0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25a987d2393a1bd5d90f69b8d10b24bce0992feb12b33b6e88873c8e4c7df9ea58b195744aade49fa780a3db1dea6a7b4e77b91d66331c2929d7fea9a4319b1b
|
7
|
+
data.tar.gz: 69ff8f7aaa59c744b89f5ef0639feb0319ad719d2572d337381fd708a467445bf1a41c07fb46dec92c25551b3e0c6c7e9fee49779aaf138cf8e58ec5e54a4a31
|
data/README.rdoc
CHANGED
@@ -38,11 +38,11 @@ You can also instruct the generator to skip a certain component to avoid using o
|
|
38
38
|
|
39
39
|
The available components and their default options are listed below:
|
40
40
|
|
41
|
-
test:: none (default), bacon, shoulda, cucumber,
|
41
|
+
test:: none (default), bacon, shoulda, cucumber, rspec, minitest
|
42
42
|
renderer:: slim (default), erb, erubis, liquid, haml
|
43
43
|
stylesheet:: none (default), less, compass, sass, scss
|
44
44
|
mock:: none (default), mocha, rr
|
45
|
-
script:: none (default), jquery, prototype, mootools,
|
45
|
+
script:: none (default), jquery, prototype, mootools, extcore, dojo
|
46
46
|
orm:: none (default), datamapper, mongomapper, mongoid, activerecord, minirecord, sequel, couchrest, ohm, mongomatic, ripple, dynamoid
|
47
47
|
|
48
48
|
In addition, you can generate projects based on existing templates:
|
data/bin/padrino-gen
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
3
|
-
|
2
|
+
require 'padrino-core/cli/binstub'
|
3
|
+
Padrino.replace_with_binstub('padrino-gen')
|
4
4
|
|
5
5
|
padrino_gen_path = File.expand_path('../../lib', __FILE__)
|
6
6
|
$:.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$:.include?(padrino_gen_path)
|
@@ -127,7 +127,7 @@ module Padrino
|
|
127
127
|
#
|
128
128
|
# @example
|
129
129
|
# retrieve_component_config(...)
|
130
|
-
# # => { :mock => 'rr', :test => '
|
130
|
+
# # => { :mock => 'rr', :test => 'rspec', ... }
|
131
131
|
#
|
132
132
|
def retrieve_component_config(target)
|
133
133
|
YAML.load_file(target)
|
@@ -307,7 +307,7 @@ WARNING
|
|
307
307
|
# require_dependencies('json', :version => ">=1.2.3")
|
308
308
|
#
|
309
309
|
def require_dependencies(*gem_names)
|
310
|
-
options = gem_names.
|
310
|
+
options = gem_names.last.is_a?(Hash) ? gem_names.pop : {}
|
311
311
|
gem_names.reverse_each { |lib| insert_into_gemfile(lib, options) }
|
312
312
|
end
|
313
313
|
|
@@ -631,7 +631,7 @@ WARNING
|
|
631
631
|
#
|
632
632
|
# @example
|
633
633
|
# available_choices_for :test
|
634
|
-
# => [:shoulda, :bacon, :
|
634
|
+
# => [:shoulda, :bacon, :minitest]
|
635
635
|
#
|
636
636
|
def available_choices_for(component)
|
637
637
|
@available_choices[component] + [:none]
|
@@ -29,7 +29,7 @@ module Padrino
|
|
29
29
|
def setup_components
|
30
30
|
self.destination_root = options[:root]
|
31
31
|
if in_app_root?
|
32
|
-
@_components = options.
|
32
|
+
@_components = options.class.new options.select{ |key,_| self.class.component_types.include?(key.to_sym) }
|
33
33
|
@app_name = (options[:app] || "App").gsub(/\W/, '_').camelize
|
34
34
|
if @_components.values.delete_if(&:blank?).empty?
|
35
35
|
self.class.start(["-h"])
|
@@ -3,8 +3,6 @@ def setup_mock
|
|
3
3
|
case options[:test].to_s
|
4
4
|
when 'rspec'
|
5
5
|
inject_into_file 'spec/spec_helper.rb', "require 'rr'\n", :after => "\"/../config/boot\")\n"
|
6
|
-
when 'riot'
|
7
|
-
inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\")\n"
|
8
6
|
when 'minitest'
|
9
7
|
insert_mocking_include "RR::Adapters::MiniTest", :path => "test/test_config.rb"
|
10
8
|
else
|
@@ -11,6 +11,7 @@ MONGO
|
|
11
11
|
def setup_orm
|
12
12
|
require_dependencies 'mongo_mapper'
|
13
13
|
require_dependencies 'bson_ext', :require => 'mongo'
|
14
|
+
require_dependencies 'activemodel', :version => '< 5'
|
14
15
|
create_file("config/database.rb", MONGO.gsub(/!NAME!/, @project_name.underscore))
|
15
16
|
end
|
16
17
|
|
@@ -91,6 +91,7 @@ TEST
|
|
91
91
|
def setup_test
|
92
92
|
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
93
93
|
require_dependencies 'shoulda', :group => 'test'
|
94
|
+
require_dependencies 'test-unit', :group => 'test'
|
94
95
|
insert_test_suite_setup SHOULDA_SETUP
|
95
96
|
create_file destination_root("test/test.rake"), SHOULDA_RAKE
|
96
97
|
end
|
@@ -82,7 +82,7 @@ module Padrino
|
|
82
82
|
#
|
83
83
|
def setup_components
|
84
84
|
return if options[:template]
|
85
|
-
@_components = options.
|
85
|
+
@_components = options.class.new options.select{ |key,_| self.class.component_types.include?(key.to_sym) }
|
86
86
|
self.class.component_types.each do |comp|
|
87
87
|
choice = @_components[comp] = resolve_valid_choice(comp)
|
88
88
|
execute_component_setup(comp, choice)
|
@@ -109,7 +109,7 @@ module Padrino
|
|
109
109
|
|
110
110
|
proc{|*args| args.map{|str| str.gsub!(/!PATH!/, recognize_path)} }.call(controller_content, helper_content)
|
111
111
|
|
112
|
-
directory_name = [:rspec
|
112
|
+
directory_name = [:rspec].include?(test_component.to_sym) ? "spec" : "test"
|
113
113
|
base_path = File.join(directory_name, "app")
|
114
114
|
create_file destination_root("#{base_path}/controllers/controllers_#{directory_name}.rb"), controller_content, :skip => true
|
115
115
|
create_file destination_root("#{base_path}/helpers/helpers_#{directory_name}.rb"), helper_content, :skip => true
|
@@ -136,7 +136,7 @@ module Padrino
|
|
136
136
|
say "#{name} is ready for development!", :green
|
137
137
|
say '=' * 65, :green
|
138
138
|
say "$ cd #{options[:root]}/#{name}"
|
139
|
-
say "$ bundle" unless options[:bundle]
|
139
|
+
say "$ bundle --binstubs" unless options[:bundle]
|
140
140
|
say "=" * 65, :green
|
141
141
|
say
|
142
142
|
end
|
data/test/helper.rb
CHANGED
@@ -73,10 +73,10 @@ class MiniTest::Spec
|
|
73
73
|
|
74
74
|
# expects_generated_project :test => :shoulda, :orm => :activerecord, :dev => true
|
75
75
|
def expects_generated_project(options={})
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
components =
|
76
|
+
options = options.dup
|
77
|
+
project_root = options.delete(:root)
|
78
|
+
project_name = options.delete(:name)
|
79
|
+
components = options.sort_by{ |k, v| k.to_s }.map{ |component, value| "--#{component}=#{value}" }
|
80
80
|
params = [project_name, *components].push("-r=#{project_root}")
|
81
81
|
Padrino.expects(:bin_gen).with(*params.unshift('project')).returns(true)
|
82
82
|
end
|
@@ -126,19 +126,6 @@ describe "ControllerGenerator" do
|
|
126
126
|
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
|
127
127
|
end
|
128
128
|
|
129
|
-
it 'should generate controller test for riot' do
|
130
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot') }
|
131
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
132
|
-
capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
133
|
-
capture_io { generate(:controller, 'UserItems','-a=/subby', "-r=#{@apptmp}/sample_project", "-p=user") }
|
134
|
-
assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
|
135
|
-
assert_match_in_file(/context "\/demo_items" do/m, @controller_test_path.gsub('app','subby'))
|
136
|
-
assert_match_in_file(/context "\/user\/:user_id\/user_items"/, @controller_with_parent_test_path.gsub('app','subby'))
|
137
|
-
assert_match_in_file(/get "\/demo_items"/m, @controller_test_path.gsub('app','subby'))
|
138
|
-
assert_match_in_file(/get "\/user\/1\/user_items"/m, @controller_with_parent_test_path.gsub('app','subby'))
|
139
|
-
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
|
140
|
-
end
|
141
|
-
|
142
129
|
it 'should generate controller test for minitest' do
|
143
130
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=minitest') }
|
144
131
|
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
@@ -179,20 +166,6 @@ describe "ControllerGenerator" do
|
|
179
166
|
assert_file_exists("#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
|
180
167
|
end
|
181
168
|
|
182
|
-
it 'should generate controller test for steak' do
|
183
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=steak') }
|
184
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
185
|
-
capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
186
|
-
capture_io { generate(:controller, 'UserItems','-a=/subby', "-r=#{@apptmp}/sample_project", "-p=user") }
|
187
|
-
assert_match_in_file(/describe "\/demo_items" do/m, "#{@apptmp}/sample_project/spec/subby/controllers/demo_items_controller_spec.rb")
|
188
|
-
assert_match_in_file(/feature "\/demo_items" do/m, "#{@apptmp}/sample_project/spec/subby/acceptance/controllers/demo_items_controller_spec.rb")
|
189
|
-
assert_match_in_file(/describe "\/user\/:user_id\/user_items" do/m, "#{@apptmp}/sample_project/spec/subby/controllers/user_items_controller_spec.rb")
|
190
|
-
assert_match_in_file(/get "\/demo_items"/m, "#{@apptmp}/sample_project/spec/subby/controllers/demo_items_controller_spec.rb")
|
191
|
-
assert_match_in_file(/get "\/user\/1\/user_items"/m, "#{@apptmp}/sample_project/spec/subby/controllers/user_items_controller_spec.rb")
|
192
|
-
assert_match_in_file(/feature "\/user\/:user_id\/user_items" do/m, "#{@apptmp}/sample_project/spec/subby/acceptance/controllers/user_items_controller_spec.rb")
|
193
|
-
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
|
194
|
-
end
|
195
|
-
|
196
169
|
it 'should generate controller test for cucumber' do
|
197
170
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=cucumber') }
|
198
171
|
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
@@ -62,13 +62,6 @@ describe "HelperGenerator" do
|
|
62
62
|
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'should generate helper test for riot' do
|
66
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot') }
|
67
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
68
|
-
capture_io { generate(:helper, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
69
|
-
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
|
70
|
-
end
|
71
|
-
|
72
65
|
it 'should generate helper test for minitest' do
|
73
66
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=minitest') }
|
74
67
|
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
@@ -93,13 +86,6 @@ describe "HelperGenerator" do
|
|
93
86
|
assert_file_exists("#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
|
94
87
|
end
|
95
88
|
|
96
|
-
it 'should generate helper test for steak' do
|
97
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=steak') }
|
98
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
99
|
-
capture_io { generate(:helper, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
|
100
|
-
assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
|
101
|
-
end
|
102
|
-
|
103
89
|
it "should generate helper test for testunit" do
|
104
90
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none') }
|
105
91
|
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
@@ -435,27 +435,6 @@ describe "ModelGenerator" do
|
|
435
435
|
assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
|
436
436
|
end
|
437
437
|
|
438
|
-
# RIOT
|
439
|
-
it 'should generate test file for riot' do
|
440
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
|
441
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
442
|
-
capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
|
443
|
-
assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
|
444
|
-
assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
|
445
|
-
assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
|
446
|
-
assert_match_in_file(/'(\/\.\.){1}\/test/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
|
447
|
-
end
|
448
|
-
|
449
|
-
it 'should generate test file for riot in specified app' do
|
450
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
|
451
|
-
capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
|
452
|
-
capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
|
453
|
-
assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
|
454
|
-
assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
|
455
|
-
assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
|
456
|
-
assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
|
457
|
-
end
|
458
|
-
|
459
438
|
# MINITEST
|
460
439
|
it 'should generate test file for minitest' do
|
461
440
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=minitest', '-d=activerecord') }
|
@@ -176,11 +176,11 @@ describe "ProjectGenerator" do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'should create components file containing options chosen' do
|
179
|
-
component_options = ['--orm=datamapper', '--test=
|
179
|
+
component_options = ['--orm=datamapper', '--test=rspec', '--mock=mocha', '--script=prototype', '--renderer=erb', '--stylesheet=less']
|
180
180
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
181
181
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
182
182
|
assert_equal 'datamapper', components_chosen[:orm]
|
183
|
-
assert_equal '
|
183
|
+
assert_equal 'rspec', components_chosen[:test]
|
184
184
|
assert_equal 'mocha', components_chosen[:mock]
|
185
185
|
assert_equal 'prototype', components_chosen[:script]
|
186
186
|
assert_equal 'erb', components_chosen[:renderer]
|
@@ -188,10 +188,10 @@ describe "ProjectGenerator" do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should output to log components being applied' do
|
191
|
-
component_options = ['--orm=datamapper', '--test=
|
191
|
+
component_options = ['--orm=datamapper', '--test=rspec', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
192
192
|
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
193
193
|
assert_match(/applying.*?datamapper.*?orm/, out)
|
194
|
-
assert_match(/applying.*?
|
194
|
+
assert_match(/applying.*?rspec.*?test/, out)
|
195
195
|
assert_match(/applying.*?mocha.*?mock/, out)
|
196
196
|
assert_match(/applying.*?prototype.*?script/, out)
|
197
197
|
assert_match(/applying.*?erb.*?renderer/, out)
|
@@ -217,13 +217,6 @@ describe "ProjectGenerator" do
|
|
217
217
|
end
|
218
218
|
|
219
219
|
describe "a generator for mock component" do
|
220
|
-
it 'should properly generate for rr and riot' do
|
221
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=riot', '--script=none') }
|
222
|
-
assert_match(/applying.*?rr.*?mock/, out)
|
223
|
-
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
224
|
-
assert_match_in_file(/require 'riot\/rr'/, "#{@apptmp}/sample_project/test/test_config.rb")
|
225
|
-
end
|
226
|
-
|
227
220
|
it 'should properly generate for rr and minitest' do
|
228
221
|
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=minitest', '--script=none') }
|
229
222
|
assert_match(/applying.*?rr.*?mock/, out)
|
@@ -251,13 +244,6 @@ describe "ProjectGenerator" do
|
|
251
244
|
assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
|
252
245
|
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
253
246
|
end
|
254
|
-
|
255
|
-
it 'should properly generate for mocha and riot' do
|
256
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--mock=mocha', '--script=none') }
|
257
|
-
assert_match(/applying.*?mocha.*?mock/, out)
|
258
|
-
assert_match_in_file(/gem 'mocha'.*require => false/, "#{@apptmp}/sample_project/Gemfile")
|
259
|
-
assert_match_in_file(/require 'mocha\/api'/, "#{@apptmp}/sample_project/test/test_config.rb")
|
260
|
-
end
|
261
247
|
end
|
262
248
|
|
263
249
|
describe "the generator for orm components" do
|
@@ -506,14 +492,6 @@ describe "ProjectGenerator" do
|
|
506
492
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
507
493
|
end
|
508
494
|
|
509
|
-
it 'should properly generate for rightjs' do
|
510
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=rightjs') }
|
511
|
-
assert_match(/applying.*?rightjs.*?script/, out)
|
512
|
-
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right.js")
|
513
|
-
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right-ujs.js")
|
514
|
-
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
515
|
-
end
|
516
|
-
|
517
495
|
it 'should properly generate for ext-core' do
|
518
496
|
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=extcore') }
|
519
497
|
assert_match(/applying.*?extcore.*?script/, out)
|
@@ -546,23 +524,6 @@ describe "ProjectGenerator" do
|
|
546
524
|
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
547
525
|
end
|
548
526
|
|
549
|
-
it 'should properly generate for riot' do
|
550
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--script=none') }
|
551
|
-
assert_match(/applying.*?riot.*?test/, out)
|
552
|
-
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
553
|
-
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
554
|
-
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
555
|
-
assert_match_in_file(/gem 'riot'/, "#{@apptmp}/sample_project/Gemfile")
|
556
|
-
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
557
|
-
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
558
|
-
assert_match_in_file(/Riot::Situation/, "#{@apptmp}/sample_project/test/test_config.rb")
|
559
|
-
assert_match_in_file(/Riot::Context/, "#{@apptmp}/sample_project/test/test_config.rb")
|
560
|
-
assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
561
|
-
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
562
|
-
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
563
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
564
|
-
end
|
565
|
-
|
566
527
|
it 'should properly generate for rspec' do
|
567
528
|
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
568
529
|
assert_match(/applying.*?rspec.*?test/, out)
|
@@ -591,20 +552,6 @@ describe "ProjectGenerator" do
|
|
591
552
|
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
592
553
|
end
|
593
554
|
|
594
|
-
it 'should properly generate for steak' do
|
595
|
-
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=steak', '--script=none') }
|
596
|
-
assert_match(/applying.*?steak.*?test/, out)
|
597
|
-
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
598
|
-
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
599
|
-
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
600
|
-
assert_match_in_file(/gem 'steak'/, "#{@apptmp}/sample_project/Gemfile")
|
601
|
-
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
602
|
-
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
603
|
-
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
604
|
-
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
605
|
-
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
606
|
-
end
|
607
|
-
|
608
555
|
it 'should properly generate for minitest' do
|
609
556
|
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') }
|
610
557
|
assert_match(/applying.*?minitest.*?test/, out)
|
@@ -694,16 +641,6 @@ describe "ProjectGenerator" do
|
|
694
641
|
assert_match_in_file(/RSpec.describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
695
642
|
end
|
696
643
|
|
697
|
-
it "should properly generate for steak" do
|
698
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=steak") }
|
699
|
-
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
700
|
-
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
701
|
-
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
702
|
-
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
703
|
-
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
704
|
-
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
705
|
-
end
|
706
|
-
|
707
644
|
it "should properly generate for cucumber" do
|
708
645
|
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=cucumber") }
|
709
646
|
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
@@ -734,16 +671,6 @@ describe "ProjectGenerator" do
|
|
734
671
|
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
735
672
|
end
|
736
673
|
|
737
|
-
it "should properly generate for riot" do
|
738
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=riot") }
|
739
|
-
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
740
|
-
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
741
|
-
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
742
|
-
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
743
|
-
assert_match_in_file(/context "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
744
|
-
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
745
|
-
end
|
746
|
-
|
747
674
|
it "should properly generate for shoulda" do
|
748
675
|
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=shoulda") }
|
749
676
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
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.13.
|
4
|
+
version: 0.13.3
|
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: 2016-
|
14
|
+
date: 2016-08-17 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.13.
|
22
|
+
version: 0.13.3
|
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.13.
|
29
|
+
version: 0.13.3
|
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.13.
|
50
|
+
version: 0.13.3
|
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.13.
|
57
|
+
version: 0.13.3
|
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.13.
|
64
|
+
version: 0.13.3
|
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.13.
|
71
|
+
version: 0.13.3
|
72
72
|
description: Generators for easily creating and building padrino applications from
|
73
73
|
the console
|
74
74
|
email: padrinorb@gmail.com
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- lib/padrino-gen/generators/components/scripts/jquery.rb
|
116
116
|
- lib/padrino-gen/generators/components/scripts/mootools.rb
|
117
117
|
- lib/padrino-gen/generators/components/scripts/prototype.rb
|
118
|
-
- lib/padrino-gen/generators/components/scripts/rightjs.rb
|
119
118
|
- lib/padrino-gen/generators/components/stylesheets/compass.rb
|
120
119
|
- lib/padrino-gen/generators/components/stylesheets/compass/application.scss
|
121
120
|
- lib/padrino-gen/generators/components/stylesheets/compass/partials/_base.scss
|
@@ -125,10 +124,8 @@ files:
|
|
125
124
|
- lib/padrino-gen/generators/components/tests/bacon.rb
|
126
125
|
- lib/padrino-gen/generators/components/tests/cucumber.rb
|
127
126
|
- lib/padrino-gen/generators/components/tests/minitest.rb
|
128
|
-
- lib/padrino-gen/generators/components/tests/riot.rb
|
129
127
|
- lib/padrino-gen/generators/components/tests/rspec.rb
|
130
128
|
- lib/padrino-gen/generators/components/tests/shoulda.rb
|
131
|
-
- lib/padrino-gen/generators/components/tests/steak.rb
|
132
129
|
- lib/padrino-gen/generators/components/tests/testunit.rb
|
133
130
|
- lib/padrino-gen/generators/controller.rb
|
134
131
|
- lib/padrino-gen/generators/helper.rb
|
@@ -218,27 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
215
|
version: 1.3.6
|
219
216
|
requirements: []
|
220
217
|
rubyforge_project: padrino-gen
|
221
|
-
rubygems_version: 2.4
|
218
|
+
rubygems_version: 2.6.4
|
222
219
|
signing_key:
|
223
220
|
specification_version: 4
|
224
221
|
summary: Generators for easily creating and building padrino applications
|
225
|
-
test_files:
|
226
|
-
- test/fixtures/admin_template.rb
|
227
|
-
- test/fixtures/example_template.rb
|
228
|
-
- test/fixtures/git_template.rb
|
229
|
-
- test/fixtures/plugin_template.rb
|
230
|
-
- test/fixtures/rake_template.rb
|
231
|
-
- test/helper.rb
|
232
|
-
- test/test_app_generator.rb
|
233
|
-
- test/test_cli.rb
|
234
|
-
- test/test_component_generator.rb
|
235
|
-
- test/test_controller_generator.rb
|
236
|
-
- test/test_generator.rb
|
237
|
-
- test/test_helper_generator.rb
|
238
|
-
- test/test_mailer_generator.rb
|
239
|
-
- test/test_migration_generator.rb
|
240
|
-
- test/test_model_generator.rb
|
241
|
-
- test/test_plugin_generator.rb
|
242
|
-
- test/test_project_generator.rb
|
243
|
-
- test/test_task_generator.rb
|
244
|
-
has_rdoc:
|
222
|
+
test_files: []
|
@@ -1,10 +0,0 @@
|
|
1
|
-
def setup_script
|
2
|
-
begin
|
3
|
-
get('https://raw.github.com/padrino/padrino-static/master/js/right.js', destination_root("/public/javascripts/right.js"))
|
4
|
-
get('https://raw.github.com/padrino/padrino-static/master/ujs/right.js', destination_root("/public/javascripts/right-ujs.js"))
|
5
|
-
rescue
|
6
|
-
copy_file('templates/static/js/right.js', destination_root("/public/javascripts/right.js"))
|
7
|
-
copy_file('templates/static/ujs/right.js', destination_root("/public/javascripts/right-ujs.js"))
|
8
|
-
end
|
9
|
-
create_file(destination_root('/public/javascripts/application.js'), "// Put your application scripts here")
|
10
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_SETUP)
|
2
|
-
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
-
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
5
|
-
|
6
|
-
# Specify your app using the #app helper inside a context.
|
7
|
-
# Takes either an app class or a block argument.
|
8
|
-
# app { Padrino.application }
|
9
|
-
# app { CLASS_NAME.tap { |app| } }
|
10
|
-
|
11
|
-
class Riot::Situation
|
12
|
-
include Rack::Test::Methods
|
13
|
-
|
14
|
-
# You can use this method to custom specify a Rack app
|
15
|
-
# you want rack-test to invoke:
|
16
|
-
#
|
17
|
-
# app CLASS_NAME
|
18
|
-
# app CLASS_NAME.tap { |a| }
|
19
|
-
# app(CLASS_NAME) do
|
20
|
-
# set :foo, :bar
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
def app(app = nil, &blk)
|
24
|
-
@app ||= block_given? ? app.instance_eval(&blk) : app
|
25
|
-
@app ||= Padrino.application
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class Riot::Context
|
30
|
-
end
|
31
|
-
|
32
|
-
TEST
|
33
|
-
|
34
|
-
RIOT_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_CONTROLLER_TEST)
|
35
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
|
36
|
-
|
37
|
-
context "!PATH!" do
|
38
|
-
context "description here" do
|
39
|
-
setup do
|
40
|
-
get "!EXPANDED_PATH!"
|
41
|
-
end
|
42
|
-
|
43
|
-
asserts("the response body") { last_response.body }.equals "Hello World"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
TEST
|
47
|
-
|
48
|
-
RIOT_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_RAKE)
|
49
|
-
require 'rake/testtask'
|
50
|
-
|
51
|
-
test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
|
52
|
-
|
53
|
-
test_tasks.each do |folder|
|
54
|
-
Rake::TestTask.new("test:\#{folder}") do |test|
|
55
|
-
test.pattern = "test/\#{folder}/**/*_test.rb"
|
56
|
-
test.verbose = true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "Run application test suite"
|
61
|
-
task 'test' => test_tasks.map { |f| "test:\#{f}" }
|
62
|
-
|
63
|
-
task :default => :test
|
64
|
-
TEST
|
65
|
-
|
66
|
-
RIOT_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_MODEL_TEST)
|
67
|
-
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
|
68
|
-
|
69
|
-
context "!NAME! Model" do
|
70
|
-
context 'can be created' do
|
71
|
-
setup do
|
72
|
-
!NAME!.new
|
73
|
-
end
|
74
|
-
|
75
|
-
asserts("that record is not nil") { !topic.nil? }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
TEST
|
79
|
-
|
80
|
-
RIOT_HELPER_TEST = (<<-TEST) unless defined?(RIOT_HELPER_TEST)
|
81
|
-
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
|
82
|
-
|
83
|
-
describe "!NAME!" do
|
84
|
-
setup do
|
85
|
-
helpers = Class.new
|
86
|
-
helpers.extend !NAME!
|
87
|
-
[helpers.foo]
|
88
|
-
end
|
89
|
-
|
90
|
-
asserts("#foo"){ topic.first }.nil
|
91
|
-
end
|
92
|
-
TEST
|
93
|
-
|
94
|
-
def setup_test
|
95
|
-
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
96
|
-
require_dependencies 'riot', :group => 'test'
|
97
|
-
insert_test_suite_setup RIOT_SETUP
|
98
|
-
create_file destination_root("test/test.rake"), RIOT_RAKE
|
99
|
-
end
|
100
|
-
|
101
|
-
def generate_controller_test(name, path)
|
102
|
-
riot_contents = RIOT_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
|
103
|
-
controller_test_path = File.join('test',options[:app],'controllers',"#{name.to_s.underscore}_controller_test.rb")
|
104
|
-
create_file destination_root(controller_test_path), riot_contents, :skip => true
|
105
|
-
end
|
106
|
-
|
107
|
-
def generate_model_test(name)
|
108
|
-
riot_contents = RIOT_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
109
|
-
riot_contents.gsub!(/!PATH!/, recognize_path)
|
110
|
-
model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
|
111
|
-
create_file destination_root(model_test_path), riot_contents, :skip => true
|
112
|
-
end
|
113
|
-
|
114
|
-
def generate_helper_test(name, project_name, app_name)
|
115
|
-
riot_contents = RIOT_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
|
116
|
-
riot_contents.gsub!(/!PATH!/, recognize_path)
|
117
|
-
helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
|
118
|
-
create_file destination_root(helper_spec_path), riot_contents, :skip => true
|
119
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
STEAK_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_SETUP)
|
2
|
-
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
-
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
5
|
-
|
6
|
-
RSpec.configure do |conf|
|
7
|
-
conf.include Rack::Test::Methods
|
8
|
-
conf.include Capybara
|
9
|
-
end
|
10
|
-
|
11
|
-
def app
|
12
|
-
##
|
13
|
-
# You can handle all padrino applications using instead:
|
14
|
-
# Padrino.application
|
15
|
-
CLASS_NAME.tap { |app| }
|
16
|
-
end
|
17
|
-
|
18
|
-
Capybara.app = app
|
19
|
-
TEST
|
20
|
-
|
21
|
-
STEAK_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_TEST)
|
22
|
-
require 'spec_helper'
|
23
|
-
|
24
|
-
describe "!PATH!" do
|
25
|
-
before do
|
26
|
-
get "!EXPANDED_PATH!"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "returns hello world" do
|
30
|
-
last_response.body.should == "Hello World"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
TEST
|
34
|
-
|
35
|
-
STEAK_CONTROLLER_ACCEPTANCE_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_ACCEPTANCE_TEST)
|
36
|
-
require 'spec_helper'
|
37
|
-
|
38
|
-
feature "!PATH!" do
|
39
|
-
background do
|
40
|
-
visit "!EXPANDED_PATH!"
|
41
|
-
end
|
42
|
-
|
43
|
-
scenario "returns hello world" do
|
44
|
-
page.should.have_content == "Hello World"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
TEST
|
48
|
-
|
49
|
-
STEAK_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_RAKE)
|
50
|
-
require 'rspec/core/rake_task'
|
51
|
-
|
52
|
-
spec_tasks = Dir['spec/*/'].map { |d| File.basename(d) }
|
53
|
-
|
54
|
-
spec_tasks.each do |folder|
|
55
|
-
RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
|
56
|
-
t.pattern = "./spec/\#{folder}/**/*_spec.rb"
|
57
|
-
t.rspec_opts = %w(-fs --color)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "Run complete application spec suite"
|
62
|
-
task 'spec' => spec_tasks.map { |f| "spec:\#{f}" }
|
63
|
-
|
64
|
-
task :default => :spec
|
65
|
-
TEST
|
66
|
-
|
67
|
-
STEAK_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_MODEL_TEST)
|
68
|
-
require 'spec_helper'
|
69
|
-
|
70
|
-
describe !NAME! do
|
71
|
-
end
|
72
|
-
TEST
|
73
|
-
|
74
|
-
STEAK_HELPER_TEST = <<-TEST unless defined?(STEAK_HELPER_TEST)
|
75
|
-
require 'spec_helper'
|
76
|
-
|
77
|
-
describe "!NAME!" do
|
78
|
-
let(:helpers){ Class.new }
|
79
|
-
before { helpers.extend !NAME! }
|
80
|
-
subject { helpers }
|
81
|
-
|
82
|
-
it "should return nil" do
|
83
|
-
expect(subject.foo).to be_nil
|
84
|
-
end
|
85
|
-
end
|
86
|
-
TEST
|
87
|
-
|
88
|
-
def setup_test
|
89
|
-
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
90
|
-
require_dependencies 'steak', :group => 'test'
|
91
|
-
insert_test_suite_setup STEAK_SETUP, :path => "spec/spec_helper.rb"
|
92
|
-
create_file destination_root("spec/spec.rake"), STEAK_RAKE
|
93
|
-
end
|
94
|
-
|
95
|
-
# Generates a controller test given the controllers name
|
96
|
-
def generate_controller_test(name, path)
|
97
|
-
spec_contents = STEAK_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
|
98
|
-
controller_spec_path = File.join('spec',options[:app],'controllers',"#{name.to_s.underscore}_controller_spec.rb")
|
99
|
-
create_file destination_root(controller_spec_path), spec_contents, :skip => true
|
100
|
-
|
101
|
-
acceptance_contents = STEAK_CONTROLLER_ACCEPTANCE_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
|
102
|
-
controller_acceptance_path = File.join('spec',options[:app],'acceptance','controllers',"#{name.to_s.underscore}_controller_spec.rb")
|
103
|
-
create_file destination_root(controller_acceptance_path), acceptance_contents, :skip => true
|
104
|
-
end
|
105
|
-
|
106
|
-
def generate_model_test(name)
|
107
|
-
rspec_contents = STEAK_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
|
108
|
-
model_spec_path = File.join('spec',options[:app],'models',"#{name.to_s.underscore}_spec.rb")
|
109
|
-
create_file destination_root(model_spec_path), rspec_contents, :skip => true
|
110
|
-
end
|
111
|
-
|
112
|
-
def generate_helper_test(name, project_name, app_name)
|
113
|
-
rspec_contents = STEAK_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
|
114
|
-
helper_spec_path = File.join('spec', options[:app], 'helpers', "#{name.underscore}_spec.rb")
|
115
|
-
create_file destination_root(helper_spec_path), rspec_contents, :skip => true
|
116
|
-
end
|