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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97cf04ba5915fa17f53a43afcb812e6c5e9ae1d8
4
- data.tar.gz: 49ee7a85bf7bcf1b5aee73287f76878ed2367265
3
+ metadata.gz: 8553f1623dd4e26049dc0e14ae65b494c064caf6
4
+ data.tar.gz: 5fb2936217eb9ff0d1995bfcfea4d116f314368d
5
5
  SHA512:
6
- metadata.gz: fc57309d70146736269128da65a11f1e125c5cc82701c5d9a28befa9209d96ef1b6ad9870a116a85f7a17593f3e0c7b70bdb995c35b505d7510f529e43e12c58
7
- data.tar.gz: 28fcbb6ac2a71c5d53a676f42f2514b1d414c0b7966007e8fce2d7426b60ad0ec69eddd6bfea1b8b5da621d39e8919567fea0ee98c44d8fd43ae319de4652814
6
+ metadata.gz: 146024a59872bd446bcb423fb78e1d5a06f4a9ad3a92d43d4537cb957ccfd4bfd08fb6726fafa65816ad9202645961d2e6b21a29b7c4be4083fe2a2d04d7a38a
7
+ data.tar.gz: 8a6a2c924ce5d37919366e36ec149718e4f802377f5e2f378b928fa3826eb24321f16757497a102b872f7635b49150f04153dba44ba7060824bd44f02204fc56
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'watir'
27
27
  spec.add_dependency 'rspec'
28
28
  spec.add_dependency 'cucumber'
29
+ spec.add_dependency 'faraday'
29
30
 
30
31
  end
@@ -3,6 +3,7 @@ module CucumberSteps
3
3
  require 'cucumber'
4
4
  # require 'cucumber/rb_support/rb_dsl'
5
5
 
6
+ require 'cucumber_steps/rest'
6
7
  require 'cucumber_steps/browser'
7
8
  require 'cucumber_steps/env_fetcher'
8
9
  require 'cucumber_steps/world_extensions'
@@ -1,4 +1,5 @@
1
1
  require 'cucumber_steps'
2
2
 
3
3
  require 'cucumber_steps/declarations/debug_steps' if CucumberSteps::ENVFetcher.development?
4
+ require 'cucumber_steps/declarations/rest_steps'
4
5
  require 'cucumber_steps/declarations/browser_steps'
@@ -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
@@ -1,3 +1,4 @@
1
1
  module CucumberSteps::WorldExtensions
2
2
  require 'cucumber_steps/world_extensions/browser_methods'
3
+ require 'cucumber_steps/world_extensions/rest_methods'
3
4
  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.5
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-05 00:00:00.000000000 Z
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