active_rest_client 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +26 -5
- data/active_rest_client.gemspec +2 -2
- data/lib/active_rest_client/base.rb +31 -0
- data/lib/active_rest_client/configuration.rb +36 -0
- data/lib/active_rest_client/request.rb +34 -1
- data/lib/active_rest_client/result_iterator.rb +18 -0
- data/lib/active_rest_client/version.rb +1 -1
- data/spec/lib/base_spec.rb +68 -20
- data/spec/lib/caching_spec.rb +23 -23
- data/spec/lib/configuration_spec.rb +38 -14
- data/spec/lib/instrumentation_spec.rb +7 -8
- data/spec/lib/lazy_association_loader_spec.rb +7 -7
- data/spec/lib/lazy_loader_spec.rb +5 -5
- data/spec/lib/logger_spec.rb +13 -13
- data/spec/lib/proxy_spec.rb +15 -15
- data/spec/lib/recording_spec.rb +2 -2
- data/spec/lib/request_spec.rb +133 -98
- data/spec/lib/result_iterator_spec.rb +34 -5
- data/spec/lib/validation_spec.rb +1 -1
- data/spec/spec_helper.rb +11 -2
- metadata +6 -6
@@ -29,9 +29,9 @@ describe ActiveRestClient::ResultIterator do
|
|
29
29
|
|
30
30
|
it "should implement any?" do
|
31
31
|
result = ActiveRestClient::ResultIterator.new
|
32
|
-
expect(result.any?).to
|
32
|
+
expect(result.any?).to be_falsey
|
33
33
|
result << "a"
|
34
|
-
expect(result.any?).to
|
34
|
+
expect(result.any?).to be_truthy
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should implement items" do
|
@@ -64,10 +64,18 @@ describe ActiveRestClient::ResultIterator do
|
|
64
64
|
|
65
65
|
it "should implement empty?" do
|
66
66
|
result = ActiveRestClient::ResultIterator.new
|
67
|
-
expect(result.empty?).to
|
67
|
+
expect(result.empty?).to be_truthy
|
68
68
|
result << "a"
|
69
69
|
result << "z"
|
70
|
-
expect(result.empty?).to
|
70
|
+
expect(result.empty?).to be_falsey
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should implement reverse" do
|
74
|
+
result = ActiveRestClient::ResultIterator.new
|
75
|
+
result << "a"
|
76
|
+
result << "z"
|
77
|
+
expect(result.reverse.first).to eq("z")
|
78
|
+
expect(result.reverse.last).to eq("a")
|
71
79
|
end
|
72
80
|
|
73
81
|
it "should implement direct index access" do
|
@@ -83,7 +91,7 @@ describe ActiveRestClient::ResultIterator do
|
|
83
91
|
100.times do |n|
|
84
92
|
result << n
|
85
93
|
end
|
86
|
-
expect(result.shuffle.first == result.shuffle.first && result.shuffle.first == result.shuffle.first).to_not
|
94
|
+
expect(result.shuffle.first == result.shuffle.first && result.shuffle.first == result.shuffle.first).to_not be_truthy
|
87
95
|
end
|
88
96
|
|
89
97
|
it "can parallelise calls to each item" do
|
@@ -101,4 +109,25 @@ describe ActiveRestClient::ResultIterator do
|
|
101
109
|
expect(end_time-start_time).to be < (6*delay)
|
102
110
|
expect(response).to eq([6,4,2])
|
103
111
|
end
|
112
|
+
|
113
|
+
it "raises an error if you call paginate without WillPaginate installed" do
|
114
|
+
result = ActiveRestClient::ResultIterator.new
|
115
|
+
result << 3
|
116
|
+
expect{result.paginate}.to raise_error
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns a WillPaginate::Collection if you call paginate with WillPaginate installed" do
|
120
|
+
result = ActiveRestClient::ResultIterator.new
|
121
|
+
result << 3
|
122
|
+
|
123
|
+
module ::WillPaginate
|
124
|
+
class Collection ; end
|
125
|
+
end
|
126
|
+
allow(::WillPaginate).to receive(:per_page).and_return(10)
|
127
|
+
collection = double("WillPaginate::Collection")
|
128
|
+
allow(collection).to receive(:create).with(page: 1, per_page: 2).and_return(collection)
|
129
|
+
allow(::WillPaginate::Collection).to receive(:create).and_return(collection)
|
130
|
+
expect(result.paginate(page: 1, per_page: 2)).to eq(collection)
|
131
|
+
Object.send(:remove_const, :WillPaginate)
|
132
|
+
end
|
104
133
|
end
|
data/spec/lib/validation_spec.rb
CHANGED
@@ -106,7 +106,7 @@ describe "ActiveRestClient::Validation" do
|
|
106
106
|
validates :name, presence:true
|
107
107
|
end
|
108
108
|
|
109
|
-
ValidationExample3.
|
109
|
+
expect_any_instance_of(ValidationExample3).to receive(:valid?)
|
110
110
|
object = ValidationExample3.new
|
111
111
|
expect { object.create }.to raise_exception(ActiveRestClient::ValidationFailedException)
|
112
112
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,13 +16,22 @@ RSpec.configure do |config|
|
|
16
16
|
config.color = true
|
17
17
|
# config.formatter = 'documentation'
|
18
18
|
|
19
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
20
|
-
|
21
19
|
# Run specs in random order to surface order dependencies. If you find an
|
22
20
|
# order dependency and want to debug it, you can fix the order by providing
|
23
21
|
# the seed, which is printed after each run.
|
24
22
|
# --seed 1234
|
25
23
|
config.order = 'random'
|
24
|
+
|
25
|
+
config.mock_with :rspec do |mocks|
|
26
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
27
|
+
# instance as the first block argument to allow the implementation block to use
|
28
|
+
# the state of the receiver.
|
29
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
30
|
+
# this config option to `false` OR set this to `true` and update your
|
31
|
+
# `any_instance` implementation blocks to account for the first block argument
|
32
|
+
# being the receiving instance.
|
33
|
+
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
class TestCacheStore
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Which Ltd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: webmock
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,7 +200,7 @@ dependencies:
|
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 0.4.9
|
203
|
-
type: :
|
203
|
+
type: :runtime
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
requirements: []
|
287
287
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.
|
288
|
+
rubygems_version: 2.4.5
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: This gem is for accessing REST services in an ActiveRecord style. ActiveResource
|