skink 0.4.0 → 0.4.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.
data/lib/skink/client/utils.rb
CHANGED
data/lib/skink/version.rb
CHANGED
data/spec/skink_dsl_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-test
|