rspec-api-expectations 0.6.0 → 0.6.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b06298366cfee74998fe2fee930496c148614c7f
|
|
4
|
+
data.tar.gz: 040a5d68d965f08d32c1e69d5fe2a32f39a6362e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25e1c069bed1c139a6121b64d184025e2796eaf85f9f846fe27c7dcb1b05e6461e1afa5476bfc850877ee5edd4c7c5198f9ee512b3e64adbc7fe9f150b474762
|
|
7
|
+
data.tar.gz: b9f113795b80e41f9aa9b8e9d34e0f50fc0362c2629c3ede60827c00a29c802697d9553c0c4b47b02de039f730eb6c23e39b7edc2f0e5e3d583b1962256999f0
|
|
@@ -7,20 +7,20 @@ module RSpecApi
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
# RSpecApi::
|
|
10
|
+
# RSpecApi::Expectations provides the +expect_response+ method to test RESTful APIs.
|
|
11
11
|
#
|
|
12
|
-
# To have
|
|
12
|
+
# To have this method available inside of an RSpec `describe` block, tag that
|
|
13
13
|
# block with the `:rspec_api` metadata:
|
|
14
14
|
#
|
|
15
15
|
# describe "Artists", rspec_api: true do
|
|
16
|
-
# ... # here you can write `
|
|
16
|
+
# ... # here you can write `expect_response response, status: :ok, etc.
|
|
17
17
|
# end
|
|
18
18
|
RSpec.configuration.extend RSpecApi::Expectations, rspec_api: true
|
|
19
19
|
|
|
20
|
-
# You can also explicitly
|
|
20
|
+
# You can also explicitly extend the example group with RSpecApi::Expectations:
|
|
21
21
|
#
|
|
22
22
|
# describe "Artists" do
|
|
23
|
-
#
|
|
24
|
-
# ... # here you can write `
|
|
23
|
+
# extend RSpecApi::Expectations
|
|
24
|
+
# ... # here you can write `expect_response response, status: :ok, etc.
|
|
25
25
|
# end
|
|
26
26
|
#
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module RSpecApi
|
|
2
|
+
module Expectations
|
|
3
|
+
module Response
|
|
4
|
+
# Creates an example group for custom expectations passed in a block
|
|
5
|
+
module Custom
|
|
6
|
+
def expect_custom(response, prefix_params, &block)
|
|
7
|
+
context 'matches custom expectations' do
|
|
8
|
+
it { instance_exec response, prefix_params, &block }
|
|
9
|
+
end if block_given?
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -3,6 +3,7 @@ require 'rack/utils'
|
|
|
3
3
|
require 'rspec-api/expectations/status'
|
|
4
4
|
require 'rspec-api/expectations/headers'
|
|
5
5
|
require 'rspec-api/expectations/body'
|
|
6
|
+
require 'rspec-api/expectations/custom'
|
|
6
7
|
|
|
7
8
|
module RSpecApi
|
|
8
9
|
module Expectations
|
|
@@ -10,11 +11,13 @@ module RSpecApi
|
|
|
10
11
|
include Status
|
|
11
12
|
include Headers
|
|
12
13
|
include Body
|
|
14
|
+
include Custom
|
|
13
15
|
|
|
14
|
-
def expect_response(response, expectations)
|
|
16
|
+
def expect_response(response, expectations, prefix_params=nil, &block)
|
|
15
17
|
expect_status response, expectations.slice(*on_status)
|
|
16
18
|
expect_headers response, expectations.slice(*on_headers)
|
|
17
19
|
expect_body response, expectations.slice(*on_body)
|
|
20
|
+
expect_custom response, prefix_params, &block if block_given?
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
private
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-api-expectations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- claudiob
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-11-
|
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- lib/rspec-api/expectations/body/jsonp.rb
|
|
136
136
|
- lib/rspec-api/expectations/body/sort.rb
|
|
137
137
|
- lib/rspec-api/expectations/body.rb
|
|
138
|
+
- lib/rspec-api/expectations/custom.rb
|
|
138
139
|
- lib/rspec-api/expectations/headers/content_type.rb
|
|
139
140
|
- lib/rspec-api/expectations/headers/page_links.rb
|
|
140
141
|
- lib/rspec-api/expectations/headers.rb
|