hobbit-contrib 0.5.2 → 0.5.3
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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/Rakefile +3 -3
- data/hobbit-contrib.gemspec +4 -4
- data/lib/hobbit/contrib.rb +8 -2
- data/lib/hobbit/contrib/version.rb +1 -1
- data/lib/hobbit/mote.rb +1 -3
- data/test/environment_test.rb +103 -0
- data/{spec/error_handling_and_filter_spec.rb → test/error_handling_and_filter_test.rb} +29 -32
- data/test/error_handling_test.rb +136 -0
- data/test/filter_test.rb +273 -0
- data/{spec → test}/fixtures/mote/views/_partial.mote +0 -0
- data/{spec → test}/fixtures/mote/views/hello.mote +0 -0
- data/{spec → test}/fixtures/mote/views/index.mote +0 -0
- data/{spec → test}/fixtures/mote/views/layouts/application.mote +0 -0
- data/{spec → test}/fixtures/render/views/_partial.erb +0 -0
- data/{spec → test}/fixtures/render/views/hello.erb +0 -0
- data/{spec → test}/fixtures/render/views/index.erb +0 -0
- data/{spec → test}/fixtures/render/views/layouts/application.erb +0 -0
- data/test/helper.rb +27 -0
- data/test/mote_test.rb +86 -0
- data/test/render_test.rb +94 -0
- data/test/session_test.rb +30 -0
- metadata +44 -44
- data/spec/environment_spec.rb +0 -105
- data/spec/error_handling_spec.rb +0 -136
- data/spec/filter_spec.rb +0 -274
- data/spec/minitest_helper.rb +0 -25
- data/spec/mote_spec.rb +0 -89
- data/spec/render_spec.rb +0 -96
- data/spec/session_spec.rb +0 -33
data/spec/render_spec.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
require 'tilt/erubis'
|
3
|
-
|
4
|
-
describe Hobbit::Render do
|
5
|
-
include Hobbit::Contrib::Mock
|
6
|
-
include Rack::Test::Methods
|
7
|
-
|
8
|
-
def app
|
9
|
-
mock_app do
|
10
|
-
include Hobbit::Render
|
11
|
-
|
12
|
-
def views_path
|
13
|
-
File.expand_path '../fixtures/render/views/', __FILE__
|
14
|
-
end
|
15
|
-
|
16
|
-
def name
|
17
|
-
'Hobbit'
|
18
|
-
end
|
19
|
-
|
20
|
-
get('/') { render 'index' }
|
21
|
-
get('/partial') { partial 'partial' }
|
22
|
-
get('/using-context') { render 'hello' }
|
23
|
-
get('/without-layout') { render '_partial', {}, layout: false }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#default_layout' do
|
28
|
-
it 'defaults to application.erb' do
|
29
|
-
app.to_app.default_layout.must_equal "#{app.to_app.layouts_path}/application.erb"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#find_template' do
|
34
|
-
it 'must return a template path' do
|
35
|
-
app.to_app.find_template('index').must_equal "#{app.to_app.views_path}/index.#{app.to_app.template_engine}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#layouts_path' do
|
40
|
-
it 'must return the path to the layouts directory' do
|
41
|
-
app.to_app.layouts_path.must_equal "#{app.to_app.views_path}/layouts"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#partial' do
|
46
|
-
it 'must render a template without a layout' do
|
47
|
-
get '/partial'
|
48
|
-
last_response.must_be :ok?
|
49
|
-
last_response.body.wont_match /From application.erb/
|
50
|
-
last_response.body.must_match /Hello World!/
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#render' do
|
55
|
-
it 'must render a template (using a layout)' do
|
56
|
-
get '/'
|
57
|
-
last_response.must_be :ok?
|
58
|
-
last_response.body.must_match /From application.erb/
|
59
|
-
last_response.body.must_match /Hello World!/
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'must render a template (not using a layout)' do
|
63
|
-
get '/without-layout'
|
64
|
-
last_response.must_be :ok?
|
65
|
-
last_response.body.wont_match /From application.erb/
|
66
|
-
last_response.body.must_match /Hello World!/
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'must render a template using the app as context' do
|
70
|
-
get '/using-context'
|
71
|
-
last_response.must_be :ok?
|
72
|
-
last_response.body.must_match /From application.erb/
|
73
|
-
last_response.body.must_match /Hello Hobbit!/
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#template_engine' do
|
78
|
-
it 'defaults to erb' do
|
79
|
-
app.to_app.template_engine.must_equal 'erb'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#views_path' do
|
84
|
-
it 'must return the path to the views directory' do
|
85
|
-
app.to_app.views_path.must_equal File.expand_path('../fixtures/render/views', __FILE__)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'defaults to "views"' do
|
89
|
-
a = mock_app do
|
90
|
-
include Hobbit::Render
|
91
|
-
end
|
92
|
-
|
93
|
-
a.to_app.views_path.must_equal 'views'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
data/spec/session_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
|
3
|
-
describe Hobbit::Session do
|
4
|
-
include Hobbit::Contrib::Mock
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def app
|
8
|
-
mock_app do
|
9
|
-
include Hobbit::Session
|
10
|
-
use Rack::Session::Cookie, secret: SecureRandom.hex(64)
|
11
|
-
|
12
|
-
get '/' do
|
13
|
-
session[:name] = 'hobbit'
|
14
|
-
end
|
15
|
-
|
16
|
-
get '/name' do
|
17
|
-
session[:name]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#session' do
|
23
|
-
it 'must return a session object' do
|
24
|
-
get '/'
|
25
|
-
last_response.must_be :ok?
|
26
|
-
last_response.body.must_equal 'hobbit'
|
27
|
-
|
28
|
-
get '/name'
|
29
|
-
last_response.must_be :ok?
|
30
|
-
last_response.body.must_equal 'hobbit'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|