httpfiesta 0.0.1 → 0.0.2

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: f81ee99aeb3835583c3ea649a0824cd94ef7f4d1
4
- data.tar.gz: 82d91c31530e142731df9c74d8807bfcbe2fb395
3
+ metadata.gz: c72cc6146fe93f5ff75f3da7c06b55314efa25e2
4
+ data.tar.gz: 5ff22630e62ccfbc2ae39eb1172143c1e22b81aa
5
5
  SHA512:
6
- metadata.gz: 43565b86656986e8752643d0ed4d8251cff6c0102a7ddd9a3674d0fec2bf3f96f52d7e0a2ae0585f1430e3a7cf698e78a01de93086d4821e7fee31905bb5d33d
7
- data.tar.gz: a43e98369e12616dfbb1a7e224b55486bfa332a15b3aee503cc96b83bb2bf17dd0c87bbfba42ba4bd9e65b5a236f3c2ce82c1c3633abf0142ef8b2fb51af9614
6
+ metadata.gz: 26d0a3dec5729d39f7d684545ec0378a66e1d05a40ee086d2842face19e450607a741b3c24ecf912ab46db4b4a858f55ab4658242ff2c70d09dc7f85286a0744
7
+ data.tar.gz: 94ebd438b70da22dea9e55fae0f625abfe27d654cb385021302b81ddbf3160291d7e442ff0a6a0340c130be50df42545270702fac3f25a88c45a4da457776f03
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ tmp
22
22
  mkmf.log
23
23
 
24
24
  .idea
25
+ .DS_Store
data/README.md CHANGED
@@ -1,6 +1,19 @@
1
- # Httpfiesta
1
+ # HTTPFiesta [![Build Status](https://travis-ci.org/cgthornt/httpfiesta.svg?branch=master)](https://travis-ci.org/cgthornt/httpfiesta)
2
2
 
3
- TODO: Write a gem description
3
+ Verify and assert your HTTParty responses with ease!
4
+
5
+ ## Usage
6
+ Basic usage:
7
+ ```ruby
8
+ response = HTTParty.get 'http://example.com'
9
+ response.assert.status(200).content_type('application/json')
10
+ ```
11
+
12
+ More advanced:
13
+ ```ruby
14
+ response = HTTParty.get 'http://example.com'
15
+ response.assert.status(200..299).content_type(:json)
16
+ ```
4
17
 
5
18
  ## Installation
6
19
 
@@ -16,13 +29,9 @@ Or install it yourself as:
16
29
 
17
30
  $ gem install httpfiesta
18
31
 
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
32
  ## Contributing
24
33
 
25
- 1. Fork it ( https://github.com/[my-github-username]/httpfiesta/fork )
34
+ 1. Fork it ( https://github.com/cgthornt/httpfiesta/fork )
26
35
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
36
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
37
  4. Push to the branch (`git push origin my-new-feature`)
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '>= 1.9.3'
20
21
 
21
22
 
22
23
  spec.add_development_dependency 'bundler', '~> 1.6'
@@ -7,8 +7,9 @@ module HTTPFiesta
7
7
  @response = response
8
8
  end
9
9
 
10
- def message
11
- "HTTP #{response.request.method.upcase} #{response.request.path} : #{super}"
10
+ def to_s
11
+ request_method = response.request.http_method.to_s.split('::').last.upcase rescue ''
12
+ "HTTP #{request_method} #{response.request.path} : #{super}"
12
13
  end
13
14
  end
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module HTTPFiesta
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,27 @@
1
+ require 'helper'
2
+
3
+
4
+ describe HTTPFiesta::UnacceptableResponseError do
5
+ let(:status_code) { 404 }
6
+ let(:content_type) { 'application/json' }
7
+ let(:return_body) { { 'error' => 'foobar'}.to_json }
8
+
9
+ let(:response) { HTTParty.get 'http://example.com' }
10
+ before do
11
+ stub_request(:any, 'http://example.com').
12
+ to_return(body: return_body, status: status_code, headers: { content_type: content_type })
13
+ end
14
+
15
+
16
+
17
+ describe '#to_s' do
18
+ it 'returns a correct message' do
19
+ begin
20
+ response.assert.status(200)
21
+ rescue HTTPFiesta::UnacceptableResponseError => e
22
+ expect(e.message).to eq('HTTP GET http://example.com : status code \'404\' not in allowable range: 200..200')
23
+ end
24
+ end
25
+ end
26
+
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpfiesta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Thornton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-20 00:00:00.000000000 Z
12
+ date: 2014-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -133,6 +133,7 @@ files:
133
133
  - spec/helper.rb
134
134
  - spec/lib/assertion_spec.rb
135
135
  - spec/lib/monkeypatch_spec.rb
136
+ - spec/lib/unacceptable_response_error_spec.rb
136
137
  homepage: https://github.com/cgthornt/httpfiesta
137
138
  licenses:
138
139
  - MIT
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
146
  requirements:
146
147
  - - ">="
147
148
  - !ruby/object:Gem::Version
148
- version: '0'
149
+ version: 1.9.3
149
150
  required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
152
  - - ">="
@@ -161,3 +162,4 @@ test_files:
161
162
  - spec/helper.rb
162
163
  - spec/lib/assertion_spec.rb
163
164
  - spec/lib/monkeypatch_spec.rb
165
+ - spec/lib/unacceptable_response_error_spec.rb