hobbit-contrib 0.5.3 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f338c24eef1f1138d3a0156b79bcad360882e454
4
- data.tar.gz: dbbe040ee3d61f823fc4867b5baba1dc39d96d76
3
+ metadata.gz: 802654dd916d3a7a81d580faf85e0d5c1bf9eeb1
4
+ data.tar.gz: 769fec8b8f0a05d54ddb9e94481485642daa3186
5
5
  SHA512:
6
- metadata.gz: 235309c1b90a30a6609fc691eea4b3a5f73f09a51d6883539087a0c5b5b894f94563f651129f24c40f746a23cf6fa82eb2110e6cf897e9f054346688aa2fdf7c
7
- data.tar.gz: b2a5b5b597630b52aa930c81c4731c2054c518794cef2287cd8e9d4ab1b09331b422446d9808f0c1838803b37a971e4aa9336194d55dd8965d7723d2f16da0cd
6
+ metadata.gz: da0ff48b1b5d7f9682e149c6e056426f01c43ee03a2dbbb39417a7278778628e5a82c7b6b98a46050234a25c051fb2fefa2e2031526dbb3865cbfec8985cfdd9
7
+ data.tar.gz: f75f472b13d2b8bd52bcb1ccaf1650311a6fea541b97aff553ce001e8668c71e611e42016ecb926abf04ec0c169536a3ead2a4db2c4bd6b58e1d7dccf43e7b4b
@@ -1,3 +1,9 @@
1
+ # 0.6.0
2
+
3
+ * Make it work with `hobbit` 0.6.0
4
+ * Test hobbit with [oktobertest](https://github.com/patriciomacadden/oktobertest)
5
+ instead of minitest (Because reasons!).
6
+
1
7
  # 0.5.2
2
8
 
3
9
  * Add `Hobbit::Mote`
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'erubis'
24
24
  spec.add_development_dependency 'mote'
25
25
  spec.add_development_dependency 'oktobertest'
26
+ spec.add_development_dependency 'oktobertest-contrib'
26
27
  spec.add_development_dependency 'rack-test'
27
28
  spec.add_development_dependency 'rake'
28
29
  spec.add_development_dependency 'tilt'
@@ -1,5 +1,5 @@
1
1
  module Hobbit
2
2
  module Contrib
3
- VERSION = '0.5.3'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -34,15 +34,15 @@ module Hobbit
34
34
  unless @response.status == 302
35
35
  # we have to do this because `super` will override @response and @request
36
36
  prev_response = @response
37
- super
38
- @response.headers.merge! prev_response.headers
37
+ current_response = super
38
+ @response = Hobbit::Response.new current_response[2], current_response[0], current_response[1].merge!(prev_response.headers)
39
39
  filter :after unless @halted
40
40
  end
41
+ @response.finish
41
42
  end
42
- @response.finish
43
43
  end
44
44
 
45
- def halt(*res)
45
+ def halt(response)
46
46
  @halted = true
47
47
  super
48
48
  end
@@ -57,6 +57,7 @@ module Hobbit
57
57
  filter = find_filter(kind)
58
58
  if filter
59
59
  instance_eval(&filter[:block])
60
+ response.finish if kind == :after
60
61
  end
61
62
  end
62
63
 
@@ -16,7 +16,7 @@ scope Hobbit::Environment do
16
16
  scope '::environment' do
17
17
  test 'returns the current environment' do
18
18
  with_env('development') do
19
- assert app.to_app.class.environment == :development
19
+ assert_equal :development, app.to_app.class.environment
20
20
  end
21
21
  end
22
22
  end
@@ -24,7 +24,7 @@ scope Hobbit::Environment do
24
24
  scope '#environment' do
25
25
  test 'returns the current environment' do
26
26
  with_env('development') do
27
- assert app.to_app.environment == :development
27
+ assert_equal :development, app.to_app.environment
28
28
  end
29
29
  end
30
30
  end
@@ -32,71 +32,71 @@ scope Hobbit::Environment do
32
32
  scope '::development?' do
33
33
  test "returns true if ENV['RACK_ENV'] = :development" do
34
34
  with_env('development') do
35
- assert app.to_app.class.development? == true
35
+ assert app.to_app.class.development?
36
36
  end
37
37
  end
38
38
 
39
39
  test "returns false if ENV['RACK_ENV'] != :development" do
40
- assert app.to_app.class.development? == false
40
+ assert !app.to_app.class.development?
41
41
  end
42
42
  end
43
43
 
44
44
  scope '#development?' do
45
45
  test "returns true if ENV['RACK_ENV'] = :development" do
46
46
  with_env('development') do
47
- assert app.to_app.development? == true
47
+ assert app.to_app.development?
48
48
  end
49
49
  end
50
50
 
51
51
  test "returns false if ENV['RACK_ENV'] != :development" do
52
- assert app.to_app.development? == false
52
+ assert !app.to_app.development?
53
53
  end
54
54
  end
55
55
 
56
56
  scope '::production?' do
57
57
  test "returns true if ENV['RACK_ENV'] = :production" do
58
58
  with_env('production') do
59
- assert app.to_app.class.production? == true
59
+ assert app.to_app.class.production?
60
60
  end
61
61
  end
62
62
 
63
63
  test "returns false if ENV['RACK_ENV'] != :production" do
64
- assert app.to_app.class.production? == false
64
+ assert !app.to_app.class.production?
65
65
  end
66
66
  end
67
67
 
68
68
  scope '#production?' do
69
69
  test "returns true if ENV['RACK_ENV'] = :production" do
70
70
  with_env('production') do
71
- assert app.to_app.production? == true
71
+ assert app.to_app.production?
72
72
  end
73
73
  end
74
74
 
75
75
  test "returns false if ENV['RACK_ENV'] != :production" do
76
- assert app.to_app.production? == false
76
+ assert !app.to_app.production?
77
77
  end
78
78
  end
79
79
 
80
80
  scope '::test?' do
81
81
  test "returns true if ENV['RACK_ENV'] = :test" do
82
- assert app.to_app.class.test? == true
82
+ assert app.to_app.class.test?
83
83
  end
84
84
 
85
85
  test "returns false if ENV['RACK_ENV'] != :test" do
86
86
  with_env('development') do
87
- assert app.to_app.class.test? == false
87
+ assert !app.to_app.class.test?
88
88
  end
89
89
  end
90
90
  end
91
91
 
92
92
  scope '#test?' do
93
93
  test "returns true if ENV['RACK_ENV'] = :test" do
94
- assert app.to_app.test? == true
94
+ assert app.to_app.test?
95
95
  end
96
96
 
97
97
  test "returns false if ENV['RACK_ENV'] != :test" do
98
98
  with_env('development') do
99
- assert app.to_app.test? == false
99
+ assert !app.to_app.test?
100
100
  end
101
101
  end
102
102
  end
@@ -29,8 +29,8 @@ scope 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
29
29
  test 'calls the before filter' do
30
30
  get '/'
31
31
  assert last_response.ok?
32
- assert last_response.body == 'Sorry'
33
- assert last_request.env.include? 'hobbit.before'
32
+ assert_equal 'Sorry', last_response.body
33
+ assert_includes last_request.env, 'hobbit.before'
34
34
  assert !last_request.env.include?('hobbit.after')
35
35
  end
36
36
  end
@@ -63,7 +63,7 @@ scope 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
63
63
  test 'calls the before filter' do
64
64
  get '/'
65
65
  assert last_response.ok?
66
- assert last_response.body == 'Sorry'
66
+ assert_equal 'Sorry', last_response.body
67
67
  assert !last_request.env.include?('hobbit.after')
68
68
  end
69
69
  end
@@ -96,8 +96,8 @@ scope 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
96
96
  test 'calls the before filter' do
97
97
  get '/'
98
98
  assert last_response.ok?
99
- assert last_response.body == 'this is written in the body. Sorry'
100
- assert last_request.env.include? 'hobbit.before'
99
+ assert_equal 'this is written in the body. Sorry', last_response.body
100
+ assert_includes last_request.env, 'hobbit.before'
101
101
  end
102
102
  end
103
103
 
@@ -130,11 +130,11 @@ scope 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
130
130
  test 'does not work as expected' do
131
131
  get '/'
132
132
  assert last_response.ok?
133
- assert last_response.body == 'Sorry'
134
- assert last_request.env.include? 'hobbit.before'
133
+ assert_equal 'Sorry', last_response.body
134
+ assert_includes last_request.env, 'hobbit.before'
135
135
  # this is contrary to a previous test, which is not the desired workflow
136
136
  # or is it?
137
- assert last_request.env.include? 'hobbit.after'
137
+ assert_includes last_request.env, 'hobbit.after'
138
138
  end
139
139
  end
140
140
  end
@@ -57,14 +57,14 @@ scope Hobbit::ErrorHandling do
57
57
  error StandardError, &p
58
58
  end
59
59
 
60
- assert app.to_app.class.errors.include? StandardError
61
- assert app.to_app.class.errors[StandardError].call == p.call
60
+ assert_includes app.to_app.class.errors, StandardError
61
+ assert_equal p.call, app.to_app.class.errors[StandardError].call
62
62
  end
63
63
  end
64
64
 
65
65
  scope '::errors' do
66
66
  test 'returns a Hash' do
67
- assert app.to_app.class.errors.kind_of? Hash
67
+ assert_kind_of Hash, app.to_app.class.errors
68
68
  end
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ scope Hobbit::ErrorHandling do
72
72
  test 'works as expected' do
73
73
  get '/'
74
74
  assert last_response.ok?
75
- assert last_response.body == 'hello'
75
+ assert_equal 'hello', last_response.body
76
76
  end
77
77
  end
78
78
 
@@ -94,25 +94,25 @@ scope Hobbit::ErrorHandling do
94
94
  test 'calls the block set in error' do
95
95
  get '/raises'
96
96
  assert last_response.ok?
97
- assert last_response.body == 'StandardError'
97
+ assert_equal 'StandardError', last_response.body
98
98
  end
99
99
 
100
100
  test 'allows to define more than one exception' do
101
101
  get '/other_raises'
102
102
  assert last_response.ok?
103
- assert last_response.body == 'Not Found'
103
+ assert_equal 'Not Found', last_response.body
104
104
  end
105
105
 
106
106
  test 'allows to define a general exception class to catch' do
107
107
  get '/same_other_raises'
108
108
  assert last_response.ok?
109
- assert last_response.body == 'Not Found'
109
+ assert_equal 'Not Found', last_response.body
110
110
  end
111
111
 
112
112
  test 'sets the returned value of the error block as the body' do
113
113
  get '/other_raises'
114
114
  assert last_response.ok?
115
- assert last_response.body == 'Not Found'
115
+ assert_equal 'Not Found', last_response.body
116
116
  assert last_response.body != 'not this'
117
117
  end
118
118
 
@@ -123,14 +123,14 @@ scope Hobbit::ErrorHandling do
123
123
 
124
124
  get '/raises'
125
125
  assert last_response.ok?
126
- assert last_response.body == 'other handler!'
126
+ assert_equal 'other handler!', last_response.body
127
127
  end
128
128
 
129
129
  test 'uses the response object' do
130
130
  get '/must_use_response'
131
131
  assert last_response.redirection?
132
132
  follow_redirect!
133
- assert last_response.body == 'hello'
133
+ assert_equal 'hello', last_response.body
134
134
  end
135
135
  end
136
136
  end
@@ -205,7 +205,8 @@ EOS
205
205
  include Hobbit::Filter
206
206
 
207
207
  before do
208
- halt 401
208
+ response.status = 401
209
+ halt response.finish
209
210
  end
210
211
 
211
212
  get '/' do
@@ -216,7 +217,7 @@ EOS
216
217
 
217
218
  test 'does not execute the route' do
218
219
  get '/'
219
- assert last_response.status == 401
220
+ assert_status 401
220
221
  assert last_response.body.empty?
221
222
  end
222
223
  end
@@ -235,17 +236,19 @@ EOS
235
236
  end
236
237
 
237
238
  get '/' do
238
- halt 401, 'Unauthenticated'
239
+ response.status = 401
240
+ response.write 'Unauthenticated'
241
+ halt response.finish
239
242
  end
240
243
  end
241
244
  end
242
245
 
243
246
  test 'does not execute the after filter' do
244
247
  get '/'
245
- assert last_response.status == 401
246
- assert last_response.headers.include? 'Content-Type'
247
- assert last_response.headers['Content-Type'] == 'text/plain'
248
- assert last_response.body == 'Unauthenticated'
248
+ assert_status 401
249
+ assert_includes last_response.headers, 'Content-Type'
250
+ assert_header 'Content-Type', 'text/plain'
251
+ assert_equal 'Unauthenticated', last_response.body
249
252
  end
250
253
  end
251
254
 
@@ -255,7 +258,8 @@ EOS
255
258
  include Hobbit::Filter
256
259
 
257
260
  after do
258
- halt 401
261
+ response.status = 401
262
+ halt response.finish
259
263
  end
260
264
 
261
265
  get '/' do
@@ -266,8 +270,8 @@ EOS
266
270
 
267
271
  test 'does not execute the route' do
268
272
  get '/'
269
- assert last_response.status == 401
270
- assert last_response.body == 'hello world'
273
+ assert_status 401
274
+ assert_equal 'hello world', last_response.body
271
275
  end
272
276
  end
273
277
  end
@@ -6,6 +6,7 @@ CodeClimate::TestReporter.start
6
6
  ENV['RACK_ENV'] ||= 'test'
7
7
 
8
8
  require 'oktobertest'
9
+ require 'oktobertest/contrib'
9
10
  require 'rack'
10
11
  require 'rack/test'
11
12
 
@@ -22,19 +22,19 @@ scope Hobbit::Mote do
22
22
 
23
23
  scope '#default_layout' do
24
24
  test 'defaults to application.mote' do
25
- assert app.to_app.default_layout == "#{app.to_app.layouts_path}/application.mote"
25
+ assert_equal "#{app.to_app.layouts_path}/application.mote", app.to_app.default_layout
26
26
  end
27
27
  end
28
28
 
29
29
  scope '#find_template' do
30
30
  test 'returns a template path' do
31
- assert app.to_app.find_template('index') == "#{app.to_app.views_path}/index.mote"
31
+ assert_equal "#{app.to_app.views_path}/index.mote", app.to_app.find_template('index')
32
32
  end
33
33
  end
34
34
 
35
35
  scope '#layouts_path' do
36
36
  test 'returns the path to the layouts directory' do
37
- assert app.to_app.layouts_path == "#{app.to_app.views_path}/layouts"
37
+ assert_equal "#{app.to_app.views_path}/layouts", app.to_app.layouts_path
38
38
  end
39
39
  end
40
40
 
@@ -72,7 +72,7 @@ scope Hobbit::Mote do
72
72
 
73
73
  scope '#views_path' do
74
74
  test 'returns the path to the views directory' do
75
- assert app.to_app.views_path == File.expand_path('../fixtures/mote/views', __FILE__)
75
+ assert_equal File.expand_path('../fixtures/mote/views', __FILE__), app.to_app.views_path
76
76
  end
77
77
 
78
78
  test 'defaults to "views"' do
@@ -80,7 +80,7 @@ scope Hobbit::Mote do
80
80
  include Hobbit::Mote
81
81
  end
82
82
 
83
- assert app.to_app.views_path == 'views'
83
+ assert_equal 'views', app.to_app.views_path
84
84
  end
85
85
  end
86
86
  end
@@ -24,19 +24,19 @@ scope Hobbit::Render do
24
24
 
25
25
  scope '#default_layout' do
26
26
  test 'defaults to application.erb' do
27
- assert app.to_app.default_layout == "#{app.to_app.layouts_path}/application.erb"
27
+ assert_equal "#{app.to_app.layouts_path}/application.erb", app.to_app.default_layout
28
28
  end
29
29
  end
30
30
 
31
31
  scope '#find_template' do
32
32
  test 'returns a template path' do
33
- assert app.to_app.find_template('index') == "#{app.to_app.views_path}/index.#{app.to_app.template_engine}"
33
+ assert_equal "#{app.to_app.views_path}/index.#{app.to_app.template_engine}", app.to_app.find_template('index')
34
34
  end
35
35
  end
36
36
 
37
37
  scope '#layouts_path' do
38
38
  test 'returns the path to the layouts directory' do
39
- assert app.to_app.layouts_path == "#{app.to_app.views_path}/layouts"
39
+ assert_equal "#{app.to_app.views_path}/layouts", app.to_app.layouts_path
40
40
  end
41
41
  end
42
42
 
@@ -74,13 +74,13 @@ scope Hobbit::Render do
74
74
 
75
75
  scope '#template_engine' do
76
76
  test 'defaults to erb' do
77
- assert app.to_app.template_engine == 'erb'
77
+ assert_equal 'erb', app.to_app.template_engine
78
78
  end
79
79
  end
80
80
 
81
81
  scope '#views_path' do
82
82
  test 'returns the path to the views directory' do
83
- assert app.to_app.views_path == File.expand_path('../fixtures/render/views', __FILE__)
83
+ assert_equal File.expand_path('../fixtures/render/views', __FILE__), app.to_app.views_path
84
84
  end
85
85
 
86
86
  test 'defaults to "views"' do
@@ -88,7 +88,7 @@ scope Hobbit::Render do
88
88
  include Hobbit::Render
89
89
  end
90
90
 
91
- assert app.to_app.views_path == 'views'
91
+ assert_equal 'views', app.to_app.views_path
92
92
  end
93
93
  end
94
94
  end
@@ -20,11 +20,11 @@ scope Hobbit::Session do
20
20
  test 'returns a session object' do
21
21
  get '/'
22
22
  assert last_response.ok?
23
- assert last_response.body == 'hobbit'
23
+ assert_equal 'hobbit', last_response.body
24
24
 
25
25
  get '/name'
26
26
  assert last_response.ok?
27
- assert last_response.body == 'hobbit'
27
+ assert_equal 'hobbit', last_response.body
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobbit-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Mac Adden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: oktobertest-contrib
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rack-test
85
99
  requirement: !ruby/object:Gem::Requirement