api-spec 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ee6a0304cf9ce5c134154b06cb0dc9ee4c22d94
4
- data.tar.gz: 1c9101fd8201f89accffea9c5a1c5bef4e11dca1
3
+ metadata.gz: 565ae1651de2c60fce66d86f56d951150c5c6b0e
4
+ data.tar.gz: 699737e6e12f66c16081a28ce44a6a514d42dd35
5
5
  SHA512:
6
- metadata.gz: f9c7e6c52db2107ff590f518c482de786ab1d5d15642984103854385c9503653cbca6f78a11f154965109fb11f04d09ad8c9d2437498e1849acec0ea051a276e
7
- data.tar.gz: bfd4fa132b73db8f9e81d39ca2e5f6fb1634beea89fad793598b1d3de25364367821256bb694ab7aa66b8df67b0eca9b498872b8d68ec5e86e1ef5561689530b
6
+ metadata.gz: f631e82b8e66f007ce0e518981ff4dfaf696753ed8a7e42583b6c352c8a2a2dc80986199ffd75a56fd980325756cb1d9dd530a8bad871cde43e6d0283ca3d6aa
7
+ data.tar.gz: 23ff6231a999ee0412f0842964c7e3b0904bc1e6ce75463c38b6fe10461cc9ab72926790befbe63048f7de905adaec657b5a0dc00e5f98f49ccfe194184532c2
@@ -17,7 +17,6 @@ end
17
17
  When(/^I GET "(.*?)"$/) do |path|
18
18
  parameters = ApiSpec::Parameters.new(:get, path)
19
19
  @response = http_client.get parameters.url, test_headers
20
- puts "@response = #{@response}"
21
20
  end
22
21
 
23
22
  When(/^I GET "(.*?)" with:$/) do |path, table|
@@ -37,7 +36,10 @@ Then(/^the Content\-Type is (.*)$/) do |content_type|
37
36
  fail "Headers are not available on 4XX and 5XX responses"
38
37
  end
39
38
 
40
- @response.headers[:content_type].should match(content_type)
39
+ content_type = @response.headers["Content-Type"] ||
40
+ @response.headers[:content_type]
41
+
42
+ content_type.should match(content_type)
41
43
  end
42
44
 
43
45
  Then(/^the response contains an authentication cookie$/) do
@@ -27,10 +27,10 @@ class ApiSpec
27
27
  headers.merge(params: parameters.query)
28
28
  when :post
29
29
  @response = http_client.post parameters.url, parameters.body,
30
- headers.merge(content_type: :json)
30
+ headers
31
31
  when :put
32
32
  @response = http_client.put parameters.url, parameters.body,
33
- headers.merge(content_type: :json)
33
+ headers
34
34
  when :delete
35
35
  @response = http_client.delete parameters.url,
36
36
  headers
@@ -39,9 +39,9 @@ class ApiSpec
39
39
  end
40
40
 
41
41
  if ENV["API_SPEC_DEBUG"]
42
- puts "@response = #{@response}"
42
+ puts "@response = #{@response.body}"
43
43
  end
44
- rescue http_client::Exception => e
44
+ rescue RestClient::Exception => e
45
45
  @response = ErrorResponse.new(e.http_code, e.http_body)
46
46
  puts "Error response body: #{ @response.body }"
47
47
  end
@@ -44,15 +44,26 @@ class ApiSpec
44
44
  end
45
45
 
46
46
  def headers
47
- @header.merge(cookie_header)
47
+ @header.merge(cookie_header).merge(content_type_headers)
48
48
  end
49
49
 
50
50
  def cookie_header
51
- string = @cookie
51
+ { "Cookie" => cookie_string, "HTTP_COOKIE" => cookie_string }
52
+ end
53
+
54
+ def cookie_string
55
+ @cookie
52
56
  .map { |key, value| "#{key}=#{value}" }
53
57
  .join("; ")
58
+ end
54
59
 
55
- { "Cookie" => string }
60
+ def content_type_headers
61
+ if @json.any?
62
+ # {"Content-Type" => "application/json"}
63
+ {content_type: :json, "CONTENT_TYPE" => "application/json"}
64
+ else
65
+ {}
66
+ end
56
67
  end
57
68
 
58
69
  private
@@ -1,3 +1,3 @@
1
1
  class ApiSpec
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruz Marzolf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client