skink 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 941fa126a27124a0c69684155e7b5482b0188cdb
4
+ data.tar.gz: ca72b6a3d47a69f8d0b435600655f10ffe2a5e79
5
+ SHA512:
6
+ metadata.gz: 7430e23e6475b2059b720e6d5815e083b62e30d0ee2d668dc61ab86f959da4726555e2419ae1059ec7b07c75f9c53bbe5ae835c267d518d59643ef89e31d3173
7
+ data.tar.gz: 277dd7fcb03156e969c3011acfcb314af21799410d83abd815428b97f836fece8749de1b9ab4c0bd9bb2c287f455df49617ae8c3753e7ada2b4b39c63297eb69
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.2"
4
- - "1.9.3"
5
- - "2.0.0"
6
- - rbx-19mode
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - jruby-19mode
8
+ - rbx-2.2.1
@@ -2,6 +2,8 @@ require 'skink/client/utils'
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'jsonpath'
5
+ require 'link_header'
6
+ require 'hash_deep_merge'
5
7
 
6
8
  module Skink
7
9
  module Client
@@ -82,6 +84,31 @@ class Response
82
84
  elems.any?(&block)
83
85
  end
84
86
 
87
+ def link_header
88
+ raise NotImplementedError
89
+ end
90
+
91
+ def links
92
+ if link_header
93
+ LinkHeader.parse(link_header).to_a.map do |linkarr|
94
+ {url: linkarr[0]}.merge Hash[linkarr[1]]
95
+ end
96
+ end
97
+ end
98
+
99
+ # example match keys for the link header:
100
+ # :url => "http://example.com",
101
+ # :rel => "search"
102
+ def has_link_header?(opts=nil)
103
+ if opts.nil?
104
+ links.any?
105
+ else
106
+ links.any? do |link|
107
+ link == link.deep_merge(opts)
108
+ end
109
+ end
110
+ end
111
+
85
112
  def method_missing(name, *args)
86
113
  if name.match(/has_(\w+)_header\?/)
87
114
  headers[normalize_header_name($1)] === args.first
@@ -25,6 +25,10 @@ class RackTestResponse < Client::Response
25
25
  end
26
26
  end
27
27
 
28
+ def link_header
29
+ headers["Link"]
30
+ end
31
+
28
32
  def body
29
33
  native_response.body
30
34
  end
@@ -21,6 +21,10 @@ class ResourcefulResponse < Client::Response
21
21
  native_response.headers.to_hash
22
22
  end
23
23
 
24
+ def link_header
25
+ headers['Link'].join(',')
26
+ end
27
+
24
28
  def body
25
29
  native_response.body || ""
26
30
  end
data/lib/skink/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skink
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
data/skink.gemspec CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.add_dependency "openlogic-resourceful"
17
17
  gem.add_dependency "nokogiri"
18
18
  gem.add_dependency "jsonpath"
19
+ gem.add_dependency "hash-deep-merge"
20
+ gem.add_dependency "link_header"
19
21
 
20
22
  gem.add_development_dependency "rspec"
21
23
  gem.add_development_dependency "sinatra"
@@ -77,6 +77,9 @@ shared_examples "a REST API test language" do
77
77
  response.should have_header(:content_type)
78
78
  response.should have_header("Content-Type")
79
79
  response.should_not have_header("This-Is-Not-A-Header-Name")
80
+
81
+ response.should have_link_header
82
+ response.should have_link_header({url: 'http://link.example.com'})
80
83
  end
81
84
 
82
85
  it "has a helpful failure message for have_header" do
@@ -95,6 +98,7 @@ shared_examples "a REST API test language" do
95
98
  response.should_not have_header(content_type: %r{json})
96
99
  end
97
100
 
101
+
98
102
  it "is able to test for content in the response body" do
99
103
  get "/"
100
104
  response.should have_content "Hello, world!"
@@ -37,6 +37,30 @@ RSpec::Matchers.define :have_header do |expected|
37
37
  end
38
38
  end
39
39
 
40
+ RSpec::Matchers.define :have_link_header do |expected|
41
+ match do |response|
42
+ response.has_link_header? expected
43
+ end
44
+
45
+ failure_message_for_should do |response|
46
+ if expected.respond_to? :keys
47
+ "expected response headers #{response.headers.inspect} to have link header header #{normalize_header_name(expected.keys.first)} matching #{expected.values.first.inspect}"
48
+ else
49
+ "expected response headers #{response.headers.inspect} to have header #{normalize_header_name(expected)}"
50
+ end
51
+ end
52
+
53
+ failure_message_for_should_not do |response|
54
+ if expected.respond_to? :keys
55
+ "expected response headers #{response.headers.inspect} to not have link header #{normalize_header_name(expected.keys.first)} matching #{expected.values.first.inspect}"
56
+ else
57
+ "expected response headers #{response.headers.inspect} to not have link header #{normalize_header_name(expected)}"
58
+ end
59
+ end
60
+ end
61
+
62
+
63
+
40
64
  RSpec::Matchers.define :have_content do |expected|
41
65
  match do |response|
42
66
  expected === response.body
data/spec/test_server.rb CHANGED
@@ -69,5 +69,6 @@ get '/xml_doc_with_pathological_namespaces', :provides => :xml do
69
69
  end
70
70
 
71
71
  get '/json_doc', :provides => :json do
72
+ response.headers["Link"] = "<http://link.example.com>; rel=\"search\""
72
73
  '{"root": {"foo": {"foo": "howdy"}}}'
73
74
  end
metadata CHANGED
@@ -1,128 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Todd Thomas
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-05 00:00:00.000000000 Z
11
+ date: 2013-12-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack-test
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
16
20
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
21
  requirements:
19
- - - ! '>='
22
+ - - '>='
20
23
  - !ruby/object:Gem::Version
21
24
  version: '0'
22
- type: :runtime
23
25
  prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: openlogic-resourceful
24
29
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
30
  requirements:
27
- - - ! '>='
31
+ - - '>='
28
32
  - !ruby/object:Gem::Version
29
33
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: openlogic-resourceful
32
34
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
35
  requirements:
35
- - - ! '>='
36
+ - - '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: '0'
38
- type: :runtime
39
39
  prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
40
43
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
44
  requirements:
43
- - - ! '>='
45
+ - - '>='
44
46
  - !ruby/object:Gem::Version
45
47
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: nokogiri
48
48
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
49
  requirements:
51
- - - ! '>='
50
+ - - '>='
52
51
  - !ruby/object:Gem::Version
53
52
  version: '0'
54
- type: :runtime
55
53
  prerelease: false
54
+ type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: jsonpath
56
57
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: jsonpath
64
62
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
63
  requirements:
67
- - - ! '>='
64
+ - - '>='
68
65
  - !ruby/object:Gem::Version
69
66
  version: '0'
70
- type: :runtime
71
67
  prerelease: false
68
+ type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ name: hash-deep-merge
72
71
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
72
  requirements:
75
- - - ! '>='
73
+ - - '>='
76
74
  - !ruby/object:Gem::Version
77
75
  version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: rspec
80
76
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
77
  requirements:
83
- - - ! '>='
78
+ - - '>='
84
79
  - !ruby/object:Gem::Version
85
80
  version: '0'
86
- type: :development
87
81
  prerelease: false
82
+ type: :runtime
83
+ - !ruby/object:Gem::Dependency
84
+ name: link_header
88
85
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
86
  requirements:
91
- - - ! '>='
87
+ - - '>='
92
88
  - !ruby/object:Gem::Version
93
89
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: sinatra
96
90
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
91
  requirements:
99
- - - ! '>='
92
+ - - '>='
100
93
  - !ruby/object:Gem::Version
101
94
  version: '0'
102
- type: :development
103
95
  prerelease: false
96
+ type: :runtime
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
104
99
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
100
  requirements:
107
- - - ! '>='
101
+ - - '>='
108
102
  - !ruby/object:Gem::Version
109
103
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: rake
112
104
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
105
  requirements:
115
- - - ! '>='
106
+ - - '>='
116
107
  - !ruby/object:Gem::Version
117
108
  version: '0'
109
+ prerelease: false
118
110
  type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: sinatra
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
119
123
  prerelease: false
124
+ type: :development
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
120
127
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
128
  requirements:
123
- - - ! '>='
129
+ - - '>='
124
130
  - !ruby/object:Gem::Version
125
131
  version: '0'
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ prerelease: false
138
+ type: :development
126
139
  description: A Ruby DSL for testing REST APIs.
127
140
  email:
128
141
  - todd.thomas@openlogic.com
@@ -155,33 +168,26 @@ files:
155
168
  - spec/test_server.rb
156
169
  homepage: https://github.com/toddthomas/skink.git
157
170
  licenses: []
158
- post_install_message:
171
+ metadata: {}
172
+ post_install_message:
159
173
  rdoc_options: []
160
174
  require_paths:
161
175
  - lib
162
176
  required_ruby_version: !ruby/object:Gem::Requirement
163
- none: false
164
177
  requirements:
165
- - - ! '>='
178
+ - - '>='
166
179
  - !ruby/object:Gem::Version
167
180
  version: '0'
168
- segments:
169
- - 0
170
- hash: -875101598988712592
171
181
  required_rubygems_version: !ruby/object:Gem::Requirement
172
- none: false
173
182
  requirements:
174
- - - ! '>='
183
+ - - '>='
175
184
  - !ruby/object:Gem::Version
176
185
  version: '0'
177
- segments:
178
- - 0
179
- hash: -875101598988712592
180
186
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 1.8.25
183
- signing_key:
184
- specification_version: 3
187
+ rubyforge_project:
188
+ rubygems_version: 2.1.9
189
+ signing_key:
190
+ specification_version: 4
185
191
  summary: Skink is Capybara's smaller, more primitive companion.
186
192
  test_files:
187
193
  - spec/skink_dsl_spec.rb