hobbit-contrib 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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