saddle 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: c6cbc5f3bed08d163ba1f6bb948acb555c16b9034ff6adac036a0f1f4252f872
4
- data.tar.gz: 6b509a1bdb969e7b54c3c6fd93d742ef3cfd7144de2e8c36014f8a5fdc32484a
3
+ metadata.gz: 40349fa3b434064564e6060fafbfede9327e3ad28d28035ecc6ce3eefebc096d
4
+ data.tar.gz: 68d77c929a14a18571ec4be49fa2daf0e207840add48e3424220643a68c57be5
5
5
  SHA512:
6
- metadata.gz: c22f775da62289da5111c42fc64373aec52b3c831b828a0b40f9fda5d354d569da0481e8d789422965cd802ea23855816c4d53224ec3507a5a8dd977f7209c0c
7
- data.tar.gz: 392ebba3e48907a68867ba54125fdccbc26df04659fd84db2aa053823af414da24093eca48bf3b460efaf43bfcbc1792c813b25e04c6a521b221f815ef89503d
6
+ metadata.gz: d84f468133bedaa13ecb030dc2819a0f23b39255b1e500301b5e220d638b2d125106ebea591f2b25628e366fc433e9f440217a94a84f30367a4acb471cbfb0a1
7
+ data.tar.gz: ab8fccb3facdd3d186627c6c76569e3209b8d7cad3608125a4c24799ba7eaf58c4e2ac04f5793d23c9d989a0a4c6bace879952ffa658bd5a76653aaa9547f85e
@@ -9,7 +9,7 @@ module <%= root_module %>
9
9
 
10
10
  # Setup stubbing for all endpoints
11
11
  def stub!
12
- <%= root_module %>::Endpoints::Status.any_instance.stub(:healthy?).and_return(
12
+ allow_any_instance_of(<%= root_module %>::Endpoints::Status).to receive(:healthy?).and_return(
13
13
  Stub::Data::TEST_STATUS_HEALTHY_RESPONSE
14
14
  )
15
15
  end
@@ -47,13 +47,13 @@ module Saddle
47
47
  @host = opt[:host] || 'localhost'
48
48
  raise ':host must be a string' unless @host.is_a?(String)
49
49
  @port = opt[:port]
50
- raise ':port must be nil or an integer' unless (@port.nil? || @port.is_a?(Fixnum))
50
+ raise ':port must be nil or an integer' unless (@port.nil? || @port.is_a?(Integer))
51
51
  @use_ssl = opt[:use_ssl] || false
52
52
  raise ':use_ssl must be true or false' unless (@use_ssl.is_a?(TrueClass) || @use_ssl.is_a?(FalseClass))
53
53
  @request_style = opt[:request_style] || :json
54
54
  raise ":request_style must be in: #{VALID_BODY_STYLES.join(',')}" unless VALID_BODY_STYLES.include?(@request_style)
55
55
  @num_retries = opt[:num_retries] || 3
56
- raise ':num_retries must be an integer' unless @num_retries.is_a?(Fixnum)
56
+ raise ':num_retries must be an integer' unless @num_retries.is_a?(Integer)
57
57
  @timeout = opt[:timeout]
58
58
  raise ':timeout must be nil or an integer' unless (@timeout.nil? || @timeout.is_a?(Numeric))
59
59
  @extra_env = opt[:extra_env] || {}
@@ -1,3 +1,3 @@
1
1
  module Saddle
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -15,8 +15,7 @@ describe Saddle::Middleware::Logging::StatsdLogger do
15
15
  end
16
16
 
17
17
  it "should log a request" do
18
- ::Statsd.any_instance.should_receive(:time).with("saddle.statsd_client.raw.localhost-test").and_yield
19
-
18
+ allow_any_instance_of(::Statsd).to receive(:time).with("saddle.statsd_client.raw.localhost-test").and_yield
20
19
  client = StatsdClient.create(
21
20
  :stubs => Faraday::Adapter::Test::Stubs.new do |stub|
22
21
  stub.get('/test') {
@@ -32,8 +31,7 @@ describe Saddle::Middleware::Logging::StatsdLogger do
32
31
  end
33
32
 
34
33
  it "should allow overriding the path" do
35
- ::Statsd.any_instance.should_receive(:time).with("hello").and_yield
36
-
34
+ allow_any_instance_of(::Statsd).to receive(:time).with("hello").and_yield
37
35
  client = StatsdClient.create(
38
36
  :stubs => Faraday::Adapter::Test::Stubs.new do |stub|
39
37
  stub.get('/test') {
@@ -0,0 +1,136 @@
1
+ require 'spec_helper'
2
+
3
+ describe Saddle::Client do
4
+ context "when path_prefix is set" do
5
+ context "using the default client" do
6
+ before :each do
7
+ @stubs = Faraday::Adapter::Test::Stubs.new
8
+ @default_client = Saddle::Client.create(:stubs => @stubs, :path_prefix => 'api/v1')
9
+ end
10
+
11
+ context "with no path" do
12
+ context "for a GET request" do
13
+ context "with no params" do
14
+ it "should properly prefix the path" do
15
+ url = ''
16
+ @stubs.get('/api/v1/') {
17
+ [
18
+ 200,
19
+ {},
20
+ 'Party!',
21
+ ]
22
+ }
23
+ @default_client.requester.get(url).should == 'Party!'
24
+ end
25
+ end
26
+
27
+ context "with params" do
28
+ it "should properly prefix the path" do
29
+ url = '?a=1'
30
+ @stubs.get('/api/v1/?a=1') {
31
+ [
32
+ 200,
33
+ {},
34
+ 'Party!',
35
+ ]
36
+ }
37
+ @default_client.requester.get(url).should == 'Party!'
38
+ end
39
+ end
40
+ end
41
+
42
+ context "for a POST request" do
43
+ context "with no params" do
44
+ it "should properly prefix the path" do
45
+ url = ''
46
+ @stubs.post('/api/v1/') {
47
+ [
48
+ 200,
49
+ {},
50
+ 'Party!',
51
+ ]
52
+ }
53
+ @default_client.requester.post(url).should == 'Party!'
54
+ end
55
+ end
56
+
57
+ context "with params" do
58
+ it "should properly prefix the path" do
59
+ url = '?a=1'
60
+ @stubs.post('/api/v1/?a=1') {
61
+ [
62
+ 200,
63
+ {},
64
+ 'Party!',
65
+ ]
66
+ }
67
+ @default_client.requester.post(url).should == 'Party!'
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ context "with a path" do
74
+ context "for a GET request" do
75
+ context "with no params" do
76
+ it "should properly prefix the path" do
77
+ url = '/test'
78
+ @stubs.get('/api/v1/test') {
79
+ [
80
+ 200,
81
+ {},
82
+ 'Party!',
83
+ ]
84
+ }
85
+ @default_client.requester.get(url).should == 'Party!'
86
+ end
87
+ end
88
+
89
+ context "with params" do
90
+ it "should properly prefix the path" do
91
+ url = '/test?a=1'
92
+ @stubs.get('/api/v1/test?a=1') {
93
+ [
94
+ 200,
95
+ {},
96
+ 'Party!',
97
+ ]
98
+ }
99
+ @default_client.requester.get(url).should == 'Party!'
100
+ end
101
+ end
102
+ end
103
+
104
+ context "for a POST request" do
105
+ context "with no params" do
106
+ it "should properly prefix the path" do
107
+ url = '/test'
108
+ @stubs.post('/api/v1/test') {
109
+ [
110
+ 200,
111
+ {},
112
+ 'Party!',
113
+ ]
114
+ }
115
+ @default_client.requester.post(url).should == 'Party!'
116
+ end
117
+ end
118
+
119
+ context "with params" do
120
+ it "should properly prefix the path" do
121
+ url = '/test?a=1'
122
+ @stubs.post('/api/v1/test?a=1') {
123
+ [
124
+ 200,
125
+ {},
126
+ 'Party!',
127
+ ]
128
+ }
129
+ @default_client.requester.post(url).should == 'Party!'
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -61,8 +61,8 @@ describe Saddle::Client do
61
61
  client2 = Client2.create(:stubs => stubs)
62
62
 
63
63
  # Make sure client2's middleware isn't called
64
- Middleware1.any_instance.should_receive(:subcall)
65
- Middleware2.any_instance.should_not_receive(:subcall)
64
+ allow_any_instance_of(Middleware1).to receive(:subcall)
65
+ allow_any_instance_of(Middleware2).to receive(:subcall)
66
66
 
67
67
  # Make the call
68
68
  client1.requester.get('/')
data/spec/spec_helper.rb CHANGED
@@ -2,3 +2,7 @@ require 'faraday' # for test stubs
2
2
  require 'saddle'
3
3
 
4
4
  require 'pry'
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Lewis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,6 +128,7 @@ files:
128
128
  - spec/middleware/logging/airbrake_spec.rb
129
129
  - spec/middleware/logging/rails_spec.rb
130
130
  - spec/middleware/logging/statsd_spec.rb
131
+ - spec/middleware/request/path_prefix_spec.rb
131
132
  - spec/middleware/request/retry_spec.rb
132
133
  - spec/middleware/response/default_response_spec.rb
133
134
  - spec/multiple_spec.rb
@@ -166,6 +167,7 @@ test_files:
166
167
  - spec/middleware/logging/airbrake_spec.rb
167
168
  - spec/middleware/logging/rails_spec.rb
168
169
  - spec/middleware/logging/statsd_spec.rb
170
+ - spec/middleware/request/path_prefix_spec.rb
169
171
  - spec/middleware/request/retry_spec.rb
170
172
  - spec/middleware/response/default_response_spec.rb
171
173
  - spec/multiple_spec.rb