cucumber_steps 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/cucumber_steps.gemspec +1 -0
- data/lib/cucumber_steps.rb +1 -0
- data/lib/cucumber_steps/declarations.rb +1 -0
- data/lib/cucumber_steps/declarations/rest_steps.rb +25 -0
- data/lib/cucumber_steps/rest.rb +18 -0
- data/lib/cucumber_steps/world_extensions.rb +1 -0
- data/lib/cucumber_steps/world_extensions/rest_methods.rb +25 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8553f1623dd4e26049dc0e14ae65b494c064caf6
|
4
|
+
data.tar.gz: 5fb2936217eb9ff0d1995bfcfea4d116f314368d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 146024a59872bd446bcb423fb78e1d5a06f4a9ad3a92d43d4537cb957ccfd4bfd08fb6726fafa65816ad9202645961d2e6b21a29b7c4be4083fe2a2d04d7a38a
|
7
|
+
data.tar.gz: 8a6a2c924ce5d37919366e36ec149718e4f802377f5e2f378b928fa3826eb24321f16757497a102b872f7635b49150f04153dba44ba7060824bd44f02204fc56
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/cucumber_steps.gemspec
CHANGED
data/lib/cucumber_steps.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'cucumber_steps/rest'
|
2
|
+
|
3
|
+
World(CucumberSteps::WorldExtensions::RestMethods)
|
4
|
+
|
5
|
+
And(/I send a "(\w+)" request to: *(.+)/) do |http_method,url|
|
6
|
+
rest_call(http_method,url,{},{})
|
7
|
+
end
|
8
|
+
|
9
|
+
And(/the rest response body is:/) do |expected_response_body|
|
10
|
+
expect(last_response.body).to eq expected_response_body
|
11
|
+
end
|
12
|
+
|
13
|
+
And(/the rest response body should match: \/(.*)\/$/) do |expected_response_body_regexp|
|
14
|
+
expect(last_response.body).to match(Regexp.new(expected_response_body_regexp))
|
15
|
+
end
|
16
|
+
|
17
|
+
And(/the rest response status code is: (\d+)/) do |http_status_code|
|
18
|
+
expect(last_response.status).to eq http_status_code.to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
And(/the rest response has the following headers:/) do |table|
|
22
|
+
table.transpose.hashes.first.each do |header_key,expected_value|
|
23
|
+
expect(last_response.headers[header_key]).to eq expected_value
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'forwardable'
|
3
|
+
class CucumberSteps::REST
|
4
|
+
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@connection, :get, :post, :put, :delete
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def initialize(*middlewares)
|
12
|
+
@connection = Faraday.new do |b|
|
13
|
+
middlewares.each { |prop| b.use(prop[:class],*prop[:args],&prop[:block]) }
|
14
|
+
b.adapter Faraday.default_adapter
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CucumberSteps::WorldExtensions::RestMethods
|
2
|
+
|
3
|
+
attr_reader :last_response
|
4
|
+
|
5
|
+
def rest_call(http_method, url, params, headers)
|
6
|
+
@last_response = rest_client.public_send(http_method.to_s.downcase) do |request|
|
7
|
+
request.url(url)
|
8
|
+
request.params.replace params
|
9
|
+
request.headers.replace headers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def rest_client
|
14
|
+
CucumberSteps::REST.new(*rest_middlewares)
|
15
|
+
end
|
16
|
+
|
17
|
+
def use_faraday_middleware(middleware_class, *args, &block)
|
18
|
+
rest_middlewares << {class: middleware_class, args: args, block: block}
|
19
|
+
end
|
20
|
+
|
21
|
+
def rest_middlewares
|
22
|
+
@rest_middlewares ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_steps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: collection of often used cucumber steps to avoid the violation of DRY
|
84
98
|
principle
|
85
99
|
email:
|
@@ -110,9 +124,12 @@ files:
|
|
110
124
|
- lib/cucumber_steps/declarations/browser_steps/typing_steps.rb
|
111
125
|
- lib/cucumber_steps/declarations/browser_steps/visit_steps.rb
|
112
126
|
- lib/cucumber_steps/declarations/debug_steps.rb
|
127
|
+
- lib/cucumber_steps/declarations/rest_steps.rb
|
113
128
|
- lib/cucumber_steps/env_fetcher.rb
|
129
|
+
- lib/cucumber_steps/rest.rb
|
114
130
|
- lib/cucumber_steps/world_extensions.rb
|
115
131
|
- lib/cucumber_steps/world_extensions/browser_methods.rb
|
132
|
+
- lib/cucumber_steps/world_extensions/rest_methods.rb
|
116
133
|
homepage: ''
|
117
134
|
licenses:
|
118
135
|
- MIT
|