cucumber-http 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 59c38771ab6ab918565cef8d236428c1454fd342
4
- data.tar.gz: 80b809a9b7f1ea12963cff9581e44263c133ac8a
3
+ metadata.gz: db09007776b7080549a13a86e301a75f4c979741
4
+ data.tar.gz: b7ef953e7f55853ad877f4a5f7cdada6327c101c
5
5
  SHA512:
6
- metadata.gz: 10cb64500e459962ab3e75826e49a159bfe99e9bfce85214ba4220f4405f37368575d95548ab34f8f9716184feb6e380c28850ad004c618bc927f6f79dd24140
7
- data.tar.gz: 88f97fa87c0031c282fd5a22b69234a663c39a22aa5804eb1ef46b8f9c7e47fb51100b0ceee13763086067e1f65623eaa7c91c1259f0566bccbd4cc39d01367a
6
+ metadata.gz: a5a566e3103706625fc736859a05af63f97dd709c7c90c955d4ba5aa6080c664e2277f2dea1f6eb2f37c87967c7496c59d07b995ee45f968ff00753ef2b038c2
7
+ data.tar.gz: f8aaa79b60e1eb017faceb048c79a404e0441dace6d62c802dbc69026f9312a5640d575e30b8924699cce030cc20b650d278b07411b9ef0e92b622f387e6a50e
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Cucumber::Http
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cucumber/http`.
3
+ This library provides Cucumber steps to test JSON HTTP API's. The
4
+ steps are rather verbose (technical) in nature, somewhat contrary to the
5
+ Cucumber philosophy of high-level, descriptive tests. This is intentional as
6
+ it allows these steps to be bundled in larger, more high-level tests by
7
+ non-developers.
4
8
 
5
9
  ## Installation
6
10
 
@@ -20,6 +24,136 @@ Or install it yourself as:
20
24
 
21
25
  ## Usage
22
26
 
27
+ ### Bundled steps
28
+
29
+ #### Examples
30
+
31
+ Examples for testing the [REST API](https://apidoc.uitdatabank.be) of
32
+ [UiTDatabank](https://www.uitdatabank.be):
33
+
34
+ ```ruby
35
+ @api @labels
36
+ Feature: Test the UDB3 labels API
37
+
38
+ Background:
39
+ Given I am using the UDB3 development environment
40
+ And I am authorized as user "centraal_beheerder"
41
+ And I send and accept JSON
42
+
43
+ @labelcreate
44
+ Scenario: Create label
45
+ When I create a label with a random name of 10 characters
46
+ And I keep the value of the JSON response at "uuid" as "uuid"
47
+ And I send a GET request to "/labels/%{uuid}"
48
+ Then the response status should be "200"
49
+ And the JSON response at "visibility" should be "visible"
50
+ And the JSON response at "privacy" should be "public"
51
+ ```
52
+
53
+ #### Benchmarking
54
+
55
+ ```ruby
56
+ Given /^I am benchmarking$/
57
+ ```
58
+
59
+ ```ruby
60
+ Then /^the elapsed time should be less than (#{CAPTURE_FLOAT}) seconds?$/
61
+ ```
62
+
63
+ #### HTTP
64
+
65
+ ```ruby
66
+ Given /^I set headers?:$/
67
+ ```
68
+
69
+ ```ruby
70
+ Given /^I send "(.*?)" and accept (XML|JSON)$/
71
+ ```
72
+
73
+ ```ruby
74
+ Given /^I send and accept (XML|JSON)$/
75
+ ```
76
+
77
+ ```ruby
78
+ Given /^I set the JSON request payload to:$/
79
+ ```
80
+
81
+ ```ruby
82
+ Given /^I set the JSON request payload from "(.*?)"$/
83
+ ```
84
+
85
+ ```ruby
86
+ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with parameters?:)?$/
87
+ ```
88
+
89
+ ```ruby
90
+ Then /^the response status should( not)? be "(#{CAPTURE_INTEGER})"$/
91
+ ```
92
+
93
+ ```ruby
94
+ Then /^the response body should be valid (XML|JSON)$/
95
+ ```
96
+
97
+ #### Debugging
98
+
99
+ ```ruby
100
+ Then /^show me the( unparsed)? response$/
101
+ ```
102
+
103
+ ```ruby
104
+ Then /^show me the kept values?$/
105
+ ```
106
+
107
+ #### JSON (through JsonSpec)
108
+
109
+ These steps are documented in the [json_spec README](https://github.com/collectiveidea/json_spec#cucumber)
110
+
111
+ ### Making larger, more descriptive tests
112
+
113
+ The steps in this library are overly technical for use in Cucumber as a communication
114
+ tool between developers and business people. They are meant to be encapsulated in
115
+ larger, more general steps through the use of the `steps` method in Cucumber.
116
+
117
+ This allows easier reuse of code and the ability for non-developers to write
118
+ requirements.
119
+
120
+ Examples for testing the [REST API](https://apidoc.uitdatabank.be) of
121
+ [UiTDatabank](https://www.uitdatabank.be):
122
+
123
+ Creating an organizer with a random name:
124
+ ```ruby
125
+ When /^I(?: have)? created? an organizer with a random name of (#{CAPTURE_INTEGER}) characters?$/ do |characters|
126
+ name = Faker::Lorem.characters(characters)
127
+ steps %Q{
128
+ Given I am using the UDB3 development environment
129
+ And I am authorized as user "centraal_beheerder"
130
+ And I send and accept JSON
131
+ When I set the JSON request payload to:
132
+ """
133
+ {"mainLanguage":"nl","website":"https://www.#{name}.be","name":"#{name}","contact":[]}
134
+ """
135
+ And I send a POST request to "/organizers/"
136
+ }
137
+ end
138
+ ```
139
+
140
+ Creating a role with a random name:
141
+ ```ruby
142
+ When /^I(?: have)? created? a role with a random name of (#{CAPTURE_INTEGER}) characters?$/ do |characters|
143
+ name = Faker::Lorem.characters(characters)
144
+ steps %Q{
145
+ Given I am using the UDB3 development environment
146
+ And I am authorized as user "centraal_beheerder"
147
+ And I send and accept JSON
148
+ When I set the JSON request payload to:
149
+ """
150
+ { "name": "#{name}" }
151
+ """
152
+ And I send a POST request to "/roles/"
153
+ }
154
+ end
155
+ ```
156
+
23
157
  ## Development
24
158
 
25
159
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -44,7 +44,7 @@ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with paramet
44
44
  endpoint = resolve(args.shift)
45
45
  params = args.shift
46
46
 
47
- request_url = URI.join(url, endpoint).to_s
47
+ request_url = URI.join(url, URI::encode(endpoint)).to_s
48
48
 
49
49
  unless params.nil?
50
50
  if params.class == Cucumber::MultilineArgument::DataTable
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module Http
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -1,10 +1,10 @@
1
1
  require_relative 'world_extensions/json_spec_interface'
2
- require_relative 'world_extensions/url'
3
2
  require_relative 'world_extensions/headers'
4
3
  require_relative 'world_extensions/parameters'
5
4
  require_relative 'world_extensions/payload'
6
5
  require_relative 'world_extensions/request'
7
6
  require_relative 'world_extensions/response'
7
+ require_relative 'world_extensions/url'
8
8
 
9
9
  World(JsonSpecInterface)
10
10
  World(Cucumber::Http::Headers)
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristof Willaert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.4.5
154
+ rubygems_version: 2.5.2.3
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Cucumber steps to easily test XML and JSON APIs