padrino-gen 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7628694455061d5f6906099df64d2570594b629
4
- data.tar.gz: 30c14c0393ea4289e1aa41d06d579646e1f864b7
3
+ metadata.gz: effdab76dcbf3f1dec71da8a9272954f2ab5bd3f
4
+ data.tar.gz: 1aaab8565a82db9b0ccb97da317318b54c12415e
5
5
  SHA512:
6
- metadata.gz: c230053d26d0c623f1f03b5ef036f7f0b0315f14bdc3b3abeb8d8cfc327584407d27b3d04fa590c5fdaf4110d2a71d309ddf9ca7697c91dbe600a4a7c3991bc2
7
- data.tar.gz: 226607ee34f61de01dd944de3dd97245c70c2b9b033e978e663c4983edfa05e95cd936667dfa20791324198ad6025c801448a0c664943741832f69c232d5f9d0
6
+ metadata.gz: ab6563038789f50343e38c33e648404239470ef2ebbec10b70ea6225ee24b2cd6f9a7794bdf51a705a16ee8cf8f74f5499e74746219ad14f33251b47f89c189f
7
+ data.tar.gz: ca0642e0a51ab6f870be8e36bf271d2bae826f8885cad03ec2d88f4190a1869954c0b42e9b6004daad239a1eefa5c9b52e02e15a831196d9e3b1ec6326cbe658
@@ -495,6 +495,13 @@ WARNING
495
495
  end
496
496
  end
497
497
 
498
+ ##
499
+ # Recognizes the path of application.
500
+ #
501
+ def recognize_path
502
+ options[:app] == '.' ? '/..' : '/../..'
503
+ end
504
+
498
505
  # Class methods for Thor generators to support the generators and component choices.
499
506
  module ClassMethods
500
507
  ##
@@ -59,6 +59,21 @@ describe "!NAME! Model" do
59
59
  end
60
60
  TEST
61
61
 
62
+ BACON_HELPER_TEST = <<-TEST unless defined?(BACON_HELPER_TEST)
63
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
64
+
65
+ describe "!NAME!" do
66
+ before do
67
+ @helpers = Class.new
68
+ @helpers.extend !NAME!
69
+ end
70
+
71
+ it "should return nil" do
72
+ @helpers.foo.should.equal nil
73
+ end
74
+ end
75
+ TEST
76
+
62
77
  def setup_test
63
78
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
64
79
  require_dependencies 'bacon', :group => 'test'
@@ -74,8 +89,14 @@ end
74
89
 
75
90
  def generate_model_test(name)
76
91
  bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
77
- path = options[:app] == '.' ? '/..' : '/../..'
78
- bacon_contents.gsub!(/!PATH!/,path)
92
+ bacon_contents.gsub!(/!PATH!/, recognize_path)
79
93
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
80
94
  create_file destination_root(model_test_path), bacon_contents, :skip => true
81
95
  end
96
+
97
+ def generate_helper_test(name, project_name, app_name)
98
+ bacon_contents = BACON_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
99
+ bacon_contents.gsub!(/!PATH!/, recognize_path)
100
+ helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
101
+ create_file destination_root(helper_spec_path), bacon_contents, :skip => true
102
+ end
@@ -2,7 +2,7 @@ MINITEST_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_SETUP)
2
2
  RACK_ENV = 'test' unless defined?(RACK_ENV)
3
3
  require File.expand_path('../../config/boot', __FILE__)
4
4
 
5
- class MiniTest::Unit::TestCase
5
+ class MiniTest::Spec
6
6
  include Rack::Test::Methods
7
7
 
8
8
  # You can use this method to custom specify a Rack app
@@ -62,6 +62,25 @@ describe "!NAME! Model" do
62
62
  end
63
63
  TEST
64
64
 
65
+ MINITEST_HELPER_TEST = (<<-TEST) unless defined?(MINITEST_HELPER_TEST)
66
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
67
+
68
+ describe "!NAME!" do
69
+ before do
70
+ @helpers = Class.new
71
+ @helpers.extend !NAME!
72
+ end
73
+
74
+ def helpers
75
+ @helpers
76
+ end
77
+
78
+ it "should return nil" do
79
+ assert_equal nil, helpers.foo
80
+ end
81
+ end
82
+ TEST
83
+
65
84
  def setup_test
66
85
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
67
86
  require_dependencies 'minitest', :require => 'minitest/autorun', :group => 'test'
@@ -77,8 +96,14 @@ end
77
96
 
78
97
  def generate_model_test(name)
79
98
  minitest_contents = MINITEST_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
80
- path = options[:app] == '.' ? '/..' : '/../..'
81
- minitest_contents.gsub!(/!PATH!/,path)
99
+ minitest_contents.gsub!(/!PATH!/, recognize_path)
82
100
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
83
101
  create_file destination_root(model_test_path), minitest_contents, :skip => true
84
102
  end
103
+
104
+ def generate_helper_test(name, project_name, app_name)
105
+ minitest_contents = MINITEST_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
106
+ minitest_contents.gsub!(/!PATH!/, recognize_path)
107
+ helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
108
+ create_file destination_root(helper_spec_path), minitest_contents, :skip => true
109
+ end
@@ -74,6 +74,20 @@ context "!NAME! Model" do
74
74
  end
75
75
  TEST
76
76
 
77
+ RIOT_HELPER_TEST = (<<-TEST) unless defined?(RIOT_HELPER_TEST)
78
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
79
+
80
+ describe "!NAME!" do
81
+ setup do
82
+ helpers = Class.new
83
+ helpers.extend !NAME!
84
+ [helpers.foo]
85
+ end
86
+
87
+ asserts("#foo"){ topic.first }.nil
88
+ end
89
+ TEST
90
+
77
91
  def setup_test
78
92
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
79
93
  require_dependencies 'riot', :group => 'test'
@@ -89,8 +103,14 @@ end
89
103
 
90
104
  def generate_model_test(name)
91
105
  riot_contents = RIOT_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize)
92
- path = options[:app] == '.' ? '/..' : '/../..'
93
- riot_contents.gsub!(/!PATH!/,path)
106
+ riot_contents.gsub!(/!PATH!/, recognize_path)
94
107
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
95
108
  create_file destination_root(model_test_path), riot_contents, :skip => true
96
109
  end
110
+
111
+ def generate_helper_test(name, project_name, app_name)
112
+ riot_contents = RIOT_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
113
+ riot_contents.gsub!(/!PATH!/, recognize_path)
114
+ helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
115
+ create_file destination_root(helper_spec_path), riot_contents, :skip => true
116
+ end
@@ -65,6 +65,20 @@ describe !NAME! do
65
65
  end
66
66
  TEST
67
67
 
68
+ RSPEC_HELPER_TEST = (<<-TEST) unless defined?(RSPEC_HELPER_TEST)
69
+ require 'spec_helper'
70
+
71
+ describe "!NAME!" do
72
+ let(:helpers){ Class.new }
73
+ before { helpers.extend !NAME! }
74
+ subject { helpers }
75
+
76
+ it "should return nil" do
77
+ expect(subject.foo).to be_nil
78
+ end
79
+ end
80
+ TEST
81
+
68
82
  def setup_test
69
83
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
70
84
  require_dependencies 'rspec', :group => 'test'
@@ -83,3 +97,9 @@ def generate_model_test(name)
83
97
  model_spec_path = File.join('spec',options[:app],'models',"#{name.to_s.underscore}_spec.rb")
84
98
  create_file destination_root(model_spec_path), rspec_contents, :skip => true
85
99
  end
100
+
101
+ def generate_helper_test(name, project_name, app_name)
102
+ rspec_contents = RSPEC_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
103
+ helper_spec_path = File.join('spec', options[:app], 'helpers', "#{name.underscore}_spec.rb")
104
+ create_file destination_root(helper_spec_path), rspec_contents, :skip => true
105
+ end
@@ -68,6 +68,27 @@ class !NAME!Test < Test::Unit::TestCase
68
68
  end
69
69
  TEST
70
70
 
71
+ SHOULDA_HELPER_TEST = (<<-TEST) unless defined?(SHOULDA_HELPER_TEST)
72
+ require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
73
+
74
+ class !NAME!Test < Test::Unit::TestCase
75
+ context "!NAME!" do
76
+ setup do
77
+ @helpers = Class.new
78
+ @helpers.extend !NAME!
79
+ end
80
+
81
+ def helpers
82
+ @helpers
83
+ end
84
+
85
+ should "return nil" do
86
+ assert_equal nil, helpers.foo
87
+ end
88
+ end
89
+ end
90
+ TEST
91
+
71
92
  def setup_test
72
93
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
73
94
  require_dependencies 'shoulda', :group => 'test'
@@ -83,8 +104,14 @@ end
83
104
 
84
105
  def generate_model_test(name)
85
106
  shoulda_contents = SHOULDA_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
86
- path = options[:app] == '.' ? '/..' : '/../..'
87
- shoulda_contents.gsub!(/!PATH!/,path)
107
+ shoulda_contents.gsub!(/!PATH!/, recognize_path)
88
108
  model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
89
109
  create_file destination_root(model_test_path), shoulda_contents, :skip => true
90
110
  end
111
+
112
+ def generate_helper_test(name, project_name, app_name)
113
+ shoulda_contents = SHOULDA_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
114
+ shoulda_contents.gsub!(/!PATH!/, recognize_path)
115
+ helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
116
+ create_file destination_root(helper_spec_path), shoulda_contents, :skip => true
117
+ end
@@ -1,5 +1,5 @@
1
1
  STEAK_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_SETUP)
2
- PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
2
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
4
 
5
5
  RSpec.configure do |conf|
@@ -68,6 +68,20 @@ describe !NAME! do
68
68
  end
69
69
  TEST
70
70
 
71
+ STEAK_HELPER_TEST = <<-TEST unless defined?(STEAK_HELPER_TEST)
72
+ require 'spec_helper'
73
+
74
+ describe "!NAME!" do
75
+ let(:helpers){ Class.new }
76
+ before { helpers.extend !NAME! }
77
+ subject { helpers }
78
+
79
+ it "should return nil" do
80
+ expect(subject.foo).to be_nil
81
+ end
82
+ end
83
+ TEST
84
+
71
85
  def setup_test
72
86
  require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
73
87
  require_dependencies 'steak', :group => 'test'
@@ -91,3 +105,9 @@ def generate_model_test(name)
91
105
  model_spec_path = File.join('spec',options[:app],'models',"#{name.to_s.underscore}_spec.rb")
92
106
  create_file destination_root(model_spec_path), rspec_contents, :skip => true
93
107
  end
108
+
109
+ def generate_helper_test(name, project_name, app_name)
110
+ rspec_contents = STEAK_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
111
+ helper_spec_path = File.join('spec', options[:app], 'helpers', "#{name.underscore}_spec.rb")
112
+ create_file destination_root(helper_spec_path), rspec_contents, :skip => true
113
+ end
@@ -42,6 +42,7 @@ module Padrino
42
42
  @app_name = fetch_app_name(app)
43
43
  @actions = controller_actions(fields)
44
44
  @controller = name.to_s.underscore
45
+ @helper_name = "#{@controller.camelize}Helper"
45
46
  @layout = options[:layout] if options[:layout] && !options[:layout].empty?
46
47
 
47
48
  block_opts = []
@@ -54,7 +55,10 @@ module Padrino
54
55
  template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb")
55
56
  empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
56
57
  include_component_module_for(:test)
57
- generate_controller_test(name) if test?
58
+ if test?
59
+ generate_controller_test(name)
60
+ generate_helper_test(@helper_name, @project_name, @app_name)
61
+ end
58
62
  else
59
63
  say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
60
64
  end
@@ -1,7 +1,13 @@
1
1
  # Helper methods defined here can be accessed in any controller or view in the application
2
2
 
3
- <%= @project_name %>::<%= @app_name %>.helpers do
4
- # def simple_helper_method
5
- # ...
6
- # end
3
+ module <%= @project_name %>
4
+ class <%= @app_name %>
5
+ module <%= @helper_name %>
6
+ # def simple_helper_method
7
+ # ...
8
+ # end
9
+ end
10
+
11
+ helpers <%= @helper_name %>
12
+ end
7
13
  end
@@ -26,6 +26,9 @@ module Padrino
26
26
  arguments << "CREATE DATABASE #{database} DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}"
27
27
 
28
28
  Process.wait Process.spawn(environment, 'mysql', *arguments)
29
+ when 'sqlite'
30
+ fail "Database #{database} already exists" if File.file?(database)
31
+ File.open(database, 'a') {}
29
32
  else
30
33
  raise "Adapter #{adapter} not supported for creating databases yet."
31
34
  end
@@ -55,6 +58,8 @@ module Padrino
55
58
  arguments << "DROP DATABASE IF EXISTS #{database}"
56
59
 
57
60
  Process.wait Process.spawn(environment, 'mysql', *arguments)
61
+ when 'sqlite'
62
+ File.delete(database) if File.file?(database)
58
63
  else
59
64
  raise "Adapter #{adapter} not supported for dropping databases yet."
60
65
  end
@@ -72,7 +72,7 @@ describe "AppGenerator" do
72
72
  capture_io { generate(:app, 'demo', "--root=#{@apptmp}/sample_project") }
73
73
  capture_io { generate(:controller, 'demo_items', "-r=#{@apptmp}/sample_project", '-a=demo') }
74
74
  assert_match_in_file(/SampleProject::Demo.controllers :demo_items do/m, "#{@apptmp}/sample_project/demo/controllers/demo_items.rb")
75
- assert_match_in_file(/SampleProject::Demo.helpers do/m, "#{@apptmp}/sample_project/demo/helpers/demo_items_helper.rb")
75
+ assert_match_in_file(/helpers DemoItemsHelper/m, "#{@apptmp}/sample_project/demo/helpers/demo_items_helper.rb")
76
76
  assert_file_exists("#{@apptmp}/sample_project/demo/views/demo_items")
77
77
  end
78
78
 
@@ -6,6 +6,8 @@ describe "ControllerGenerator" do
6
6
  `mkdir -p #{@apptmp}`
7
7
  @controller_path = "#{@apptmp}/sample_project/app/controllers/demo_items.rb"
8
8
  @controller_test_path = "#{@apptmp}/sample_project/test/app/controllers/demo_items_controller_test.rb"
9
+ @helper_path = "#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb"
10
+ @helper_test_path = "#{@apptmp}/sample_project/test/app/helpers/demo_items_helper_test.rb"
9
11
  end
10
12
 
11
13
  def teardown
@@ -23,16 +25,27 @@ describe "ControllerGenerator" do
23
25
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
24
26
  capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project") }
25
27
  assert_match_in_file(/SampleProject::App.controllers :demo_items do/m, @controller_path)
26
- assert_match_in_file(/SampleProject::App.helpers do/m, "#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
28
+ assert_match_in_file(/helpers DemoItemsHelper/, @helper_path)
27
29
  assert_file_exists("#{@apptmp}/sample_project/app/views/demo_items")
28
30
  assert_file_exists(@controller_test_path)
29
31
  end
30
32
 
33
+ it 'should generate helper within existing project' do
34
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
35
+ capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project") }
36
+ assert_match_in_file(/module SampleProject/, @helper_path)
37
+ assert_match_in_file(/class App/, @helper_path)
38
+ assert_match_in_file(/module DemoItemsHelper/, @helper_path)
39
+ assert_match_in_file(/helpers DemoItemsHelper/, @helper_path)
40
+ assert_file_exists(@helper_path)
41
+ assert_file_exists(@helper_test_path)
42
+ end
43
+
31
44
  it 'should generate controller within existing project with weird name' do
32
45
  capture_io { generate(:project, 'warepedia', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
33
46
  capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/warepedia") }
34
47
  assert_match_in_file(/Warepedia::App.controllers :demo_items do/m, "#{@apptmp}/warepedia/app/controllers/demo_items.rb")
35
- assert_match_in_file(/Warepedia::App.helpers do/m, "#{@apptmp}/warepedia/app/helpers/demo_items_helper.rb")
48
+ assert_match_in_file(/helpers DemoItemsHelper/, "#{@apptmp}/warepedia/app/helpers/demo_items_helper.rb")
36
49
  assert_file_exists("#{@apptmp}/warepedia/app/views/demo_items")
37
50
  end
38
51
 
@@ -41,7 +54,7 @@ describe "ControllerGenerator" do
41
54
  capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
42
55
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
43
56
  assert_match_in_file(/SampleProject::Subby.controllers :demo_items do/m, @controller_path.gsub('app','subby'))
44
- assert_match_in_file(/SampleProject::Subby.helpers do/m, "#{@apptmp}/sample_project/subby/helpers/demo_items_helper.rb")
57
+ assert_match_in_file(/helpers DemoItemsHelper/m, "#{@apptmp}/sample_project/subby/helpers/demo_items_helper.rb")
45
58
  assert_file_exists("#{@apptmp}/sample_project/subby/views/demo_items")
46
59
  assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
47
60
  end
@@ -86,7 +99,7 @@ describe "ControllerGenerator" do
86
99
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=none') }
87
100
  capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project") }
88
101
  assert_match_in_file(/SampleProject::App.controllers :demo_items do/m, @controller_path)
89
- assert_match_in_file(/SampleProject::App.helpers do/m, "#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
102
+ assert_match_in_file(/helpers DemoItemsHelper/m, "#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
90
103
  assert_file_exists("#{@apptmp}/sample_project/app/views/demo_items")
91
104
  assert_no_file_exists("#{@apptmp}/sample_project/test")
92
105
  end
@@ -97,6 +110,7 @@ describe "ControllerGenerator" do
97
110
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
98
111
  assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
99
112
  assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
113
+ assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
100
114
  end
101
115
 
102
116
  it 'should generate controller test for riot' do
@@ -105,6 +119,7 @@ describe "ControllerGenerator" do
105
119
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
106
120
  assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
107
121
  assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path.gsub('app','subby'))
122
+ assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
108
123
  end
109
124
 
110
125
  it 'should generate controller test for minitest' do
@@ -113,6 +128,7 @@ describe "ControllerGenerator" do
113
128
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
114
129
  assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app', 'subby'))
115
130
  assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path.gsub('app', 'subby'))
131
+ assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
116
132
  end
117
133
 
118
134
  it 'should generate controller test for rspec' do
@@ -120,6 +136,7 @@ describe "ControllerGenerator" do
120
136
  capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
121
137
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
122
138
  assert_match_in_file(/describe "DemoItemsController" do/m, "#{@apptmp}/sample_project/spec/subby/controllers/demo_items_controller_spec.rb")
139
+ assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
123
140
  end
124
141
 
125
142
  it 'should generate controller test for shoulda' do
@@ -129,7 +146,9 @@ describe "ControllerGenerator" do
129
146
  expected_pattern = /class DemoItemsControllerTest < Test::Unit::TestCase/m
130
147
  assert_match_in_file(expected_pattern, @controller_test_path.gsub('app','subby'))
131
148
  assert_match_in_file(/(\/\.\.){2}/m, @controller_test_path.gsub('app','subby'))
132
- assert_file_exists("#{@apptmp}/sample_project/test/subby/controllers/demo_items_controller_test.rb")
149
+ assert_match_in_file(/context "SampleProject::Subby::DemoItemsHelper" do/m, @helper_test_path.gsub('app','subby'))
150
+ assert_file_exists(@helper_test_path.gsub('app','subby'))
151
+ assert_file_exists("#{@apptmp}/sample_project/test/subby/helpers/demo_items_helper_test.rb")
133
152
  end
134
153
 
135
154
  it 'should generate controller test for steak' do
@@ -138,6 +157,7 @@ describe "ControllerGenerator" do
138
157
  capture_io { generate(:controller, 'DemoItems','-a=/subby', "-r=#{@apptmp}/sample_project") }
139
158
  assert_match_in_file(/describe "DemoItemsController" do/m, "#{@apptmp}/sample_project/spec/subby/controllers/demo_items_controller_spec.rb")
140
159
  assert_match_in_file(/feature "DemoItemsController" do/m, "#{@apptmp}/sample_project/spec/subby/acceptance/controllers/demo_items_controller_spec.rb")
160
+ assert_match_in_file(/describe "SampleProject::Subby::DemoItemsHelper" do/m, "#{@apptmp}/sample_project/spec/subby/helpers/demo_items_helper_spec.rb")
141
161
  end
142
162
 
143
163
  it 'should generate controller test for cucumber' do
@@ -155,6 +175,7 @@ describe "ControllerGenerator" do
155
175
  assert_file_exists("#{@apptmp}/sample_project/app/controllers/demo_items.rb")
156
176
  assert_file_exists("#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
157
177
  assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/demo_items_controller_spec.rb")
178
+ assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/demo_items_helper_spec.rb")
158
179
  end
159
180
 
160
181
  # Controller action generation
@@ -185,6 +206,15 @@ describe "ControllerGenerator" do
185
206
  assert_no_file_exists("#{@apptmp}/sample_project/spec/app/controllers/demo_items_controller_spec.rb")
186
207
  end
187
208
 
209
+ it 'should destroy helper files with rspec' do
210
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec') }
211
+ capture_io { generate(:controller, 'demo_items',"-r=#{@apptmp}/sample_project") }
212
+ capture_io { generate(:controller, 'demo_items',"-r=#{@apptmp}/sample_project",'-d') }
213
+ assert_no_file_exists(@controller_path)
214
+ assert_no_file_exists("#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
215
+ assert_no_file_exists("#{@apptmp}/sample_project/spec/app/helpers/demo_items_helper_spec.rb")
216
+ end
217
+
188
218
  it 'should destroy controller files in sub apps' do
189
219
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
190
220
  capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
@@ -576,7 +576,7 @@ describe "ProjectGenerator" do
576
576
  assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
577
577
  assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
578
578
  assert_match_in_file(/gem 'steak'/, "#{@apptmp}/sample_project/Gemfile")
579
- assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
579
+ assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
580
580
  assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
581
581
  assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
582
582
  assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
@@ -592,7 +592,7 @@ describe "ProjectGenerator" do
592
592
  assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
593
593
  assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
594
594
  assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
595
- assert_match_in_file(/MiniTest::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb")
595
+ assert_match_in_file(/MiniTest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
596
596
  assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
597
597
  assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
598
598
  assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
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.12.1
4
+ version: 0.12.2
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: 2014-04-04 00:00:00.000000000 Z
14
+ date: 2014-05-12 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.12.1
22
+ version: 0.12.2
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.12.1
29
+ version: 0.12.2
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.12.1
50
+ version: 0.12.2
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.12.1
57
+ version: 0.12.2
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.12.1
64
+ version: 0.12.2
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.12.1
71
+ version: 0.12.2
72
72
  description: Generators for easily creating and building padrino applications from
73
73
  the console
74
74
  email: padrinorb@gmail.com