httpfiesta 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +16 -7
- data/httpfiesta.gemspec +1 -0
- data/lib/httpfiesta/unacceptable_response_error.rb +3 -2
- data/lib/httpfiesta/version.rb +1 -1
- data/spec/lib/unacceptable_response_error_spec.rb +27 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72cc6146fe93f5ff75f3da7c06b55314efa25e2
|
4
|
+
data.tar.gz: 5ff22630e62ccfbc2ae39eb1172143c1e22b81aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26d0a3dec5729d39f7d684545ec0378a66e1d05a40ee086d2842face19e450607a741b3c24ecf912ab46db4b4a858f55ab4658242ff2c70d09dc7f85286a0744
|
7
|
+
data.tar.gz: 94ebd438b70da22dea9e55fae0f625abfe27d654cb385021302b81ddbf3160291d7e442ff0a6a0340c130be50df42545270702fac3f25a88c45a4da457776f03
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# HTTPFiesta [](https://travis-ci.org/cgthornt/httpfiesta)
|
2
2
|
|
3
|
-
|
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/
|
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`)
|
data/httpfiesta.gemspec
CHANGED
@@ -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
|
11
|
-
|
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
|
data/lib/httpfiesta/version.rb
CHANGED
@@ -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.
|
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-
|
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:
|
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
|