rapidash 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c07a3c38b01592f574fe0e4fcefde4d2b6d9f708
4
- data.tar.gz: 2e0d84d785ba58bd8767a52d4481f9714e759d3b
3
+ metadata.gz: 27988e3bc9f82d6c93ca68a8f5e4a18a802b56c0
4
+ data.tar.gz: 65b988d98e2feb6afed163fb8876ef3f033d04d4
5
5
  SHA512:
6
- metadata.gz: f8c6bbd17bfdd5bca3a85c527bb7f98b9db48f9c38edcd450b4ba8b3fbeab9626fb458426ae1018e24eeb934ed3bf5fe6c945448e439c09477c693eb2e55e25e
7
- data.tar.gz: 2b023b3f5e73e8ca9f192538c9aa6ab05ca162fab46a811aac2534510d2d7aaf14698c1ad4d90e2135c97547e938045b41b2c517c78135f3b40da90278ceef49
6
+ metadata.gz: e379666447ac2040248ea184dae2068c871ac9b51e0d446a71a5b6abe0525f981bd9cd2f43bd73050706091984f4d4d2a0f800fc3a74931f1682fb19b55c0b59
7
+ data.tar.gz: d9ca90ec4f6c5c88da837644642396281807b3387285a870ebc98b2ad54148f984535d7b0c7dca49133adf2bd0d6ee8769fce88d349d251aed565a6aedf3e9fd
data/README.md CHANGED
@@ -20,6 +20,11 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ A screencast on Rapidash is available to watch in mp4 and ogv formats.
24
+
25
+ * [Rapidash Screencast mp4](http://screencasts.gazler.com/rapidash.mp4)
26
+ * [Rapidash Screencast ogv](http://screencasts.gazler.com/rapidash.ogv)
27
+
23
28
  ### Resources
24
29
 
25
30
  Resources can be defined as follows:
@@ -158,4 +163,4 @@ p client.users("Gazler").repos![0].name #Githug
158
163
 
159
164
  ## Credits
160
165
 
161
- Thanks to @Sid3show for the sweet logo!
166
+ Thanks to [@Sid3show](https://github.com/Sid3show) for the sweet logo!
@@ -8,7 +8,6 @@ module Rapidash
8
8
  def new(response)
9
9
  return nil unless response.body
10
10
  type = response.headers["content-type"]
11
- if type.include?("application/json")
12
11
  body = JSON.parse(response.body)
13
12
  if body.kind_of?(Hash)
14
13
  return Hashie::Mash.new(body)
@@ -19,9 +18,8 @@ module Rapidash
19
18
  end
20
19
  return output
21
20
  end
22
- else
23
- raise ParseError.new("Cannot parse content type: #{response.headers["content-type"]}")
24
- end
21
+ rescue JSON::ParserError => e
22
+ raise ParseError.new("Failed to parse content for type: #{response.headers["content-type"]}")
25
23
  end
26
24
  end
27
25
 
@@ -1,3 +1,3 @@
1
1
  module Rapidash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -11,6 +11,26 @@ def valid_response_object
11
11
  })
12
12
  end
13
13
 
14
+ def valid_html_response_object
15
+ body = {"foo" => "bar" }.to_json
16
+ OpenStruct.new({
17
+ :headers => {
18
+ "content-type" => "text/html"
19
+ },
20
+ :body => body
21
+ })
22
+ end
23
+
24
+ def valid_js_response_object
25
+ body = {"foo" => "bar" }.to_json
26
+ OpenStruct.new({
27
+ :headers => {
28
+ "content-type" => "text/javascript"
29
+ },
30
+ :body => body
31
+ })
32
+ end
33
+
14
34
 
15
35
  def valid_response_array
16
36
  body = [{"foo" => "bar" }, {"baz" => "bra"}].to_json
@@ -32,6 +52,15 @@ def invalid_response
32
52
  })
33
53
  end
34
54
 
55
+ def invalid_js_response_object
56
+ OpenStruct.new({
57
+ :headers => {
58
+ "content-type" => "text/javascript"
59
+ },
60
+ :body => "<xml>something</xml>"
61
+ })
62
+ end
63
+
35
64
  def nil_response
36
65
  OpenStruct.new({
37
66
  :body => nil
@@ -45,6 +74,16 @@ describe Rapidash::Response do
45
74
  response = Rapidash::Response.new(valid_response_object)
46
75
  response.foo.should eql("bar")
47
76
  end
77
+
78
+ it "should parse JSON Objects returned with javascript type" do
79
+ response = Rapidash::Response.new(valid_js_response_object)
80
+ response.foo.should eql("bar")
81
+ end
82
+
83
+ it "should parse JSON Objects returned with html type" do
84
+ response = Rapidash::Response.new(valid_html_response_object)
85
+ response.foo.should eql("bar")
86
+ end
48
87
 
49
88
  it "should parse JSON Arrays" do
50
89
  response = Rapidash::Response.new(valid_response_array)
@@ -63,6 +102,12 @@ describe Rapidash::Response do
63
102
  Rapidash::Response.new(invalid_response)
64
103
  }.to raise_error(Rapidash::ParseError)
65
104
  end
105
+
106
+ it "should raise an error on a non-json response body" do
107
+ expect {
108
+ Rapidash::Response.new(invalid_js_response_object)
109
+ }.to raise_error(Rapidash::ParseError)
110
+ end
66
111
  end
67
112
 
68
113
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapidash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary 'Gazler' Rennie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-14 00:00:00.000000000 Z
11
+ date: 2013-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler