padrino-gen 0.15.3 → 0.16.0.pre2

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
  SHA256:
3
- metadata.gz: d07100c75250bdd62f31290dba577e0ce902aa7bc6b239b799dd85c54eb5f291
4
- data.tar.gz: 39cb53d997da60d95c01702320613b862e8e2fe41c356b3b5e6e289f0334018d
3
+ metadata.gz: 2f034aa058ccb73307b88de840bb55e1e61d004c43d840676374ae1129041ea0
4
+ data.tar.gz: dc4bb733df1936970c29bb58771a1af22f8d48a5f3f49e5521ebd7e402d7d63f
5
5
  SHA512:
6
- metadata.gz: 209af2715caeaa06443aa47cb4825039cb778bfffe99994f60c8486cd3ef02a7c9ab3161b180a45756f0c325a21fb29ab18c2abe044e9fab3dd3464ed817d0b3
7
- data.tar.gz: e1786c83f0f21ded7089726d8159e0404a9d3ee51c81a1a2d380df0dea2705fdf7dcc4305200bda6db9051cced88fac7ed7f94948f4f856254820c6cb2680cb5
6
+ metadata.gz: 6810bd4a81c3829dbd581223f8555247d7b591255dae000b7aa84a367522469bd1c80a1de314feef9f2c21dc4eeae6a79cf264a0a0b8fd3a2478fdd546dcbb7c
7
+ data.tar.gz: d0a114751d530162c4fefaeed2c62eb0a36f0ec46985f9933357daf5b18c5e444b683568a4c39fa3a542bb2c90cb3877546bbe019fd03e4960ec758eba80e390
@@ -3,7 +3,7 @@ RACK_ENV = 'test' unless defined?(RACK_ENV)
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
4
  Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
5
5
 
6
- class MiniTest::Spec
6
+ class Minitest::Spec
7
7
  include Rack::Test::Methods
8
8
 
9
9
  # You can use this method to custom specify a Rack app
@@ -9,6 +9,6 @@ require 'padrino-core/cli/launcher'
9
9
  ARGV.unshift('start') if ARGV.first.nil? || ARGV.first.start_with?('-')
10
10
  Padrino::Cli::Launcher.start ARGV
11
11
 
12
- # Start the app with Rack::Server
13
- #require "rack"
14
- #Rack::Server.start
12
+ # Start the app with Rackup::Server
13
+ #require "rackup"
14
+ #Rackup::Server.start
@@ -136,7 +136,11 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
136
136
  ActiveRecord::MigrationContext.new("db/migrate/", ActiveRecord::SchemaMigration).migrate(env_migration_version)
137
137
  end
138
138
 
139
- Rake::Task["ar:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
139
+ if less_than_active_record_7_0?
140
+ Rake::Task["ar:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
141
+ else
142
+ Rake::Task["ar:schema:dump"].invoke if ActiveRecord.schema_format == :ruby
143
+ end
140
144
  end
141
145
 
142
146
  namespace :migrate do
@@ -424,6 +428,10 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
424
428
  ActiveRecord.version < Gem::Version.create("6.1.0")
425
429
  end
426
430
 
431
+ def less_than_active_record_7_0?
432
+ ActiveRecord.version < Gem::Version.create("7.0.0")
433
+ end
434
+
427
435
  def with_database(env_name)
428
436
  if less_than_active_record_6_0?
429
437
  config = ActiveRecord::Base.configurations.with_indifferent_access[env_name]
data/test/helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/pride'
3
3
  require 'rack/test'
4
- require 'fakeweb'
5
4
  require 'thor/group'
6
5
  require 'padrino-gen'
7
6
  require 'padrino-core'
@@ -9,29 +8,38 @@ require 'padrino-mailer'
9
8
  require 'padrino-helpers'
10
9
 
11
10
  require 'ext/minitest-spec'
12
- require 'ext/fakeweb-ruby24'
13
11
  require 'mocha/minitest'
12
+ require 'webmock/minitest'
14
13
 
15
14
  Padrino::Generators.load_components!
16
15
 
17
- # register fake URL to avoid downloading static files every time tests run
18
- fake_uri_base = "https://raw.github.com/padrino/padrino-static/master/"
19
- %W[
20
- js/dojo.js ujs/dojo.js
21
- js/ext.js ujs/ext.js
22
- js/jquery.js ujs/jquery.js
23
- js/mootools.js ujs/mootools.js
24
- js/right.js ujs/right.js
25
- js/protopak.js js/lowpro.js ujs/prototype.js
26
- ].each do |suffix|
27
- FakeWeb.register_uri(:get, fake_uri_base + suffix, :body => '')
28
- end
29
-
30
- class MiniTest::Spec
16
+ class Minitest::Spec
31
17
  def stop_time_for_test
32
18
  time = Time.now
33
19
  Time.stubs(:now).returns(time)
34
- return time
20
+ time
21
+ end
22
+
23
+ def stub_static_files
24
+ # register fake URL to avoid downloading static files every time tests run
25
+ fake_uri_base = "https://raw.github.com/padrino/padrino-static/master/"
26
+ %w[
27
+ js/dojo.js
28
+ js/ext.js
29
+ js/jquery.js
30
+ js/lowpro.js
31
+ js/mootools.js
32
+ js/protopak.js
33
+ js/right.js
34
+ ujs/dojo.js
35
+ ujs/ext.js
36
+ ujs/jquery.js
37
+ ujs/mootools.js
38
+ ujs/prototype.js
39
+ ujs/right.js
40
+ ].each do |suffix|
41
+ WebMock::API.stub_request(:get, fake_uri_base + suffix)
42
+ end
35
43
  end
36
44
 
37
45
  # generate(:controller, 'DemoItems', '-r=/tmp/sample_project')
@@ -44,7 +52,7 @@ class MiniTest::Spec
44
52
  def generate_with_parts(name, *params)
45
53
  features, constants = [$", Object.constants].map{|x| Marshal.load(Marshal.dump(x)) }
46
54
 
47
- if root = params.find{|x| x.index(/\-r=|\-\-root=/) }
55
+ if root = params.find{|x| x.index(/-r=|--root=/) }
48
56
  root = root.split(/=/)[1]
49
57
  options, model_path = {}, File.expand_path(File.join(root, "/models/**/*.rb"))
50
58
  options = params.pop if params.last.is_a?(Hash)
@@ -69,7 +77,7 @@ class MiniTest::Spec
69
77
  options = options.dup
70
78
  project_root = options.delete(:root)
71
79
  project_name = options.delete(:name)
72
- components = options.sort_by{ |k, v| k.to_s }.map{ |component, value| "--#{component}=#{value}" }
80
+ components = options.sort_by{ |k, _v| k.to_s }.map{ |component, value| "--#{component}=#{value}" }
73
81
  params = [project_name, *components].push("-r=#{project_root}")
74
82
  Padrino.expects(:bin_gen).with(*params.unshift('project')).returns(true)
75
83
  end
@@ -5,6 +5,7 @@ describe "ComponentGenerator" do
5
5
  def setup
6
6
  @apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}"
7
7
  `mkdir -p #{@apptmp}`
8
+ stub_static_files
8
9
  end
9
10
 
10
11
  def teardown
@@ -12,22 +12,22 @@ describe "PluginGenerator" do
12
12
 
13
13
  describe "the plugin generator" do
14
14
  it 'should respect --root option' do
15
- path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
15
+ path = File.expand_path('fixtures/plugin_template.rb', __dir__)
16
16
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
17
- out, err = capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
18
- refute_match /You are not at the root/, out
17
+ out, _err = capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
18
+ refute_match(/You are not at the root/, out)
19
19
  end
20
20
  end
21
21
 
22
22
  describe "the plugin destroy option" do
23
23
  it 'should remove the plugin instance' do
24
- path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
24
+ path = File.expand_path('fixtures/plugin_template.rb', __dir__)
25
25
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
26
26
  capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
27
27
  capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project", '-d') }
28
28
  assert_no_file_exists("#{@apptmp}/sample_project/lib/hoptoad_initializer.rb")
29
- assert_no_match_in_file(/enable \:raise_errors/,"#{@apptmp}/sample_project/app/app.rb")
30
- assert_no_match_in_file(/rack\_hoptoad/, "#{@apptmp}/sample_project/Gemfile")
29
+ assert_no_match_in_file(/enable :raise_errors/,"#{@apptmp}/sample_project/app/app.rb")
30
+ assert_no_match_in_file(/rack_hoptoad/, "#{@apptmp}/sample_project/Gemfile")
31
31
  end
32
32
  end
33
33
 
@@ -54,14 +54,14 @@ 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 => ''
57
+ stub_request :get, template_file
58
58
  project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
59
59
  project_gen.expects(:apply).with(template_file).returns(true).once
60
60
  capture_io { project_gen.invoke_all }
61
61
  end
62
62
 
63
63
  it 'should resolve gist url properly' do
64
- FakeWeb.register_uri(:get, "https://gist.github.com/357045", :body => '<a href="/raw/357045/4356/blog_template.rb">raw</a>')
64
+ stub_request(:get, "https://gist.github.com/357045").to_return(body: '<a href="/raw/357045/4356/blog_template.rb">raw</a>')
65
65
  template_file = 'https://gist.github.com/357045'
66
66
  resolved_path = 'https://gist.github.com/raw/357045/4356/blog_template.rb'
67
67
  project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
@@ -72,7 +72,7 @@ describe "PluginGenerator" do
72
72
  it 'should resolve official template' do
73
73
  template_file = 'sampleblog'
74
74
  resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/templates/sampleblog_template.rb"
75
- FakeWeb.register_uri :get, resolved_path, :body => template_file
75
+ stub_request(:get, resolved_path).to_return(body: template_file)
76
76
  project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
77
77
  project_gen.expects(:apply).with(resolved_path).returns(true).once
78
78
  capture_io { project_gen.invoke_all }
@@ -88,7 +88,7 @@ describe "PluginGenerator" do
88
88
  it 'should resolve official plugin' do
89
89
  template_file = 'hoptoad'
90
90
  resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/plugins/hoptoad_plugin.rb"
91
- FakeWeb.register_uri :get, resolved_path, :body => template_file
91
+ stub_request(:get, resolved_path).to_return(body: template_file)
92
92
  plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
93
93
  plugin_gen.expects(:in_app_root?).returns(true).once
94
94
  plugin_gen.expects(:apply).with(resolved_path).returns(true).once
@@ -98,7 +98,7 @@ describe "PluginGenerator" do
98
98
  it 'should print a warning if template cannot be found' do
99
99
  template_file = 'hwat'
100
100
  resolved_path = "https://raw.github.com/padrino/padrino-recipes/master/plugins/hwat_plugin.rb"
101
- FakeWeb.register_uri :get, resolved_path, :status => 404
101
+ stub_request(:get, resolved_path).to_return(status: 404)
102
102
  plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
103
103
  plugin_gen.expects(:in_app_root?).returns(true).once
104
104
  # Use regex to ignore trailing whitespace in message
@@ -124,7 +124,7 @@ describe "PluginGenerator" do
124
124
  describe "with git commands" do
125
125
  it 'should generate a repository correctly' do
126
126
  skip 'Change stubs here'
127
- expects_generated_project :test => :rspec, :orm => :activerecord, :name => 'sample_git', :root => "#{@apptmp}"
127
+ expects_generated_project :test => :rspec, :orm => :activerecord, :name => 'sample_git', :root => @apptmp.to_s
128
128
  expects_git :init, :root => "#{@apptmp}/sample_git"
129
129
  expects_git :add, :arguments => '.', :root => "#{@apptmp}/sample_git"
130
130
  expects_git :commit, :arguments => 'hello', :root => "#{@apptmp}/sample_git"
@@ -135,7 +135,7 @@ describe "PluginGenerator" do
135
135
 
136
136
  describe "with rake invocations" do
137
137
  it 'should Run rake task and list tasks' do
138
- expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_rake', :root => "#{@apptmp}"
138
+ expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_rake', :root => @apptmp.to_s
139
139
  expects_rake "custom", :root => "#{@apptmp}/sample_rake"
140
140
  rake_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'rake_template.rb')
141
141
  capture_io { generate(:project, 'sample_rake', "-p=#{rake_template_path}", "-r=#{@apptmp}", '> /dev/null') }
@@ -144,7 +144,7 @@ describe "PluginGenerator" do
144
144
 
145
145
  describe "with admin commands" do
146
146
  it 'should generate correctly an admin' do
147
- expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_admin', :root => "#{@apptmp}"
147
+ expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_admin', :root => @apptmp.to_s
148
148
  expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_admin"
149
149
  expects_rake "ar:create", :root => "#{@apptmp}/sample_admin"
150
150
  expects_generated :admin, "-r=#{@apptmp}/sample_admin"
@@ -4,6 +4,7 @@ describe "ProjectGenerator" do
4
4
  def setup
5
5
  @apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}"
6
6
  `mkdir -p #{@apptmp}`
7
+ stub_static_files
7
8
  end
8
9
 
9
10
  def teardown
@@ -561,7 +562,7 @@ describe "ProjectGenerator" do
561
562
  assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
562
563
  assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
563
564
  assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
564
- assert_match_in_file(/MiniTest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
565
+ assert_match_in_file(/Minitest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
565
566
  assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
566
567
  assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
567
568
  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.15.3
4
+ version: 0.16.0.pre2
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: 2023-02-25 00:00:00.000000000 Z
14
+ date: 2024-08-06 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.15.3
22
+ version: 0.16.0.pre2
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.15.3
29
+ version: 0.16.0.pre2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -53,28 +53,28 @@ dependencies:
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.15.3
56
+ version: 0.16.0.pre2
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.15.3
63
+ version: 0.16.0.pre2
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: padrino-mailer
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.15.3
70
+ version: 0.16.0.pre2
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.15.3
77
+ version: 0.16.0.pre2
78
78
  description: Generators for easily creating and building padrino applications from
79
79
  the console
80
80
  email: padrinorb@gmail.com
@@ -219,11 +219,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ">="
222
+ - - ">"
223
223
  - !ruby/object:Gem::Version
224
- version: 1.3.6
224
+ version: 1.3.1
225
225
  requirements: []
226
- rubygems_version: 3.0.8
226
+ rubygems_version: 3.2.3
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Generators for easily creating and building padrino applications