cucumber-http 0.3.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7707172531d26bbfdc20747882134db3cf009569dcbbd9da1340113a4026a77c
4
- data.tar.gz: becc331dfcbf82ef2ad9059561023639b43e4fe4ecba6ce9692bd12720114c04
3
+ metadata.gz: c75c0db8674ba9d8fd6b0cf5c1d9c7f8f8854f37a800dad01fe8d43b744beecf
4
+ data.tar.gz: f8e1726ef35a5148f3327b94a8633b670dca929cf6dfc6193827c2a38df3f0c2
5
5
  SHA512:
6
- metadata.gz: '098aa6a7e5cf4474b398672d558de96533978feada030b11abf8625737d0294173e9cb15825741dbb54b0a9aa8480cecaa4a7f75c771f2a3be172eb0372be1bb'
7
- data.tar.gz: 161dded2bd5230f25ab53f6655856c31be169f761a05cd8cd830fdc5656d4b9fcce5586dae742cf1347c65ddec80e9fb6a313c8ad10705652e6b8769eb27fb05
6
+ metadata.gz: 605f04856f7872c474d30fc030cb0686bce7f7a7a2dc15e94e0f3c9c2905e6a891da62bad1d05df077ff380e66bdd66e375a85e9c981b3c2e71808891c886e28
7
+ data.tar.gz: 61770eb34b0b42d4835c7ed090e1811f5e8bae21718d7b17e474a9a64b63c18cd951bdd50ef153f09d057dc97c674884b87048c7db14995b5dd711f12cb6119c
data/README.md CHANGED
@@ -38,7 +38,7 @@ Feature: Test the UDB3 labels API
38
38
  Background:
39
39
  Given I am using the UDB3 development environment
40
40
  And I am authorized as user "centraal_beheerder"
41
- And I send and accept JSON
41
+ And I send "application/json" and accept "application/ld+json"
42
42
 
43
43
  @labelcreate
44
44
  Scenario: Create label
@@ -57,7 +57,7 @@ Given /^I am benchmarking$/
57
57
  ```
58
58
 
59
59
  ```ruby
60
- Then /^the elapsed time should be less than (#{CAPTURE_FLOAT}) seconds?$/
60
+ Then 'the elapsed time should be less than {float} second(s)'
61
61
  ```
62
62
 
63
63
  #### HTTP
@@ -67,11 +67,27 @@ Given /^I set headers?:$/
67
67
  ```
68
68
 
69
69
  ```ruby
70
- Given /^I send "(.*?)" and accept (XML|JSON)$/
70
+ Given /^I send "(.*?)"$/
71
71
  ```
72
72
 
73
73
  ```ruby
74
- Given /^I send and accept (XML|JSON)$/
74
+ Given /^I accept "(.*?)"$/
75
+ ```
76
+
77
+ ```ruby
78
+ Given /^I send and accept "(.*?)"$/
79
+ ```
80
+
81
+ ```ruby
82
+ Given /^I send "(.*?)" and accept "(.*?)"$/
83
+ ```
84
+
85
+ ```ruby
86
+ Given /^I send "(.*?)" and accept JSON$/
87
+ ```
88
+
89
+ ```ruby
90
+ Given /^I send and accept JSON$/
75
91
  ```
76
92
 
77
93
  ```ruby
@@ -87,11 +103,15 @@ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with paramet
87
103
  ```
88
104
 
89
105
  ```ruby
90
- Then /^the response status should( not)? be "(#{CAPTURE_INTEGER})"$/
106
+ Then 'the response status should be "{int}"'
107
+ ```
108
+
109
+ ```ruby
110
+ Then 'the response status should not be "{int}"'
91
111
  ```
92
112
 
93
113
  ```ruby
94
- Then /^the response body should be valid (XML|JSON)$/
114
+ Then /^the response body should be valid JSON$/
95
115
  ```
96
116
 
97
117
  #### Debugging
@@ -122,12 +142,12 @@ Examples for testing the [REST API](https://apidoc.uitdatabank.be) of
122
142
 
123
143
  Creating an organizer with a random name:
124
144
  ```ruby
125
- When /^I create an organizer with a random name of (#{CAPTURE_INTEGER}) characters?$/ do |characters|
145
+ When 'I create an organizer with a random name of {integer} character(s)' do |characters|
126
146
  name = Faker::Lorem.characters(characters)
127
147
  steps %Q{
128
148
  Given I am using the UDB3 development environment
129
149
  And I am authorized as user "centraal_beheerder"
130
- And I send and accept JSON
150
+ And I send and accept "application/json"
131
151
  When I set the JSON request payload to:
132
152
  """
133
153
  {"mainLanguage":"nl","website":"https://www.#{name}.be","name":"#{name}","contact":[]}
@@ -139,12 +159,12 @@ end
139
159
 
140
160
  Creating a role with a random name:
141
161
  ```ruby
142
- When /^I create a role with a random name of (#{CAPTURE_INTEGER}) characters?$/ do |characters|
162
+ When 'I create a role with a random name of {integer} character(s)' do |characters|
143
163
  name = Faker::Lorem.characters(characters)
144
164
  steps %Q{
145
165
  Given I am using the UDB3 development environment
146
166
  And I am authorized as user "centraal_beheerder"
147
- And I send and accept JSON
167
+ And I send and accept "application/json"
148
168
  When I set the JSON request payload to:
149
169
  """
150
170
  { "name": "#{name}" }
@@ -2,7 +2,7 @@ Given /^I am benchmarking$/ do
2
2
  @scenario_start_time = Time.now
3
3
  end
4
4
 
5
- Then /^the elapsed time should be less than (#{CAPTURE_FLOAT}) seconds?$/ do |time|
5
+ Then 'the elapsed time should be less than {float} second(s)' do |time|
6
6
  elapsed = Time.now - @scenario_start_time
7
7
 
8
8
  expect(elapsed).to be < time
@@ -12,8 +12,6 @@ Then /^show me the( unparsed)? response$/ do |unparsed|
12
12
  if unparsed.nil?
13
13
  if response[:headers]['content-type'][0] =~ /json/
14
14
  body = JSON.pretty_generate(JSON.parse(response[:body]))
15
- elsif response[:headers]['content-type'][0] =~ /xml/
16
- body = Nokogiri::XML(response[:body])
17
15
  end
18
16
  end
19
17
 
@@ -1,23 +1,52 @@
1
- require 'nokogiri'
2
1
  require 'json_spec'
3
2
 
4
3
  Given /^I set headers?:$/ do |hdrs|
5
4
  hdrs.rows_hash.each { |name, value| add_header(name, value) }
6
5
  end
7
6
 
8
- Given /^I send "(.*?)" and accept (XML|JSON)$/ do |content_type, accept_type|
7
+ Given /^I send "(.*?)"$/ do |content_type|
9
8
  steps %Q{
10
9
  Given I set headers:
11
- | Content-Type | #{content_type} |
12
- | Accept | application/#{accept_type.downcase} |
10
+ | Content-Type | #{content_type} |
13
11
  }
14
12
  end
15
13
 
16
- Given /^I send and accept (XML|JSON)$/ do |type|
14
+ Given /^I accept "(.*?)"$/ do |accept_type|
17
15
  steps %Q{
18
16
  Given I set headers:
19
- | Content-Type | application/#{type.downcase} |
20
- | Accept | application/#{type.downcase} |
17
+ | Accept | #{accept_type} |
18
+ }
19
+ end
20
+
21
+ Given /^I send and accept "(.*?)"$/ do |type|
22
+ steps %Q{
23
+ Given I set headers:
24
+ | Content-Type | #{type} |
25
+ | Accept | #{type} |
26
+ }
27
+ end
28
+
29
+ Given /^I send "(.*?)" and accept "(.*?)"$/ do |content_type, accept_type|
30
+ steps %Q{
31
+ Given I set headers:
32
+ | Content-Type | #{content_type} |
33
+ | Accept | #{accept_type} |
34
+ }
35
+ end
36
+
37
+ Given /^I send "(.*?)" and accept JSON$/ do |content_type|
38
+ steps %Q{
39
+ Given I set headers:
40
+ | Content-Type | #{content_type} |
41
+ | Accept | application/json |
42
+ }
43
+ end
44
+
45
+ Given /^I send and accept JSON$/ do
46
+ steps %Q{
47
+ Given I set headers:
48
+ | Content-Type | application/json |
49
+ | Accept | application/json |
21
50
  }
22
51
  end
23
52
 
@@ -63,19 +92,14 @@ When /^(?:I )?keep the value of the (?:JSON|json)(?: response)?(?: at "(.*)")? a
63
92
  JsonSpec.memorize(key, parse_json(last_json, path))
64
93
  end
65
94
 
66
- Then /^the response status should( not)? be "(#{CAPTURE_INTEGER})"$/ do |negative, status_code|
67
- if negative
68
- expect(response[:status]).not_to eq(status_code)
69
- else
70
- expect(response[:status]).to eq(status_code)
71
- end
95
+ Then 'the response status should be "{int}"' do |status_code|
96
+ expect(response[:status]).to eq(status_code)
72
97
  end
73
98
 
74
- Then /^the response body should be valid (XML|JSON)$/ do |type|
75
- case type
76
- when 'XML'
77
- expect { Nokogiri::XML(response[:body]) { |config| config.strict } }.not_to raise_error
78
- when 'JSON'
79
- expect { JSON.parse(response[:body]) }.not_to raise_error
80
- end
99
+ Then 'the response status should not be "{int}"' do |status_code|
100
+ expect(response[:status]).not_to eq(status_code)
101
+ end
102
+
103
+ Then /^the response body should be valid JSON$/ do
104
+ expect { JSON.parse(response[:body]) }.not_to raise_error
81
105
  end
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module Http
3
- VERSION = "0.3.1"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
data/lib/cucumber/http.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'cucumber/http/transforms'
2
1
  require 'cucumber/http/world_extensions'
3
2
  require 'cucumber/http/hooks'
4
3
  require 'cucumber/http/http_steps'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristof Willaert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-30 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json_spec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: nokogiri
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.6'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.6'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: faker
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,14 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '10.0'
75
+ version: '13.0'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '10.0'
82
+ version: '13.0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundler
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +94,7 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '1.9'
111
- description: Cucumber steps to easily test external XML and JSON APIs
97
+ description: Cucumber steps to easily test external JSON APIs
112
98
  email:
113
99
  - kristof.willaert@publiq.be
114
100
  executables: []
@@ -121,7 +107,6 @@ files:
121
107
  - lib/cucumber/http/debug_steps.rb
122
108
  - lib/cucumber/http/hooks.rb
123
109
  - lib/cucumber/http/http_steps.rb
124
- - lib/cucumber/http/transforms.rb
125
110
  - lib/cucumber/http/version.rb
126
111
  - lib/cucumber/http/world_extensions.rb
127
112
  - lib/cucumber/http/world_extensions/headers.rb
@@ -153,5 +138,5 @@ requirements: []
153
138
  rubygems_version: 3.1.2
154
139
  signing_key:
155
140
  specification_version: 4
156
- summary: Cucumber steps to easily test XML and JSON APIs
141
+ summary: Cucumber steps to easily test JSON APIs
157
142
  test_files: []
@@ -1,7 +0,0 @@
1
- CAPTURE_INTEGER = Transform /^(-?\d+)$/ do |number_string|
2
- number_string.to_i
3
- end
4
-
5
- CAPTURE_FLOAT = Transform /^(-?[\d.]+)$/ do |number_string|
6
- number_string.to_f
7
- end