regal 0.1.0 → 0.2.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.
@@ -3,30 +3,15 @@ require 'spec_helper'
3
3
  module Regal
4
4
  describe Request do
5
5
  let :request do
6
- described_class.new(env)
6
+ described_class.new(env, path_captures)
7
7
  end
8
8
 
9
9
  let :env do
10
10
  {}
11
11
  end
12
12
 
13
- describe '#request_method' do
14
- it 'returns the request method' do
15
- env['REQUEST_METHOD'] = 'OPTIONS'
16
- expect(request.request_method).to eq('OPTIONS')
17
- end
18
- end
19
-
20
- describe '#head?' do
21
- it 'returns true when the request method is HEAD' do
22
- env['REQUEST_METHOD'] = 'HEAD'
23
- expect(request.head?).to be_truthy
24
- end
25
-
26
- it 'returns false when the request method is not HEAD' do
27
- env['REQUEST_METHOD'] = 'POST'
28
- expect(request.head?).to be_falsy
29
- end
13
+ let :path_captures do
14
+ {}
30
15
  end
31
16
 
32
17
  describe '#env' do
@@ -43,7 +28,7 @@ module Regal
43
28
  end
44
29
 
45
30
  it 'includes path captures' do
46
- env[Route::PATH_CAPTURES_KEY] = {:echo => 'polo'}
31
+ path_captures[:echo] = 'polo'
47
32
  expect(request.parameters).to include(:echo => 'polo')
48
33
  end
49
34
 
@@ -88,6 +73,14 @@ module Regal
88
73
  request.attributes[:foo] = 'bar'
89
74
  expect(request.attributes).to include(:foo => 'bar')
90
75
  end
76
+
77
+ it 'returns a copy of the hash passed to #initialize' do
78
+ attributes = {:foo => 'bar'}
79
+ request = described_class.new(env, path_captures, attributes)
80
+ expect(request.attributes).to include(:foo => 'bar')
81
+ request.attributes[:bar] = 'foo'
82
+ expect(attributes).not_to have_key(:bar)
83
+ end
91
84
  end
92
85
  end
93
86
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,9 @@
1
1
  require 'rack/test'
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_group 'Implementation', 'lib'
6
+ add_group 'Unit tests', 'spec/regal'
7
+ end
8
+
2
9
  require 'regal'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".yardopts"
35
+ - README.md
35
36
  - lib/regal.rb
36
37
  - lib/regal/app.rb
37
38
  - lib/regal/request.rb
@@ -70,3 +71,4 @@ test_files:
70
71
  - spec/regal/request_spec.rb
71
72
  - spec/regal/response_spec.rb
72
73
  - spec/spec_helper.rb
74
+ has_rdoc: