stretchr 1.0.0

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.
@@ -0,0 +1,47 @@
1
+ require 'test/unit'
2
+ require 'test_helper.rb'
3
+
4
+ class StretchrResponseTest < Test::Unit::TestCase
5
+
6
+ def test_new_with_json
7
+
8
+ json_string = '{"~s":200,"~d":{"name":"Ryan"},"~x":"123","~e":[{"~m":"Something went wrong"}]}'
9
+ r = Stretchr::Response.new(:json => json_string)
10
+
11
+ assert_equal(json_string, r.json_string)
12
+ assert_equal(200, r.json_object["~s"])
13
+
14
+ assert_equal(200, r.status)
15
+ assert_equal("123", r.client_context)
16
+ assert_equal("Ryan", r.data["name"])
17
+ assert_equal(1, r.errors.length)
18
+ assert_equal("Something went wrong", r.errors[0])
19
+
20
+ end
21
+
22
+ def test_change_info
23
+ json_string = '{"~s":200, "~ch" : {"~deltas" : "test"}}'
24
+ r = Stretchr::Response.new(:json => json_string)
25
+ assert_equal r.changed, "test", "Should have grabbed the change info"
26
+
27
+ end
28
+
29
+ def test_was_successful
30
+ json_string = '{"~s":200,"~d":{"name":"Ryan"},"~x":"123","~e":[{"~m":"Something went wrong"}]}'
31
+ r = Stretchr::Response.new(:json => json_string)
32
+ assert_equal true, r.success?, "200 success"
33
+
34
+ json_string = '{"~s":201,"~d":{"name":"Ryan"},"~x":"123","~e":[{"~m":"Something went wrong"}]}'
35
+ r = Stretchr::Response.new(:json => json_string)
36
+ assert_equal true, r.success?, "201 success"
37
+
38
+ json_string = '{"~s":404,"~d":{"name":"Ryan"},"~x":"123","~e":[{"~m":"Something went wrong"}]}'
39
+ r = Stretchr::Response.new(:json => json_string, :supress_errors => true)
40
+ assert_equal false, r.success?, "404 success"
41
+
42
+ json_string = '{"~s":500,"~d":{"name":"Ryan"},"~x":"123","~e":[{"~m":"Something went wrong"}]}'
43
+ r = Stretchr::Response.new(:json => json_string, :supress_errors => true)
44
+ assert_equal false, r.success?, "500 success"
45
+ end
46
+
47
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ require 'test_helper.rb'
3
+
4
+ class TestTransporterTest < Test::Unit::TestCase
5
+
6
+ def test_test_transporter
7
+
8
+ t = Stretchr::TestTransporter.new
9
+
10
+ testRequest = Stretchr::Request.new
11
+ testResponse = Stretchr::Response.new
12
+
13
+ # queue up the repsonse
14
+ t.responses << testResponse
15
+
16
+ # make the request
17
+ returnedResponse = t.make_request(testRequest)
18
+
19
+ if assert_not_nil(t.requests, ".requests should be an array")
20
+ assert_equal(1, t.requests.length, "Should be one recorded request")
21
+ assert_equal(testRequest, t.requests[0], "Request should be added to .requests")
22
+ end
23
+
24
+ assert_equal(returnedResponse, testResponse, "Response in queue should be returned")
25
+ assert_equal(0, t.responses.length, ".responses should lose items as they're returned")
26
+
27
+ end
28
+
29
+ def test_test_transporter_response
30
+
31
+ t = Stretchr::TestTransporter.new
32
+
33
+ testRequest = Stretchr::Request.new
34
+
35
+ # make the request
36
+ returnedResponse = t.make_request(testRequest)
37
+
38
+ assert_nil(returnedResponse)
39
+
40
+ end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stretchr
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Quinn
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A gem for interacting with your stretchr data
15
+ email: ryan@mazondo.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/stretchr/client.rb
21
+ - lib/stretchr/configuration.rb
22
+ - lib/stretchr/exceptions.rb
23
+ - lib/stretchr/resources/resource.rb
24
+ - lib/stretchr/resources.rb
25
+ - lib/stretchr/security/signatory.rb
26
+ - lib/stretchr/security.rb
27
+ - lib/stretchr/stretchr_request.rb
28
+ - lib/stretchr/stretchr_response.rb
29
+ - lib/stretchr/transporters/default_transporter.rb
30
+ - lib/stretchr/transporters/test_transporter.rb
31
+ - lib/stretchr/transporters.rb
32
+ - lib/stretchr.rb
33
+ - test/test_client.rb
34
+ - test/test_helper.rb
35
+ - test/test_resources.rb
36
+ - test/test_signatory.rb
37
+ - test/test_stretchr_http_actions.rb
38
+ - test/test_stretchr_request.rb
39
+ - test/test_stretchr_response.rb
40
+ - test/test_test_transporter.rb
41
+ homepage: http://www.stretchr.com
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.24
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: A gem for managing your stretchr data
65
+ test_files: []
66
+ has_rdoc: