and-son 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency("sanford-protocol", ["~> 0.10"])
21
+ gem.add_dependency("sanford-protocol", ["~> 0.11"])
22
22
 
23
- gem.add_development_dependency("assert", ["~> 2.12"])
23
+ gem.add_development_dependency("assert", ["~> 2.14"])
24
24
  end
@@ -74,6 +74,11 @@ module AndSon
74
74
  params ||= {}
75
75
  callback_params = self.params_value.merge(params)
76
76
 
77
+ # attempt to encode (and then throw away) the request, this will error on
78
+ # the developer if it can't encode the request
79
+ request = Sanford::Protocol::Request.new(name, params)
80
+ Sanford::Protocol.msg_body.encode(request.to_hash)
81
+
77
82
  response = self.responses.get(name, params)
78
83
  self.before_call_procs.each{ |p| p.call(name, callback_params, self) }
79
84
  self.calls << Call.new(name, params, response.protocol_response)
@@ -1,3 +1,3 @@
1
1
  module AndSon
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -55,10 +55,18 @@ class TestServer
55
55
  thread = Thread.new{ server.run }
56
56
  yield
57
57
  ensure
58
+ sockaddr = Socket.pack_sockaddr_in(
59
+ server.instance_variable_get("@port"),
60
+ '127.0.0.1'
61
+ )
62
+ socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
58
63
  begin
59
- TCPSocket.open("localhost", server.instance_variable_get("@port"))
60
- rescue Exception
64
+ socket.connect_nonblock(sockaddr)
65
+ rescue Errno::EINPROGRESS # socket is in the process of connecting
66
+ IO.select(nil, [socket], nil, 1) # timeout after 1 second
67
+ rescue StandardError
61
68
  end
69
+ socket.close
62
70
  thread.join
63
71
  end
64
72
  end
@@ -126,6 +126,8 @@ module AndSon::Client
126
126
  @name = Factory.string
127
127
  @params = { Factory.string => Factory.string }
128
128
 
129
+ Assert.stub(Sanford::Protocol.msg_body, :encode){ |r| @encoded_request = r }
130
+
129
131
  @client = AndSon::TestClient.new(@host, @port)
130
132
  end
131
133
  subject{ @client }
@@ -147,7 +149,7 @@ module AndSon::Client
147
149
  end
148
150
 
149
151
  should "know its call runner" do
150
- subject
152
+ assert_equal subject, subject.call_runner
151
153
  end
152
154
 
153
155
  should "store each call made in its `calls`" do
@@ -174,6 +176,12 @@ module AndSon::Client
174
176
  assert_equal exp.protocol_response, yielded
175
177
  end
176
178
 
179
+ should "build and encode a request when called" do
180
+ subject.call(@name, @params)
181
+ exp = Sanford::Protocol::Request.new(@name, @params).to_hash
182
+ assert_equal exp, @encoded_request
183
+ end
184
+
177
185
  should "run before call procs" do
178
186
  subject.params({ Factory.string => Factory.string })
179
187
  yielded_name = nil
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: and-son
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 8
8
+ - 9
9
9
  - 0
10
- version: 0.8.0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-12-18 00:00:00 Z
19
+ date: 2015-06-22 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 31
27
+ hash: 29
28
28
  segments:
29
29
  - 0
30
- - 10
31
- version: "0.10"
32
- version_requirements: *id001
30
+ - 11
31
+ version: "0.11"
33
32
  type: :runtime
34
33
  name: sanford-protocol
34
+ version_requirements: *id001
35
35
  prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
@@ -39,14 +39,14 @@ dependencies:
39
39
  requirements:
40
40
  - - ~>
41
41
  - !ruby/object:Gem::Version
42
- hash: 27
42
+ hash: 31
43
43
  segments:
44
44
  - 2
45
- - 12
46
- version: "2.12"
47
- version_requirements: *id002
45
+ - 14
46
+ version: "2.14"
48
47
  type: :development
49
48
  name: assert
49
+ version_requirements: *id002
50
50
  prerelease: false
51
51
  description: Simple Sanford client for Ruby.
52
52
  email:
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements: []
111
111
 
112
112
  rubyforge_project:
113
- rubygems_version: 1.8.29
113
+ rubygems_version: 1.8.25
114
114
  signing_key:
115
115
  specification_version: 3
116
116
  summary: Simple Sanford client for Ruby.