skink 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module Utils
20
20
  end
21
21
 
22
22
  # otherwise this should work
23
- name.split("_").map(&:capitalize).join("-")
23
+ name.to_s.split(/[_-]/).map(&:capitalize).join("-")
24
24
  end
25
25
  end
26
26
 
@@ -18,7 +18,11 @@ class RackTestResponse < Client::Response
18
18
  end
19
19
 
20
20
  def headers
21
- native_response.header
21
+ if native_response.is_a? Rack::Response
22
+ native_response.header
23
+ else
24
+ native_response.headers
25
+ end
22
26
  end
23
27
 
24
28
  def body
data/lib/skink/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skink
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -79,6 +79,15 @@ shared_examples "a REST API test language" do
79
79
  response.should_not have_header("This-Is-Not-A-Header-Name")
80
80
  end
81
81
 
82
+ it "has a helpful failure message for have_header" do
83
+ with_accept_header "application/json"
84
+ get "/json_doc"
85
+ expect {response.should have_header(:not_a_real_header)}.to raise_error(/expected response headers .* to have header Not-A-Real-Header/)
86
+ expect {response.should have_header(content_type: /xml/)}.to raise_error(%r{expected response headers .* to have header Content-Type with value /xml/})
87
+ expect {response.should_not have_header(:content_type)}.to raise_error(/expected response headers .* to not have header Content-Type/)
88
+ expect {response.should_not have_header('Content-Type' => /json/)}.to raise_error(%r{expected response headers .* to not have header Content-Type with value /json/})
89
+ end
90
+
82
91
  it "is able to test the value of specified response headers" do
83
92
  with_accept_header "application/xml"
84
93
  get "/xml_doc"
@@ -1,3 +1,6 @@
1
+ require 'skink/client/utils'
2
+ include Skink::Client::Utils
3
+
1
4
  RSpec::Matchers.define :have_status_code do |expected|
2
5
  match do |response|
3
6
  response.has_status_code? expected
@@ -12,6 +15,28 @@ RSpec::Matchers.define :have_status_code do |expected|
12
15
  end
13
16
  end
14
17
 
18
+ RSpec::Matchers.define :have_header do |expected|
19
+ match do |response|
20
+ response.has_header? expected
21
+ end
22
+
23
+ failure_message_for_should do |response|
24
+ if expected.respond_to? :keys
25
+ "expected response headers #{response.headers.inspect} to have header #{normalize_header_name(expected.keys.first)} with value #{expected.values.first.inspect}"
26
+ else
27
+ "expected response headers #{response.headers.inspect} to have header #{normalize_header_name(expected)}"
28
+ end
29
+ end
30
+
31
+ failure_message_for_should_not do |response|
32
+ if expected.respond_to? :keys
33
+ "expected response headers #{response.headers.inspect} to not have header #{normalize_header_name(expected.keys.first)} with value #{expected.values.first.inspect}"
34
+ else
35
+ "expected response headers #{response.headers.inspect} to not have header #{normalize_header_name(expected)}"
36
+ end
37
+ end
38
+ end
39
+
15
40
  RSpec::Matchers.define :have_xpath do |xpath, value|
16
41
  match do |response|
17
42
  response.has_xpath? xpath, value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-27 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-test