cucumber-blendle-steps 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/lib/cucumber/blendle/steps/model_steps.rb +1 -1
- data/lib/cucumber/blendle/steps/resource_steps.rb +18 -14
- data/lib/cucumber/blendle/steps/rest_steps.rb +12 -11
- data/lib/cucumber/blendle/support/dump.rb +2 -1
- data/lib/cucumber/blendle/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6d5ffa7f19cddc960b90cac8c998474b5a5ccd6
|
4
|
+
data.tar.gz: 122ffdf9b1241377caf69eb0133fe12109136642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da27cd9b9b98aea2a01f4833bf55771384ccab21e0f25dd1e37e6d52679b5f73e34bdff08fa415ece2279113f6d014835215f6d3ffb654ca550a7f0760e47ab9
|
7
|
+
data.tar.gz: e56a137ea2d9b66cfafde4f44d975a2a4157afdfb342fa8166194ae4a2c148d84ea721640d6209b0192b1a3376907327d60ce492af2f460b30d88411ce301ff9
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## [v0.8.2](https://github.com/blendle/cucumber-blendle-steps/tree/v0.8.2) (2016-04-28)
|
4
|
+
[Full Changelog](https://github.com/blendle/cucumber-blendle-steps/compare/v0.8.1...v0.8.2)
|
5
|
+
|
3
6
|
## [v0.8.1](https://github.com/blendle/cucumber-blendle-steps/tree/v0.8.1) (2016-04-26)
|
4
7
|
[Full Changelog](https://github.com/blendle/cucumber-blendle-steps/compare/v0.8.0...v0.8.1)
|
5
8
|
|
@@ -136,7 +136,7 @@ end
|
|
136
136
|
def row_finder(klass, hash)
|
137
137
|
ext = 'where'
|
138
138
|
query = hash.each_with_object({}) do |(key, value), q|
|
139
|
-
if value.is_a?(Sequel::Postgres::JSONBHash)
|
139
|
+
if defined?(Sequel::Postgres) && value.is_a?(Sequel::Postgres::JSONBHash)
|
140
140
|
ext = "where { Sequel.pg_jsonb(:#{key}).contains(#{value}) }"
|
141
141
|
else
|
142
142
|
q[key] = value
|
@@ -21,20 +21,11 @@ end
|
|
21
21
|
#
|
22
22
|
When(/^the client does a (GET|POST|DELETE) request to the "([^"]*)" resource with these template variables:$/) do |method, resource, table|
|
23
23
|
params = {}
|
24
|
-
current_accept_header = current_session.instance_variable_get(:@headers)['Accept']
|
25
|
-
|
26
|
-
step %(the client provides the header "Accept: application/hal+json")
|
27
|
-
body = JSON.parse(get('/api').body)
|
28
|
-
|
29
|
-
if current_accept_header
|
30
|
-
step %(the client provides the header "Accept: #{current_accept_header}")
|
31
|
-
end
|
32
|
-
|
33
24
|
table && table.hashes.each do |row|
|
34
25
|
params[row['key']] = row['value']
|
35
26
|
end
|
36
27
|
|
37
|
-
api = HyperResource.from_body(
|
28
|
+
api = HyperResource.from_body(api_body)
|
38
29
|
url = api.send(resource, params).href
|
39
30
|
step %(the client does a #{method} request to "#{url}")
|
40
31
|
end
|
@@ -48,8 +39,7 @@ end
|
|
48
39
|
# """
|
49
40
|
#
|
50
41
|
When(/^the client does a (GET|POST|DELETE) request to the "([^"]*)" resource with the following content:$/) do |method, resource, content|
|
51
|
-
|
52
|
-
api = HyperResource.from_body(body)
|
42
|
+
api = HyperResource.from_body(api_body)
|
53
43
|
url = api.send(resource, {}).href
|
54
44
|
|
55
45
|
step %(the client does a #{method} request to "#{url}" with the following content:), content
|
@@ -63,9 +53,23 @@ end
|
|
63
53
|
# """
|
64
54
|
#
|
65
55
|
When(/^the client does a (POST|PUT) request to the "([^"]*)" resource with the template variable "([^"]*)" set to "([^"]*)" and the following content:$/) do |method, resource, key, value, content|
|
66
|
-
|
67
|
-
api = HyperResource.from_body(body)
|
56
|
+
api = HyperResource.from_body(api_body)
|
68
57
|
url = api.send(resource, key => value).href
|
69
58
|
|
70
59
|
step %(the client does a #{method} request to "#{url}" with the following content:), content
|
71
60
|
end
|
61
|
+
|
62
|
+
def api_body
|
63
|
+
current_accept_header = current_session.instance_variable_get(:@headers)['Accept']
|
64
|
+
|
65
|
+
step %(the client provides the header "Accept: application/hal+json")
|
66
|
+
body = JSON.parse(get('/api').body)
|
67
|
+
|
68
|
+
if current_accept_header
|
69
|
+
step %(the client provides the header "Accept: #{current_accept_header}")
|
70
|
+
else
|
71
|
+
header('Accept', nil)
|
72
|
+
end
|
73
|
+
|
74
|
+
body
|
75
|
+
end
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
# * Then the response should contain the header "Location" with value "https://example.org/item/hello"
|
46
46
|
#
|
47
47
|
Then(/^the response should contain the header "([^"]*)" with value "([^"]*)"$/) do |header, value|
|
48
|
-
assert_equal last_response.headers[header]
|
48
|
+
assert_equal value, last_response.headers[header]
|
49
49
|
end
|
50
50
|
|
51
51
|
# * Then the response should be of type "application/json" with content:
|
@@ -58,8 +58,15 @@ end
|
|
58
58
|
Then(/^the response should be of type "([^"]*)" with content:$/) do |content_type, content|
|
59
59
|
dump last_response.body
|
60
60
|
|
61
|
+
content = Liquid::Template.parse(content).render
|
62
|
+
|
61
63
|
assert_equal content_type, last_response.headers['Content-Type']
|
62
|
-
|
64
|
+
|
65
|
+
if content_type.include?('json')
|
66
|
+
expect(last_response.body).to be_json_eql(content)
|
67
|
+
else
|
68
|
+
assert_equal content, last_response.body
|
69
|
+
end
|
63
70
|
end
|
64
71
|
|
65
72
|
# * Then the response should be JSON:
|
@@ -68,13 +75,8 @@ end
|
|
68
75
|
# "uid": "hello"
|
69
76
|
# }
|
70
77
|
# """
|
71
|
-
Then(/^the response should be JSON:$/) do |
|
72
|
-
|
73
|
-
|
74
|
-
json = Liquid::Template.parse(json).render
|
75
|
-
|
76
|
-
assert_equal last_response.headers['Content-Type'], 'application/json'
|
77
|
-
expect(last_response.body).to be_json_eql(json)
|
78
|
+
Then(/^the response should be JSON:$/) do |content|
|
79
|
+
step 'the response should be of type "application/json" with content:', content
|
78
80
|
end
|
79
81
|
|
80
82
|
# * Then the response should be HAL/JSON:
|
@@ -108,8 +110,6 @@ Then(%r{^the response should be HAL/JSON(?: \(disregarding values? of "([^"]*)"\
|
|
108
110
|
assert false, [e.message, last_response.body].join("\n")
|
109
111
|
end
|
110
112
|
|
111
|
-
assert hal.valid?, "Halidator errors: #{hal.errors.join(',')}"
|
112
|
-
|
113
113
|
json = Liquid::Template.parse(json).render
|
114
114
|
match = be_json_eql(json)
|
115
115
|
|
@@ -120,6 +120,7 @@ Then(%r{^the response should be HAL/JSON(?: \(disregarding values? of "([^"]*)"\
|
|
120
120
|
end
|
121
121
|
|
122
122
|
expect(last_response.body).to match
|
123
|
+
assert hal.valid?, "Halidator errors: #{hal.errors.join(',')}"
|
123
124
|
end
|
124
125
|
|
125
126
|
# * Then the response contains the "Location" header with value "https://example.org/item/hello"
|
@@ -45,8 +45,9 @@ def prettify_hash(hash)
|
|
45
45
|
|
46
46
|
hash = unshift_hash_key('_embedded', hash)
|
47
47
|
hash = unshift_hash_key('_links', hash)
|
48
|
+
hash['_links'] = unshift_hash_key('self', hash['_links']) if hash['_links']
|
48
49
|
|
49
|
-
hash
|
50
|
+
hash.sort.to_h
|
50
51
|
end
|
51
52
|
|
52
53
|
def unshift_hash_key(key, hash)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-blendle-steps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Mertz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- ".gitignore"
|
315
315
|
- ".hubbit.yml"
|
316
316
|
- ".rubocop.yml"
|
317
|
+
- ".ruby-version"
|
317
318
|
- ".wercker.yml"
|
318
319
|
- CHANGELOG.md
|
319
320
|
- Gemfile
|