sanford-protocol 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,8 +17,11 @@ module Sanford::Protocol
17
17
  super(build_status(status), data)
18
18
  end
19
19
 
20
- def code; status.code; end
21
- def to_s; status.to_s; end
20
+ def code; status.code; end
21
+ def code=(new_code); status.code = new_code; end
22
+ def message; status.message; end
23
+ def message=(new_message); status.message = new_message; end
24
+ def to_s; status.to_s; end
22
25
 
23
26
  def to_hash
24
27
  { 'status' => [ status.code, status.message ],
@@ -10,9 +10,13 @@ module Sanford::Protocol
10
10
  super(Code.new(code), message)
11
11
  end
12
12
 
13
- def code; code_obj.number; end
13
+ def code; self.code_obj.number; end
14
14
  alias_method :to_i, :code
15
15
 
16
+ def code=(new_code)
17
+ self.code_obj = Code.new(new_code)
18
+ end
19
+
16
20
  def name; code_obj.name; end
17
21
  def to_s; code_obj.to_s; end
18
22
 
@@ -1,5 +1,5 @@
1
1
  module Sanford
2
2
  module Protocol
3
- GEM_VERSION = "0.9.0"
3
+ GEM_VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ class Sanford::Protocol::ResponseStatus
11
11
  subject{ @status }
12
12
 
13
13
  should have_readers :code_obj, :message
14
- should have_imeths :code, :name, :to_i
14
+ should have_imeths :code, :code=, :name, :to_i
15
15
 
16
16
  should "know it's code name" do
17
17
  named = Sanford::Protocol::ResponseStatus.new(200)
@@ -35,6 +35,12 @@ class Sanford::Protocol::ResponseStatus
35
35
  assert_equal subject.code, subject.to_i
36
36
  end
37
37
 
38
+ should "allow setting its code" do
39
+ number = Factory.integer
40
+ subject.code = number
41
+ assert_equal number, subject.code
42
+ end
43
+
38
44
  should "return it's code number and code name with #to_s" do
39
45
  named = Sanford::Protocol::ResponseStatus.new(200)
40
46
  unamed = Sanford::Protocol::ResponseStatus.new(999)
@@ -10,15 +10,21 @@ class Sanford::Protocol::Response
10
10
  end
11
11
  subject{ @response }
12
12
 
13
- should have_imeths :status, :code, :data, :to_hash, :to_s
13
+ should have_imeths :status, :data, :to_hash
14
+ should have_imeths :code, :code=, :message, :message=, :to_s
14
15
  should have_cmeths :parse
15
16
 
16
- should "return its status#code with #code" do
17
+ should "demeter its status" do
17
18
  assert_equal subject.status.code, subject.code
18
- end
19
-
20
- should "return its status#to_s with #to_s" do
19
+ assert_equal subject.status.message, subject.message
21
20
  assert_equal subject.status.to_s, subject.to_s
21
+
22
+ new_code = Factory.integer
23
+ new_message = Factory.string
24
+ subject.code = new_code
25
+ subject.message = new_message
26
+ assert_equal new_code, subject.code
27
+ assert_equal new_message, subject.message
22
28
  end
23
29
 
24
30
  should "return an instance of a Sanford::Protocol::Response given a hash using #parse" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanford-protocol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
8
+ - 10
9
9
  - 0
10
- version: 0.9.0
10
+ version: 0.10.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-06-27 00:00:00 Z
19
+ date: 2014-09-26 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement