padrino-core 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +191 -2
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/bin/padrino +2 -1
- data/lib/padrino-core.rb +2 -3
- data/lib/padrino-core/application.rb +42 -19
- data/lib/padrino-core/caller.rb +35 -0
- data/lib/padrino-core/loader.rb +44 -20
- data/lib/padrino-core/mounter.rb +34 -28
- data/lib/padrino-core/support_lite.rb +24 -9
- data/lib/padrino-core/support_lite/as_support.rb +21 -0
- data/lib/padrino-core/support_lite/extlib_support.rb +96 -0
- data/lib/padrino-core/tasks.rb +3 -6
- data/lib/padrino-core/tasks/test.rb +5 -4
- data/lib/padrino-core/version.rb +1 -1
- data/padrino-core.gemspec +14 -13
- data/test/fixtures/{simple_app → apps}/.components +0 -0
- data/test/fixtures/{simple_app → apps}/.gitignore +0 -0
- data/test/fixtures/apps/app.rb +15 -0
- data/test/fixtures/apps/multi.rb +27 -0
- data/test/helper.rb +29 -11
- data/test/test_padrino_core.rb +3 -13
- data/test/test_padrino_mounter.rb +50 -19
- metadata +20 -10
- data/test/active_support_helpers.rb +0 -7
- data/test/fixtures/simple_app/Gemfile +0 -9
- data/test/fixtures/simple_app/app.rb +0 -41
- data/test/test_padrino_application.rb +0 -45
data/test/helper.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
+
ENV['PADRINO_ENV'] = 'test'
|
2
|
+
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
|
1
7
|
require 'rubygems'
|
8
|
+
require 'padrino-core'
|
2
9
|
require 'test/unit'
|
3
10
|
require 'shoulda'
|
4
11
|
require 'mocha'
|
5
12
|
require 'rack/test'
|
6
13
|
require 'webrat'
|
7
14
|
|
8
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
-
|
11
|
-
require 'active_support_helpers'
|
12
|
-
|
13
15
|
class Test::Unit::TestCase
|
14
16
|
include Rack::Test::Methods
|
15
17
|
include Webrat::Methods
|
@@ -19,12 +21,34 @@ class Test::Unit::TestCase
|
|
19
21
|
config.mode = :rack
|
20
22
|
end
|
21
23
|
|
24
|
+
# Test App
|
25
|
+
class PadrinoTestApp < Padrino::Application; end
|
26
|
+
|
27
|
+
# Sets up a Sinatra::Base subclass defined with the block
|
28
|
+
# given. Used in setup or individual spec methods to establish
|
29
|
+
# the application.
|
30
|
+
def mock_app(base=PadrinoTestApp, &block)
|
31
|
+
@app = Sinatra.new(base, &block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def app
|
35
|
+
Rack::Lint.new(@app)
|
36
|
+
end
|
37
|
+
|
22
38
|
def stop_time_for_test
|
23
39
|
time = Time.now
|
24
40
|
Time.stubs(:now).returns(time)
|
25
41
|
return time
|
26
42
|
end
|
27
43
|
|
44
|
+
# Asserts that a file matches the pattern
|
45
|
+
def assert_match_in_file(pattern, file)
|
46
|
+
assert File.exist?(file), "File '#{file}' does not exist!"
|
47
|
+
assert_match pattern, File.read(file)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Object
|
28
52
|
# Silences the output by redirecting to stringIO
|
29
53
|
# silence_logger { ...commands... } => "...output..."
|
30
54
|
def silence_logger(&block)
|
@@ -34,12 +58,6 @@ class Test::Unit::TestCase
|
|
34
58
|
$stdout = orig_stdout
|
35
59
|
log_buffer.rewind && log_buffer.read
|
36
60
|
end
|
37
|
-
|
38
|
-
# Asserts that a file matches the pattern
|
39
|
-
def assert_match_in_file(pattern, file)
|
40
|
-
assert File.exist?(file), "File '#{file}' does not exist!"
|
41
|
-
assert_match pattern, File.read(file)
|
42
|
-
end
|
43
61
|
end
|
44
62
|
|
45
63
|
module Webrat
|
data/test/test_padrino_core.rb
CHANGED
@@ -1,30 +1,20 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
|
-
PADRINO_ENV = RACK_ENV = 'test' unless defined?(PADRINO_ENV)
|
4
|
-
require File.dirname(__FILE__) + '/fixtures/simple_app/app'
|
5
|
-
require 'padrino-core'
|
6
|
-
|
7
3
|
class TestPadrinoCore < Test::Unit::TestCase
|
8
4
|
|
9
5
|
context 'for core functionality' do
|
10
6
|
|
11
|
-
should 'check global methods' do
|
7
|
+
should 'check some global methods' do
|
12
8
|
assert_respond_to Padrino, :env
|
13
9
|
assert_respond_to Padrino, :root
|
14
10
|
assert_respond_to Padrino, :load!
|
15
11
|
assert_respond_to Padrino, :reload!
|
16
|
-
assert_respond_to Padrino, :load_dependencies
|
17
|
-
assert_respond_to Padrino, :load_required_gems
|
18
|
-
assert_respond_to Padrino, :mounted_root
|
19
|
-
assert_respond_to Padrino, :mounted_apps
|
20
|
-
assert_respond_to Padrino, :mount
|
21
|
-
assert_respond_to Padrino, :mount_core
|
22
12
|
assert_respond_to Padrino, :version
|
23
13
|
end
|
24
14
|
|
25
15
|
should 'validate global helpers' do
|
26
16
|
assert_equal "test", Padrino.env
|
27
|
-
assert_match
|
17
|
+
assert_match /\/test/, Padrino.root
|
28
18
|
end
|
29
19
|
|
30
20
|
should 'raise application error if I instantiate a new padrino application without mounted apps' do
|
@@ -34,4 +24,4 @@ class TestPadrinoCore < Test::Unit::TestCase
|
|
34
24
|
end
|
35
25
|
end
|
36
26
|
end
|
37
|
-
end
|
27
|
+
end
|
@@ -1,19 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
|
-
PADRINO_ENV = RACK_ENV = 'test' unless defined?(PADRINO_ENV)
|
4
|
-
require File.dirname(__FILE__) + '/fixtures/simple_app/app'
|
5
|
-
require 'padrino-core'
|
6
|
-
|
7
3
|
class TestPadrinoMounter < Test::Unit::TestCase
|
8
4
|
|
9
|
-
def app
|
10
|
-
Padrino.application.tap { }
|
11
|
-
end
|
12
|
-
|
13
5
|
def setup
|
14
6
|
Padrino.mounted_apps.clear
|
15
|
-
Padrino.mount("core_1_demo", :app_file => "#{Padrino.root("app.rb")}").to("/core_1_demo")
|
16
|
-
Padrino.mount("core_2_demo", :app_file => "#{Padrino.root("app.rb")}").to("/core_2_demo")
|
17
7
|
end
|
18
8
|
|
19
9
|
context 'for mounter functionality' do
|
@@ -26,26 +16,67 @@ class TestPadrinoMounter < Test::Unit::TestCase
|
|
26
16
|
assert_respond_to mounter, :to
|
27
17
|
assert_respond_to mounter, :map_onto
|
28
18
|
assert_equal "test", mounter.name
|
19
|
+
assert_equal "Test", mounter.app_class
|
29
20
|
assert_equal "/path/to/test.rb", mounter.app_file
|
30
21
|
assert_equal "/test", mounter.uri_root
|
31
22
|
assert_nil mounter.app_root
|
32
23
|
end
|
33
24
|
|
34
|
-
should '
|
35
|
-
|
25
|
+
should 'check locate_app_file with __FILE__' do
|
26
|
+
mounter = Padrino::Mounter.new("test")
|
27
|
+
mounter.to("/test")
|
28
|
+
assert_equal "test", mounter.name
|
29
|
+
assert_equal "Test", mounter.app_class
|
30
|
+
assert_equal __FILE__, mounter.app_file
|
31
|
+
assert_equal "/test", mounter.uri_root
|
32
|
+
assert_nil mounter.app_root
|
36
33
|
end
|
37
34
|
|
38
|
-
should 'mount
|
39
|
-
Padrino
|
40
|
-
|
35
|
+
should 'mount an app' do
|
36
|
+
class AnApp < Padrino::Application; end
|
37
|
+
|
38
|
+
Padrino.mount_core("an_app")
|
41
39
|
assert_equal ["core"], Padrino.mounted_apps.collect(&:name)
|
42
40
|
end
|
41
|
+
|
42
|
+
should 'mount a core' do
|
43
|
+
mounter = Padrino.mount_core("test")
|
44
|
+
assert_equal "core", mounter.name
|
45
|
+
assert_equal "Test", mounter.app_class
|
46
|
+
assert_equal Padrino.root('app/app.rb'), mounter.app_file
|
47
|
+
assert_equal "/", mounter.uri_root
|
48
|
+
assert_equal Padrino.root, mounter.app_root
|
49
|
+
end
|
50
|
+
|
51
|
+
should 'mount multiple apps' do
|
52
|
+
class OneApp < Padrino::Application; end
|
53
|
+
class TwoApp < Padrino::Application; end
|
54
|
+
|
55
|
+
Padrino.mount("one_app").to("/one_app")
|
56
|
+
Padrino.mount("two_app").to("/two_app")
|
57
|
+
|
58
|
+
assert_equal ["one_app", "two_app"], Padrino.mounted_apps.collect(&:name)
|
59
|
+
end
|
60
|
+
|
61
|
+
should 'change mounted_root' do
|
62
|
+
Padrino.mounted_root = "fixtures"
|
63
|
+
assert_equal Padrino.root("fixtures", "test", "app.rb"), Padrino.mounted_root("test", "app.rb")
|
64
|
+
Padrino.mounted_root = "apps"
|
65
|
+
assert_equal Padrino.root("apps", "test", "app.rb"), Padrino.mounted_root("test", "app.rb")
|
66
|
+
Padrino.mounted_root = nil
|
67
|
+
assert_equal Padrino.root("apps", "test", "app.rb"), Padrino.mounted_root("test", "app.rb")
|
68
|
+
end
|
43
69
|
|
44
70
|
should 'correctly instantiate a new padrino application' do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
71
|
+
mock_app do
|
72
|
+
get("/demo_1"){ "Im Demo 1" }
|
73
|
+
get("/demo_2"){ "Im Demo 2" }
|
74
|
+
end
|
75
|
+
|
76
|
+
get '/demo_1'
|
77
|
+
assert_contain "Im Demo 1"
|
78
|
+
visit '/demo_2'
|
79
|
+
assert_contain "Im Demo 2"
|
49
80
|
end
|
50
81
|
end
|
51
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-11-
|
15
|
+
date: 2009-11-23 00:00:00 -08:00
|
16
16
|
default_executable: padrino
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -45,6 +45,16 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 2.2.1
|
47
47
|
version:
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
type: :runtime
|
51
|
+
version_requirement:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.5.0
|
57
|
+
version:
|
48
58
|
- !ruby/object:Gem::Dependency
|
49
59
|
name: shoulda
|
50
60
|
type: :development
|
@@ -92,7 +102,6 @@ executables:
|
|
92
102
|
extensions: []
|
93
103
|
|
94
104
|
extra_rdoc_files:
|
95
|
-
- LICENSE
|
96
105
|
- README.rdoc
|
97
106
|
files:
|
98
107
|
- .document
|
@@ -104,11 +113,14 @@ files:
|
|
104
113
|
- bin/padrino
|
105
114
|
- lib/padrino-core.rb
|
106
115
|
- lib/padrino-core/application.rb
|
116
|
+
- lib/padrino-core/caller.rb
|
107
117
|
- lib/padrino-core/loader.rb
|
108
118
|
- lib/padrino-core/mounter.rb
|
109
119
|
- lib/padrino-core/reloader.rb
|
110
120
|
- lib/padrino-core/stat.rb
|
111
121
|
- lib/padrino-core/support_lite.rb
|
122
|
+
- lib/padrino-core/support_lite/as_support.rb
|
123
|
+
- lib/padrino-core/support_lite/extlib_support.rb
|
112
124
|
- lib/padrino-core/tasks.rb
|
113
125
|
- lib/padrino-core/tasks/adapter.rb
|
114
126
|
- lib/padrino-core/tasks/console.rb
|
@@ -116,17 +128,15 @@ files:
|
|
116
128
|
- lib/padrino-core/tasks/test.rb
|
117
129
|
- lib/padrino-core/version.rb
|
118
130
|
- padrino-core.gemspec
|
119
|
-
- test/
|
120
|
-
- test/fixtures/
|
121
|
-
- test/fixtures/
|
122
|
-
- test/fixtures/
|
123
|
-
- test/fixtures/simple_app/app.rb
|
131
|
+
- test/fixtures/apps/.components
|
132
|
+
- test/fixtures/apps/.gitignore
|
133
|
+
- test/fixtures/apps/app.rb
|
134
|
+
- test/fixtures/apps/multi.rb
|
124
135
|
- test/helper.rb
|
125
|
-
- test/test_padrino_application.rb
|
126
136
|
- test/test_padrino_core.rb
|
127
137
|
- test/test_padrino_mounter.rb
|
128
138
|
has_rdoc: true
|
129
|
-
homepage: http://github.com/padrino/padrino-core
|
139
|
+
homepage: http://github.com/padrino/padrino-framework/tree/master/padrino-core
|
130
140
|
licenses: []
|
131
141
|
|
132
142
|
post_install_message:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'haml'
|
4
|
-
require 'padrino-core'
|
5
|
-
|
6
|
-
class Core1Demo < Padrino::Application
|
7
|
-
set :app_file, File.dirname(__FILE__) + "/app.rb"
|
8
|
-
disable :padrino_routing
|
9
|
-
disable :padrino_mailer
|
10
|
-
disable :padrino_helpers
|
11
|
-
|
12
|
-
get "" do
|
13
|
-
"Im Core1Demo"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Core2Demo < Padrino::Application
|
18
|
-
set :app_file, File.dirname(__FILE__) + "/app.rb"
|
19
|
-
disable :padrino_routing
|
20
|
-
disable :padrino_mailer
|
21
|
-
disable :padrino_helpers
|
22
|
-
|
23
|
-
get "" do
|
24
|
-
"Im Core2Demo"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Core3Demo < Padrino::Application
|
29
|
-
enable :padrino_routing
|
30
|
-
|
31
|
-
# TODO enabling this causes an error (because routing not loaded yet)
|
32
|
-
# get :test, :map => '/test' do
|
33
|
-
# "This raises a large error"
|
34
|
-
# end
|
35
|
-
end
|
36
|
-
|
37
|
-
orig_stdout = $stdout
|
38
|
-
$stdout = log_buffer = StringIO.new
|
39
|
-
Padrino.load!
|
40
|
-
$stdout = orig_stdout
|
41
|
-
log_buffer.rewind && log_buffer.read
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
PADRINO_ENV = RACK_ENV = 'test' unless defined?(PADRINO_ENV)
|
4
|
-
require File.dirname(__FILE__) + '/fixtures/simple_app/app'
|
5
|
-
require 'padrino-core'
|
6
|
-
|
7
|
-
class TestPadrinoApplication < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def app
|
10
|
-
Padrino.application.tap { }
|
11
|
-
end
|
12
|
-
|
13
|
-
def setup
|
14
|
-
Padrino.mounted_apps.clear
|
15
|
-
Padrino.mount("core_1_demo", :app_file => "#{Padrino.root("app.rb")}").to("/core_1_demo")
|
16
|
-
Padrino.mount("core_2_demo", :app_file => "#{Padrino.root("app.rb")}").to("/core_2_demo")
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'for application functionality' do
|
20
|
-
|
21
|
-
should 'check methods' do
|
22
|
-
assert_respond_to Padrino::Application, :new
|
23
|
-
assert_respond_to Padrino::Application, :controllers
|
24
|
-
assert_respond_to Padrino::Application, :setup_application!
|
25
|
-
assert_respond_to Padrino::Application, :default_configuration!
|
26
|
-
assert_respond_to Padrino::Application, :calculate_paths
|
27
|
-
assert_respond_to Padrino::Application, :register_initializers
|
28
|
-
assert_respond_to Padrino::Application, :register_framework_extensions
|
29
|
-
assert_respond_to Padrino::Application, :require_load_paths
|
30
|
-
assert_respond_to Padrino::Application, :setup_logger
|
31
|
-
assert_respond_to Padrino::Application, :load_paths
|
32
|
-
assert_respond_to Padrino::Application, :find_view_path
|
33
|
-
end
|
34
|
-
|
35
|
-
should 'have controllers' do
|
36
|
-
Core1Demo.controllers do
|
37
|
-
get("/controller") { "Im a controller" }
|
38
|
-
end
|
39
|
-
visit "/core_1_demo/controller"
|
40
|
-
assert_contain "Im a controller"
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|