cucoo 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dummy/app/controllers/api_controller.rb +4 -0
- data/lib/cucoo.rb +1 -2
- data/lib/cucoo/api_driver.rb +5 -1
- data/lib/cucoo/cucumber.rb +41 -22
- data/lib/cucoo/stub_helper.rb +2 -1
- data/lib/cucoo/version.rb +1 -1
- metadata +2 -3
- data/dummy/app/controllers/concerns/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb82dbc8f1556118844337c4f52609a94b65d1f1
|
4
|
+
data.tar.gz: 04ccfbe5038913241162768b1fd132deb2ab66c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3281c3d67e0530057ef4ea0a195cb260e531d264ac358ef3d573836658afa729169b79936653331d804180b5aba88b4b22f75d8b43b82f0544e684174b14db7
|
7
|
+
data.tar.gz: 4f16bb4ed141821e1740cc6b1a981fe7a22dc0cbf82ceaac36612bfa707a48f7c5969deffd37e79e15be7d07be9e5026e64768aa41299eb13f686db03978893a
|
data/lib/cucoo.rb
CHANGED
@@ -9,8 +9,7 @@ module Cucoo
|
|
9
9
|
|
10
10
|
def self.config
|
11
11
|
yield Config
|
12
|
-
WebMock.disable_net_connect!(
|
13
|
-
WebMock.allow_net_connect!(:net_http_connect_on_start => true)
|
12
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
14
13
|
end
|
15
14
|
|
16
15
|
end
|
data/lib/cucoo/api_driver.rb
CHANGED
@@ -9,6 +9,10 @@ module Cucoo
|
|
9
9
|
@response = self.class.post(url, {body: body})
|
10
10
|
end
|
11
11
|
|
12
|
+
def post_raw(url, body=nil)
|
13
|
+
@response = self.class.post(url, {body: body.to_json})
|
14
|
+
end
|
15
|
+
|
12
16
|
def post_with_header(url, headers = {}, body=nil)
|
13
17
|
@response = self.class.post(url, {body: body, headers: headers})
|
14
18
|
end
|
@@ -33,7 +37,7 @@ module Cucoo
|
|
33
37
|
class Driver
|
34
38
|
extend SingleForwardable
|
35
39
|
@api_driver = Cucoo::ApiDriver.new
|
36
|
-
def_delegators :@api_driver, :post, :put, :get, :delete, :response, :post_with_header
|
40
|
+
def_delegators :@api_driver, :post, :post_raw, :put, :get, :delete, :response, :post_with_header
|
37
41
|
end
|
38
42
|
|
39
43
|
end
|
data/lib/cucoo/cucumber.rb
CHANGED
@@ -4,90 +4,109 @@ def last_json
|
|
4
4
|
end
|
5
5
|
|
6
6
|
#API Steps
|
7
|
-
When
|
7
|
+
When(/^I make a POST to "([^"]*)" with:$/) do |url, params|
|
8
8
|
Cucoo::Driver.post url, params.hashes.first
|
9
9
|
end
|
10
10
|
|
11
|
-
When
|
11
|
+
When(/^I make a POST to "([^"]*)" with raw params:$/) do |url, params|
|
12
|
+
Cucoo::Driver.post_raw url, params.hashes.first
|
13
|
+
end
|
14
|
+
|
15
|
+
When(/^I make a POST to "([^"]*)"$/) do |url|
|
12
16
|
Cucoo::Driver.post url
|
13
17
|
end
|
14
18
|
|
15
|
-
When
|
19
|
+
When(/^I make a POST to "([^"]*)" with headers "([^"]*)" and the following params:$/) do |url, headers, params|
|
16
20
|
header, value = headers.split(':')
|
17
21
|
Cucoo::Driver.post_with_header url, {header => value, 'Content-type' => 'text/plain; charset=UTF-8'}, params.hashes.first.to_json
|
18
22
|
end
|
19
23
|
|
20
|
-
When
|
24
|
+
When(/^I make a GET to "([^"]*)"$/) do |url|
|
21
25
|
Cucoo::Driver.get url
|
22
26
|
end
|
23
27
|
|
24
|
-
When
|
28
|
+
When(/^I make a DELETE to "([^"]*)"$/) do |url|
|
25
29
|
Cucoo::Driver.delete url
|
26
30
|
end
|
27
31
|
|
28
|
-
When
|
32
|
+
When(/^I make a DELETE to "([^"]*)" with:$/) do |url, params|
|
29
33
|
Cucoo::Driver.delete url, params.hashes.first
|
30
34
|
end
|
31
35
|
|
32
|
-
And
|
36
|
+
And(/^the response error message should be "([^"]*)"$/) do |message|
|
33
37
|
expect(Cucoo::Driver.response['error']).to eq(message)
|
34
38
|
end
|
35
39
|
|
36
|
-
And
|
40
|
+
And(/^the response body must be "([^"]*)"$/) do |body|
|
37
41
|
expect(Cucoo::Driver.response.to_s).to eq(body)
|
38
42
|
end
|
39
43
|
|
40
|
-
When
|
44
|
+
When(/^I send a PUT request to "([^"]*)" with:$/) do |url, params|
|
41
45
|
Cucoo::Driver.put url, params.hashes.first
|
42
46
|
end
|
43
47
|
|
44
48
|
# Stub Steps
|
45
|
-
Given
|
49
|
+
Given(/^I expect a POST to "([^"]*)" with:$/) do |url, table|
|
46
50
|
params = table.hashes.first
|
47
51
|
stub_my_request(:post, url, params)
|
48
52
|
end
|
49
53
|
|
50
|
-
Given
|
54
|
+
Given(/^I expect a POST to "([^"]*)" with form params:$/) do |url, table|
|
55
|
+
params = table.hashes.first
|
56
|
+
stub_my_request(:post, url, params)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
Given(/^I expect a POST to "([^"]*)" with json request:$/) do |url, json|
|
51
61
|
stub_my_request(:post, url, {request: JSON.parse(json)})
|
52
62
|
end
|
53
63
|
|
54
|
-
Given
|
64
|
+
Given(/^I expect a PUT to "([^"]*)" with json request:$/) do |url, json|
|
55
65
|
stub_my_request(:put, url, {request: JSON.parse(json)})
|
56
66
|
end
|
57
67
|
|
58
|
-
|
68
|
+
Given(/^I expect a PUT to "([^"]*)" with:$/) do |url, table|
|
59
69
|
params = table.hashes.first
|
60
|
-
stub_my_request(:
|
70
|
+
stub_my_request(:put, url, params)
|
61
71
|
end
|
62
72
|
|
63
|
-
|
64
|
-
stub_my_request(:
|
73
|
+
Given(/^I expect a PUT to "([^"]*)"$/) do |url|
|
74
|
+
stub_my_request(:put, url)
|
75
|
+
end
|
76
|
+
|
77
|
+
And(/^I expect a GET to "([^"]*)" with:$/) do |url, table|
|
78
|
+
params = table.hashes.first
|
79
|
+
stub_my_request(:get, url, params)
|
65
80
|
end
|
66
81
|
|
67
|
-
Given
|
82
|
+
Given(/^I expect a GET to "([^"]*)" and return NOT FOUND$/) do |url|
|
68
83
|
stub_my_request(:get, url, {status: 404})
|
69
84
|
end
|
70
85
|
|
71
|
-
And /^I expect a
|
86
|
+
And /^I expect a GET to "([^"]*)" with json response:$/ do |url, json|
|
87
|
+
stub_my_request(:get, url, {response: json})
|
88
|
+
end
|
89
|
+
|
90
|
+
And(/^I expect a DELETE to "([^"]*)"$/) do |url|
|
72
91
|
stub_my_request(:delete, url, {})
|
73
92
|
end
|
74
93
|
|
75
|
-
Then
|
94
|
+
Then(/^the response should be OK$/) do
|
76
95
|
expect(Cucoo::Driver.response.code).to be_between(200, 201).inclusive
|
77
96
|
assert_all_stubs!
|
78
97
|
end
|
79
98
|
|
80
|
-
Then
|
99
|
+
Then(/^the response should be NOT FOUND$/) do
|
81
100
|
expect(Cucoo::Driver.response.code).to eq(404)
|
82
101
|
assert_all_stubs!
|
83
102
|
end
|
84
103
|
|
85
|
-
Then
|
104
|
+
Then(/^the response should be BAD REQUEST$/) do
|
86
105
|
expect(Cucoo::Driver.response.code).to eq(400)
|
87
106
|
assert_all_stubs!
|
88
107
|
end
|
89
108
|
|
90
|
-
Then
|
109
|
+
Then(/^the response code should be "([^"]*)"$/) do |code|
|
91
110
|
expect(Cucoo::Driver.response.code).to eq(code.to_i)
|
92
111
|
assert_all_stubs!
|
93
112
|
end
|
data/lib/cucoo/stub_helper.rb
CHANGED
@@ -9,7 +9,7 @@ module StubHelper
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def stub_my_request(method, url, params)
|
12
|
+
def stub_my_request(method, url, params={})
|
13
13
|
response = if params[:file]
|
14
14
|
File.new(params['file']).read
|
15
15
|
else
|
@@ -19,6 +19,7 @@ module StubHelper
|
|
19
19
|
stub_obj = stub_request(method, expand_url(url))
|
20
20
|
@stubs << stub_obj
|
21
21
|
stub_obj.with(body: params[:request], headers: {'Content-Type' => 'application/json'}) if params[:request]
|
22
|
+
stub_obj.with(body: params[:form_params], headers: {'Content-Type' => 'application/x-www-form-urlencoded'}) if params[:form_params]
|
22
23
|
stub_obj.to_return(body: response, status: status)
|
23
24
|
end
|
24
25
|
|
data/lib/cucoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -174,7 +174,6 @@ files:
|
|
174
174
|
- dummy/app/assets/stylesheets/application.css
|
175
175
|
- dummy/app/controllers/api_controller.rb
|
176
176
|
- dummy/app/controllers/application_controller.rb
|
177
|
-
- dummy/app/controllers/concerns/.keep
|
178
177
|
- dummy/app/helpers/application_helper.rb
|
179
178
|
- dummy/app/mailers/.keep
|
180
179
|
- dummy/app/models/.keep
|
File without changes
|