acfs 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +16 -19
  4. data/acfs.gemspec +2 -0
  5. data/lib/acfs/adapter/typhoeus.rb +6 -4
  6. data/lib/acfs/configuration.rb +13 -3
  7. data/lib/acfs/errors.rb +1 -1
  8. data/lib/acfs/global.rb +2 -2
  9. data/lib/acfs/location.rb +1 -1
  10. data/lib/acfs/operation.rb +1 -1
  11. data/lib/acfs/request/callbacks.rb +1 -1
  12. data/lib/acfs/request.rb +1 -1
  13. data/lib/acfs/resource/attributes/uuid.rb +1 -1
  14. data/lib/acfs/resource/locatable.rb +2 -2
  15. data/lib/acfs/resource/query_methods.rb +2 -2
  16. data/lib/acfs/runner.rb +15 -15
  17. data/lib/acfs/stub.rb +34 -29
  18. data/lib/acfs/version.rb +2 -2
  19. data/spec/acfs/adapter/typhoeus_spec.rb +1 -1
  20. data/spec/acfs/collection_spec.rb +66 -41
  21. data/spec/acfs/configuration_spec.rb +22 -12
  22. data/spec/acfs/global_spec.rb +9 -7
  23. data/spec/acfs/middleware/json_spec.rb +8 -8
  24. data/spec/acfs/middleware/{msgpack_spec.rb → message_pack_spec.rb} +6 -6
  25. data/spec/acfs/operation_spec.rb +3 -2
  26. data/spec/acfs/request/callbacks_spec.rb +19 -10
  27. data/spec/acfs/request_spec.rb +15 -19
  28. data/spec/acfs/resource/attributes/boolean_spec.rb +32 -32
  29. data/spec/acfs/resource/attributes/date_time_spec.rb +16 -8
  30. data/spec/acfs/resource/attributes/dict_spec.rb +15 -9
  31. data/spec/acfs/resource/attributes/float_spec.rb +20 -10
  32. data/spec/acfs/resource/attributes/integer_spec.rb +10 -5
  33. data/spec/acfs/resource/attributes/list_spec.rb +13 -8
  34. data/spec/acfs/resource/attributes/uuid_spec.rb +12 -6
  35. data/spec/acfs/resource/attributes_spec.rb +33 -32
  36. data/spec/acfs/resource/dirty_spec.rb +6 -3
  37. data/spec/acfs/resource/initialization_spec.rb +4 -5
  38. data/spec/acfs/resource/loadable_spec.rb +3 -1
  39. data/spec/acfs/resource/locatable_spec.rb +24 -18
  40. data/spec/acfs/resource/{persistance_spec.rb → persistence_spec.rb} +114 -82
  41. data/spec/acfs/resource/query_methods_spec.rb +143 -110
  42. data/spec/acfs/resource/validation_spec.rb +34 -27
  43. data/spec/acfs/response/formats_spec.rb +8 -8
  44. data/spec/acfs/response/status_spec.rb +16 -9
  45. data/spec/acfs/runner_spec.rb +10 -8
  46. data/spec/acfs/service/middleware_spec.rb +3 -3
  47. data/spec/acfs/service_spec.rb +5 -4
  48. data/spec/acfs/singleton_resource_spec.rb +2 -1
  49. data/spec/acfs/stub_spec.rb +57 -53
  50. data/spec/acfs_spec.rb +111 -93
  51. data/spec/spec_helper.rb +1 -1
  52. data/spec/support/response.rb +2 -2
  53. data/spec/support/service.rb +1 -1
  54. data/spec/support/shared/find_callbacks.rb +14 -10
  55. metadata +9 -8
@@ -6,149 +6,174 @@ describe Acfs::Collection do
6
6
  let(:model) { MyUser }
7
7
 
8
8
  describe 'Pagination' do
9
+ subject do
10
+ Acfs.run
11
+ collection
12
+ end
13
+
9
14
  let(:params) { {} }
10
15
  let!(:collection) { model.all params }
11
16
 
12
- subject { Acfs.run; collection }
13
-
14
17
  context 'without explicit page parameter' do
15
18
  before do
16
19
  stub_request(:get, 'http://users.example.org/users')
17
20
  .to_return response([{id: 1, name: 'Anon', age: 12, born_at: 'Berlin'}],
18
21
  headers: {
19
22
  'X-Total-Pages' => '2',
20
- 'X-Total-Count' => '10'
21
- })
23
+ 'X-Total-Count' => '10',
24
+ },)
22
25
  end
23
26
 
24
- its(:total_pages) { should eq 2 }
25
- its(:current_page) { should eq 1 }
26
- its(:total_count) { should eq 10 }
27
+ its(:total_pages) { is_expected.to eq 2 }
28
+ its(:current_page) { is_expected.to eq 1 }
29
+ its(:total_count) { is_expected.to eq 10 }
27
30
  end
28
31
 
29
32
  context 'with page parameter' do
30
33
  let(:params) { {page: 2} }
34
+
31
35
  before do
32
36
  stub_request(:get, 'http://users.example.org/users?page=2')
33
37
  .to_return response([{id: 1, name: 'Anon', age: 12, born_at: 'Berlin'}],
34
38
  headers: {
35
39
  'X-Total-Pages' => '2',
36
- 'X-Total-Count' => '10'
37
- })
40
+ 'X-Total-Count' => '10',
41
+ },)
38
42
  end
39
43
 
40
- its(:total_pages) { should eq 2 }
41
- its(:current_page) { should eq 2 }
42
- its(:total_count) { should eq 10 }
44
+ its(:total_pages) { is_expected.to eq 2 }
45
+ its(:current_page) { is_expected.to eq 2 }
46
+ its(:total_count) { is_expected.to eq 10 }
43
47
  end
44
48
 
45
49
  context 'with non-numerical page parameter' do
46
50
  let(:params) { {page: 'e546f5'} }
51
+
47
52
  before do
48
53
  stub_request(:get, 'http://users.example.org/users?page=e546f5')
49
54
  .to_return response([{id: 1, name: 'Anon', age: 12, born_at: 'Berlin'}],
50
55
  headers: {
51
56
  'X-Total-Pages' => '2',
52
- 'X-Total-Count' => '10'
53
- })
57
+ 'X-Total-Count' => '10',
58
+ },)
54
59
  end
55
60
 
56
- its(:total_pages) { should eq 2 }
57
- its(:current_page) { should eq 'e546f5' }
58
- its(:total_count) { should eq 10 }
61
+ its(:total_pages) { is_expected.to eq 2 }
62
+ its(:current_page) { is_expected.to eq 'e546f5' }
63
+ its(:total_count) { is_expected.to eq 10 }
59
64
  end
60
65
 
61
66
  describe '#next_page' do
67
+ subject(:request_page) do
68
+ Acfs.run
69
+ collection.next_page
70
+ end
71
+
62
72
  before do
63
73
  stub_request(:get, 'http://users.example.org/users')
64
74
  .to_return response([{id: 1, name: 'Anon', age: 12, born_at: 'Berlin'}],
65
75
  headers: {
66
76
  'X-Total-Pages' => '2',
67
- 'Link' => '<http://users.example.org/users?page=2>; rel="next"'
68
- })
77
+ 'Link' => '<http://users.example.org/users?page=2>; rel="next"',
78
+ },)
69
79
  end
80
+
70
81
  let!(:req) do
71
82
  stub_request(:get, 'http://users.example.org/users?page=2').to_return response([])
72
83
  end
73
84
  let!(:collection) { model.all }
74
- subject { Acfs.run; collection.next_page }
75
85
 
76
- it { should be_a Acfs::Collection }
86
+ it { is_expected.to be_a Acfs::Collection }
77
87
 
78
- it 'should have fetched page 2' do
79
- subject
88
+ it 'has fetched page 2' do
89
+ request_page
80
90
  Acfs.run
81
91
  expect(req).to have_been_requested
82
92
  end
83
93
  end
84
94
 
85
95
  describe '#prev_page' do
96
+ subject(:request_page) do
97
+ Acfs.run
98
+ collection.prev_page
99
+ end
100
+
86
101
  before do
87
102
  stub_request(:get, 'http://users.example.org/users?page=2')
88
103
  .to_return response([{id: 2, name: 'Anno', age: 1604, born_at: 'Santa Maria'}],
89
104
  headers: {
90
105
  'X-Total-Pages' => '2',
91
- 'Link' => '<http://users.example.org/users>; rel="prev"'
92
- })
106
+ 'Link' => '<http://users.example.org/users>; rel="prev"',
107
+ },)
93
108
  end
109
+
94
110
  let!(:req) do
95
111
  stub_request(:get, 'http://users.example.org/users').to_return response([])
96
112
  end
97
113
  let!(:collection) { model.all page: 2 }
98
- subject { Acfs.run; collection.prev_page }
99
114
 
100
- it { should be_a Acfs::Collection }
115
+ it { is_expected.to be_a Acfs::Collection }
101
116
 
102
- it 'should have fetched page 1' do
103
- subject
117
+ it 'has fetched page 1' do
118
+ request_page
104
119
  Acfs.run
105
120
  expect(req).to have_been_requested
106
121
  end
107
122
  end
108
123
 
109
124
  describe '#first_page' do
125
+ subject(:request_page) do
126
+ Acfs.run
127
+ collection.first_page
128
+ end
129
+
110
130
  before do
111
131
  stub_request(:get, 'http://users.example.org/users?page=2')
112
132
  .to_return response([{id: 2, name: 'Anno', age: 1604, born_at: 'Santa Maria'}],
113
133
  headers: {
114
134
  'X-Total-Pages' => '2',
115
- 'Link' => '<http://users.example.org/users>; rel="first"'
116
- })
135
+ 'Link' => '<http://users.example.org/users>; rel="first"',
136
+ },)
117
137
  end
138
+
118
139
  let!(:req) do
119
140
  stub_request(:get, 'http://users.example.org/users').to_return response([])
120
141
  end
121
142
  let!(:collection) { model.all page: 2 }
122
- subject { Acfs.run; collection.first_page }
123
143
 
124
- it { should be_a Acfs::Collection }
144
+ it { is_expected.to be_a Acfs::Collection }
125
145
 
126
- it 'should have fetched page 1' do
127
- subject
146
+ it 'has fetched page 1' do
147
+ request_page
128
148
  Acfs.run
129
149
  expect(req).to have_been_requested
130
150
  end
131
151
  end
132
152
 
133
153
  describe '#last_page' do
154
+ subject(:request_page) do
155
+ Acfs.run
156
+ collection.last_page
157
+ end
158
+
134
159
  before do
135
160
  stub_request(:get, 'http://users.example.org/users?page=2')
136
161
  .to_return response([{id: 2, name: 'Anno', age: 1604, born_at: 'Santa Maria'}],
137
162
  headers: {
138
163
  'X-Total-Pages' => '2',
139
- 'Link' => '<http://users.example.org/users?page=12>; rel="last"'
140
- })
164
+ 'Link' => '<http://users.example.org/users?page=12>; rel="last"',
165
+ },)
141
166
  end
167
+
142
168
  let!(:req) do
143
169
  stub_request(:get, 'http://users.example.org/users?page=12').to_return response([])
144
170
  end
145
171
  let!(:collection) { model.all page: 2 }
146
- subject { Acfs.run; collection.last_page }
147
172
 
148
- it { should be_a Acfs::Collection }
173
+ it { is_expected.to be_a Acfs::Collection }
149
174
 
150
- it 'should have fetched page 1' do
151
- subject
175
+ it 'has fetched page 1' do
176
+ request_page
152
177
  Acfs.run
153
178
  expect(req).to have_been_requested
154
179
  end
@@ -4,11 +4,16 @@ require 'spec_helper'
4
4
 
5
5
  describe Acfs::Configuration do
6
6
  let(:cfg) { Acfs::Configuration.new }
7
- before { @configuration = Acfs::Configuration.current.dup }
8
- after { Acfs::Configuration.set @configuration }
7
+
8
+ around do |example|
9
+ configuration = Acfs::Configuration.current.dup
10
+ example.run
11
+ ensure
12
+ Acfs::Configuration.set(configuration)
13
+ end
9
14
 
10
15
  describe 'Acfs.configure' do
11
- it 'should invoke configure on current configuration' do
16
+ it 'invokes configure on current configuration' do
12
17
  expect(Acfs::Configuration.current).to receive(:configure).once.and_call_original
13
18
 
14
19
  Acfs.configure do |c|
@@ -18,26 +23,31 @@ describe Acfs::Configuration do
18
23
  end
19
24
 
20
25
  describe '.load' do
21
- it 'should be able to load YAML' do
26
+ it 'is able to load YAML' do
22
27
  cfg.configure do
23
28
  load 'spec/fixtures/config.yml'
24
29
  end
25
30
 
26
- expect(cfg.locate(UserService).to_s).to be == 'http://localhost:3001/'
27
- expect(cfg.locate(CommentService).to_s).to be == 'http://localhost:3002/'
31
+ expect(cfg.locate(UserService).to_s).to eq 'http://localhost:3001/'
32
+ expect(cfg.locate(CommentService).to_s).to eq 'http://localhost:3002/'
28
33
  end
29
34
 
30
35
  context 'with RACK_ENV' do
31
- before { @env = ENV['RACK_ENV']; ENV['RACK_ENV'] = 'production' }
32
- after { ENV['RACK_ENV'] = @env }
36
+ around do |example|
37
+ env = ENV['RACK_ENV']
38
+ ENV['RACK_ENV'] = 'production'
39
+ example.run
40
+ ensure
41
+ ENV['RACK_ENV'] = env
42
+ end
33
43
 
34
- it 'should load ENV block' do
44
+ it 'loads ENV block' do
35
45
  cfg.configure do
36
46
  load 'spec/fixtures/config.yml'
37
47
  end
38
48
 
39
- expect(cfg.locate(UserService).to_s).to be == 'http://user.example.org/'
40
- expect(cfg.locate(CommentService).to_s).to be == 'http://comment.example.org/'
49
+ expect(cfg.locate(UserService).to_s).to eq 'http://user.example.org/'
50
+ expect(cfg.locate(CommentService).to_s).to eq 'http://comment.example.org/'
41
51
  end
42
52
  end
43
53
  end
@@ -45,7 +55,7 @@ describe Acfs::Configuration do
45
55
  describe '#adapter' do
46
56
  let(:object) { Object.new }
47
57
 
48
- it 'should be a accessor' do
58
+ it 'is a accessor' do
49
59
  cfg.adapter = object
50
60
  expect(cfg.adapter).to eq object
51
61
  end
@@ -28,7 +28,8 @@ describe ::Acfs::Global do
28
28
  before do
29
29
  ::ActiveSupport::Notifications.subscribe 'acfs.run', collector
30
30
  end
31
- it 'should trigger event' do
31
+
32
+ it 'triggers event' do
32
33
  Acfs.run
33
34
  expect(collector.events).to have(1).items
34
35
  end
@@ -38,7 +39,8 @@ describe ::Acfs::Global do
38
39
  before do
39
40
  ::ActiveSupport::Notifications.subscribe 'acfs.reset', collector
40
41
  end
41
- it 'should trigger event' do
42
+
43
+ it 'triggers event' do
42
44
  Acfs.reset
43
45
  expect(collector.events).to have(1).items
44
46
  end
@@ -50,11 +52,11 @@ describe ::Acfs::Global do
50
52
  stub_request(:get, %r{http://users.example.org/users/\d+}).to_return(
51
53
  status: 200,
52
54
  body: '{}',
53
- headers: {'Content-Type' => 'application/json'}
55
+ headers: {'Content-Type' => 'application/json'},
54
56
  )
55
57
  end
56
58
 
57
- it 'should invoke when both resources' do
59
+ it 'invokes when both resources' do
58
60
  user1 = MyUser.find 1
59
61
  user2 = MyUser.find 2
60
62
 
@@ -64,7 +66,7 @@ describe ::Acfs::Global do
64
66
  end.to yield_with_args(user1, user2)
65
67
  end
66
68
 
67
- it 'should invoke when both resources when loaded' do
69
+ it 'invokes when both resources when loaded' do
68
70
  user1 = MyUser.find 1
69
71
  user2 = MyUser.find 2
70
72
 
@@ -82,7 +84,7 @@ describe ::Acfs::Global do
82
84
  .to_return(
83
85
  status: 200,
84
86
  body: '{}',
85
- headers: {'Content-Type' => 'application/json'}
87
+ headers: {'Content-Type' => 'application/json'},
86
88
  )
87
89
  end
88
90
 
@@ -125,7 +127,7 @@ describe ::Acfs::Global do
125
127
  runner1 = Thread.new { acfs.runner }.value
126
128
  runner2 = Thread.new { acfs.runner }.value
127
129
 
128
- expect(runner1).to_not equal runner2
130
+ expect(runner1).not_to equal runner2
129
131
  end
130
132
 
131
133
  it 'uses configurated adapter' do
@@ -16,15 +16,15 @@ describe Acfs::Middleware::JSON do
16
16
 
17
17
  describe 'encode' do
18
18
  context 'with not serialized request' do
19
- it 'should set Content-Type' do
19
+ it 'sets Content-Type' do
20
20
  expect(request.headers['Content-Type']).to eq 'application/json'
21
21
  end
22
22
 
23
- it 'should append Accept header' do
23
+ it 'appends Accept header' do
24
24
  expect(request.headers['Accept']).to eq 'application/json;q=1'
25
25
  end
26
26
 
27
- it 'should serialize data to JSON' do
27
+ it 'serializes data to JSON' do
28
28
  expect(JSON.parse(request.body)).to eq data.map(&:stringify_keys)
29
29
  end
30
30
  end
@@ -38,7 +38,7 @@ describe Acfs::Middleware::JSON do
38
38
  end.new
39
39
  end
40
40
 
41
- it 'should serialize data with #to_json' do
41
+ it 'serializes data with #to_json' do
42
42
  expect(JSON.parse(request.body)).to eq 'a' => 1, 'b' => 2
43
43
  end
44
44
  end
@@ -49,10 +49,10 @@ describe Acfs::Middleware::JSON do
49
49
  let(:headers) { {'Content-Type' => 'application/json; charset=utf-8'} }
50
50
  let(:body) { data.to_json }
51
51
 
52
- it 'should decode body data' do
52
+ it 'decodes body data' do
53
53
  request.complete! response
54
54
 
55
- expect(response.data).to be == data.map(&:stringify_keys)
55
+ expect(response.data).to eq data.map(&:stringify_keys)
56
56
  end
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ describe Acfs::Middleware::JSON do
60
60
  let(:headers) { {'Content-Type' => 'application/json'} }
61
61
  let(:body) { data.to_json[4..-4] }
62
62
 
63
- it 'should raise an error' do
63
+ it 'raises an error' do
64
64
  expect { request.complete! response }.to raise_error(::JSON::ParserError)
65
65
  end
66
66
  end
@@ -69,7 +69,7 @@ describe Acfs::Middleware::JSON do
69
69
  let(:headers) { {'Content-Type' => 'application/text'} }
70
70
  let(:body) { data.to_json }
71
71
 
72
- it 'should not decode non-JSON encoded responses' do
72
+ it 'does not decode non-JSON encoded responses' do
73
73
  request.complete! response
74
74
 
75
75
  expect(response.data).to be_nil
@@ -16,23 +16,23 @@ describe Acfs::Middleware::MessagePack do
16
16
 
17
17
  describe 'encode' do
18
18
  context 'with not serialized request' do
19
- it 'should set Content-Type' do
19
+ it 'sets Content-Type' do
20
20
  expect(request.headers['Content-Type']).to eq 'application/x-msgpack'
21
21
  end
22
22
 
23
- it 'should append Accept header' do
23
+ it 'appends Accept header' do
24
24
  expect(request.headers['Accept']).to eq 'application/x-msgpack;q=1'
25
25
  end
26
26
 
27
27
  context 'with JSON chained' do
28
28
  let(:decoder) { Acfs::Middleware::JSON.new super(), q: 0.5 }
29
29
 
30
- it 'should append to Accept header' do
30
+ it 'appends to Accept header' do
31
31
  expect(request.headers['Accept']).to eq 'application/json;q=0.5,application/x-msgpack;q=1'
32
32
  end
33
33
  end
34
34
 
35
- it 'should serialize data to MessagePack' do
35
+ it 'serializes data to MessagePack' do
36
36
  expect(MessagePack.unpack(request.body)).to eq data.map(&:stringify_keys)
37
37
  end
38
38
  end
@@ -42,7 +42,7 @@ describe Acfs::Middleware::MessagePack do
42
42
  let(:headers) { {'Content-Type' => 'application/x-msgpack'} }
43
43
  let(:body) { MessagePack.pack data }
44
44
 
45
- it 'should decode body data' do
45
+ it 'decodes body data' do
46
46
  request.complete! response
47
47
 
48
48
  expect(response.data).to be == data.map(&:stringify_keys)
@@ -53,7 +53,7 @@ describe Acfs::Middleware::MessagePack do
53
53
  let(:headers) { {'Content-Type' => 'application/text'} }
54
54
  let(:body) { data.to_json }
55
55
 
56
- it 'should not decode non-MessagePack encoded responses' do
56
+ it 'does not decode non-MessagePack encoded responses' do
57
57
  request.complete! response
58
58
 
59
59
  expect(response.data).to be_nil
@@ -5,8 +5,9 @@ require 'spec_helper'
5
5
  describe ::Acfs::Operation do
6
6
  let(:operation) { described_class.new MyUser, :read, params: {id: 0} }
7
7
 
8
- context '#request' do
8
+ describe '#request' do
9
9
  subject { operation.request }
10
- its(:operation) { should eq operation }
10
+
11
+ its(:operation) { is_expected.to eq operation }
11
12
  end
12
13
  end
@@ -7,42 +7,51 @@ describe Acfs::Request::Callbacks do
7
7
  let(:request) { Acfs::Request.new('fubar') }
8
8
 
9
9
  describe '#on_complete' do
10
- it 'should store a given callback' do
10
+ it 'stores a given callback' do
11
11
  request.on_complete(&callback)
12
12
 
13
13
  expect(request.callbacks).to have(1).item
14
- expect(request.callbacks[0]).to be == callback
14
+ expect(request.callbacks[0]).to eq callback
15
15
  end
16
16
 
17
- it 'should store multiple callback' do
17
+ it 'stores multiple callback' do
18
18
  request.on_complete {|_res| 'abc' }
19
19
  request.on_complete(&callback)
20
20
 
21
21
  expect(request.callbacks).to have(2).item
22
- expect(request.callbacks[0]).to be == callback
22
+ expect(request.callbacks[0]).to eq callback
23
23
  end
24
24
  end
25
25
 
26
26
  describe '#complete!' do
27
27
  let(:response) { Acfs::Response.new(request) }
28
28
 
29
- it 'should trigger registered callbacks with given response' do
29
+ it 'triggers registered callbacks with given response' do
30
30
  expect(callback).to receive(:call).with(response, kind_of(Proc))
31
31
 
32
32
  request.on_complete(&callback)
33
33
  request.complete! response
34
34
  end
35
35
 
36
- it 'should trigger multiple callback in reverted insertion order' do
36
+ it 'triggers multiple callback in reverted insertion order' do
37
37
  check = []
38
38
 
39
- request.on_complete {|res, nxt| check << 1; nxt.call res }
40
- request.on_complete {|res, nxt| check << 2; nxt.call res }
41
- request.on_complete {|res, nxt| check << 3; nxt.call res }
39
+ request.on_complete do |res, nxt|
40
+ check << 1
41
+ nxt.call res
42
+ end
43
+ request.on_complete do |res, nxt|
44
+ check << 2
45
+ nxt.call res
46
+ end
47
+ request.on_complete do |res, nxt|
48
+ check << 3
49
+ nxt.call res
50
+ end
42
51
 
43
52
  request.complete! response
44
53
 
45
- expect(check).to be == [3, 2, 1]
54
+ expect(check).to eq [3, 2, 1]
46
55
  end
47
56
  end
48
57
  end
@@ -12,15 +12,15 @@ describe Acfs::Request do
12
12
  let(:request) { Acfs::Request.new(url, **options) }
13
13
 
14
14
  describe '#url' do
15
- it 'should return request URL' do
16
- expect(request.url).to be == url
15
+ it 'returns request URL' do
16
+ expect(request.url).to eq url
17
17
  end
18
18
 
19
19
  context 'with parameters' do
20
20
  let(:params) { {id: 10} }
21
21
 
22
- it 'should return URL without query' do
23
- expect(request.url).to be == url.to_s
22
+ it 'returns URL without query' do
23
+ expect(request.url).to eq url.to_s
24
24
  end
25
25
  end
26
26
  end
@@ -28,8 +28,8 @@ describe Acfs::Request do
28
28
  describe '#headers' do
29
29
  let(:headers) { {'Accept' => 'application/json'} }
30
30
 
31
- it 'should return request headers' do
32
- expect(request.headers).to be == headers
31
+ it 'returns request headers' do
32
+ expect(request.headers).to eq headers
33
33
  end
34
34
  end
35
35
 
@@ -37,43 +37,39 @@ describe Acfs::Request do
37
37
  context 'when nil given' do
38
38
  let(:method) { nil }
39
39
 
40
- it 'should default to :get' do
41
- expect(request.method).to be == :get
40
+ it 'defaults to :get' do
41
+ expect(request.method).to eq :get
42
42
  end
43
43
  end
44
44
 
45
- it 'should return request method' do
46
- expect(request.method).to be == method
45
+ it 'returns request method' do
46
+ expect(request.method).to eq method
47
47
  end
48
48
  end
49
49
 
50
50
  describe '#params' do
51
51
  let(:params) { {id: 10} }
52
52
 
53
- it 'should return request headers' do
54
- expect(request.params).to be == params
53
+ it 'returns request headers' do
54
+ expect(request.params).to eq params
55
55
  end
56
56
  end
57
57
 
58
58
  describe '#data' do
59
59
  let(:data) { {id: 10, name: 'Anon'} }
60
60
 
61
- it 'should return request data' do
62
- expect(request.data).to be == data
61
+ it 'returns request data' do
62
+ expect(request.data).to eq data
63
63
  end
64
- end
65
64
 
66
- describe '#data' do
67
65
  context 'with data' do
68
- let(:data) { {id: 10, name: 'Anon'} }
69
-
70
66
  it { expect(request).to be_data }
71
67
  end
72
68
 
73
69
  context 'without data' do
74
70
  let(:data) { nil }
75
71
 
76
- it { expect(request).to_not be_data }
72
+ it { expect(request).not_to be_data }
77
73
  end
78
74
  end
79
75
  end