skink 0.3.0 → 0.3.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/integrations/rspec.rb +2 -0
- data/lib/skink/version.rb +1 -1
- data/spec/skink_dsl_spec.rb +21 -0
- data/spec/support/matchers/response_matchers.rb +27 -0
- data/spec/test_server.rb +1 -1
- metadata +4 -2
data/lib/skink/version.rb
CHANGED
data/spec/skink_dsl_spec.rb
CHANGED
@@ -7,6 +7,12 @@ shared_examples "a REST API test language" do
|
|
7
7
|
response.body.size.should == 0
|
8
8
|
end
|
9
9
|
|
10
|
+
it "has a helpful failure message for have_status_code" do
|
11
|
+
head "/"
|
12
|
+
expect { response.should have_status_code 500 }.to raise_error("expected status code 500, but got 200")
|
13
|
+
expect { response.should_not have_status_code 200 }.to raise_error("expected status code would not be 200, but dang, it was")
|
14
|
+
end
|
15
|
+
|
10
16
|
it "is able to test a GET" do
|
11
17
|
get "/"
|
12
18
|
response.should have_status_code 200
|
@@ -59,6 +65,12 @@ shared_examples "a REST API test language" do
|
|
59
65
|
response.body.should == "Welcome, authenticated client."
|
60
66
|
end
|
61
67
|
|
68
|
+
it "is able to test requests requiring basic auth with long usernames or passwords" do
|
69
|
+
with_basic_auth "xanthomata.loosish@shazbot.invalid", "super-super-super-super-super-super-dooper-secret"
|
70
|
+
get "/protected"
|
71
|
+
response.should have_status_code 200
|
72
|
+
end
|
73
|
+
|
62
74
|
it "is able to test the presence of specified response headers" do
|
63
75
|
with_accept_header "application/json"
|
64
76
|
get "/json_doc"
|
@@ -89,6 +101,15 @@ shared_examples "a REST API test language" do
|
|
89
101
|
response.should have_jsonpath "root.foo.foo", /ow/
|
90
102
|
response.should_not have_jsonpath "root.foo.foo", /oo/
|
91
103
|
end
|
104
|
+
|
105
|
+
it "gives a helpful error message when have_xpath fails" do
|
106
|
+
with_accept_header "application/xml"
|
107
|
+
get "/xml_doc"
|
108
|
+
expect {response.should have_xpath "//not/a/valid/xpath"}.to raise_error(/^expected xpath .* in .*$/)
|
109
|
+
expect {response.should have_xpath "//root/foo", /not there/}.to raise_error(%r{^expected xpath .* with value /not there/ in .*$})
|
110
|
+
expect {response.should_not have_xpath "//foo/foo"}.to raise_error(/^expected xpath .* would not be in .*/)
|
111
|
+
expect {response.should_not have_xpath "//root/foo", /Some/}.to raise_error(%r{^expected xpath .* with value /Some/ would not be in .*$})
|
112
|
+
end
|
92
113
|
end
|
93
114
|
|
94
115
|
describe Skink::DSL do
|
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec::Matchers.define :have_status_code do |expected|
|
2
|
+
match do |response|
|
3
|
+
response.has_status_code? expected
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message_for_should do |response|
|
7
|
+
"expected status code #{expected}, but got #{response.status_code}"
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should_not do |response|
|
11
|
+
"expected status code would not be #{expected}, but dang, it was"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec::Matchers.define :have_xpath do |xpath, value|
|
16
|
+
match do |response|
|
17
|
+
response.has_xpath? xpath, value
|
18
|
+
end
|
19
|
+
|
20
|
+
failure_message_for_should do |response|
|
21
|
+
"expected xpath #{xpath}#{value ? " with value #{value.inspect}" : ""} in #{response.body}"
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_for_should_not do |response|
|
25
|
+
"expected xpath #{xpath}#{value ? " with value #{value.inspect}" : ""} would not be in #{response.body}"
|
26
|
+
end
|
27
|
+
end
|
data/spec/test_server.rb
CHANGED
@@ -10,7 +10,7 @@ helpers do
|
|
10
10
|
|
11
11
|
def authorized?
|
12
12
|
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
13
|
-
@auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == ['admin', 'admin']
|
13
|
+
@auth.provided? && @auth.basic? && @auth.credentials && (@auth.credentials == ['admin', 'admin'] || @auth.credentials == ['xanthomata.loosish@shazbot.invalid', 'super-super-super-super-super-super-dooper-secret'])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
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.3.
|
4
|
+
version: 0.3.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-
|
12
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-test
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- skink.gemspec
|
135
135
|
- spec/skink_dsl_spec.rb
|
136
136
|
- spec/spec_helper.rb
|
137
|
+
- spec/support/matchers/response_matchers.rb
|
137
138
|
- spec/test_server.rb
|
138
139
|
homepage: https://github.com/toddthomas/skink.git
|
139
140
|
licenses: []
|
@@ -162,4 +163,5 @@ summary: Skink is Capybara's smaller, more primitive companion.
|
|
162
163
|
test_files:
|
163
164
|
- spec/skink_dsl_spec.rb
|
164
165
|
- spec/spec_helper.rb
|
166
|
+
- spec/support/matchers/response_matchers.rb
|
165
167
|
- spec/test_server.rb
|