rest-assured 1.2.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG +5 -0
- data/Gemfile +7 -7
- data/Gemfile.lock +18 -44
- data/README.markdown +4 -4
- data/bin/console +0 -1
- data/bin/rest-assured +0 -1
- data/features/step_definitions/doubles_steps.rb +3 -7
- data/features/step_definitions/redirect_rules_steps.rb +1 -1
- data/features/support/env.rb +55 -62
- data/features/web_ui/doubles.feature +2 -4
- data/features/web_ui/redirects.feature +2 -4
- data/lib/rest-assured/routes/double.rb +15 -15
- data/lib/rest-assured/routes/redirect.rb +7 -7
- data/lib/rest-assured/version.rb +1 -1
- data/spec/functional/double_routes_spec.rb +2 -2
- data/spec/functional/redirect_routes_spec.rb +2 -2
- data/spec/spec_helper.rb +45 -54
- metadata +22 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4be619d9752d4b3fc3ef2f4755c2f1de691d83b
|
|
4
|
+
data.tar.gz: c289e34540a93ae862f2bd2087f495d4ae993968
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0df823b94ad412f0c966155ef635fc19121a64d5b673f4b79c48459fd4c178a986b5ad274f2c932576df2b952ec4731168bf904b321282a1135416550c4d5434
|
|
7
|
+
data.tar.gz: 9c4289f4b76be49c696b84ccc263a00375e118177f02368b69c86f8b9a702644ea30bb107cda78bb5a7d936963cd8eb441787e0a2c3d58c968696f4cc78f3be4
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
+
ruby '2.1.0'
|
|
4
|
+
|
|
3
5
|
gemspec
|
|
4
6
|
|
|
5
7
|
gem 'pg'
|
|
@@ -7,20 +9,19 @@ gem 'pg'
|
|
|
7
9
|
# skipped for heroku
|
|
8
10
|
group :test do
|
|
9
11
|
gem 'cucumber'
|
|
12
|
+
gem 'selenium-webdriver'
|
|
10
13
|
gem 'database_cleaner'
|
|
11
14
|
gem 'rspec'
|
|
12
15
|
gem 'shoulda-matchers'
|
|
13
16
|
gem 'anticipate'
|
|
14
17
|
gem 'rack-test'
|
|
15
|
-
gem 'capybara'
|
|
18
|
+
gem 'capybara'
|
|
16
19
|
gem 'rake'
|
|
17
20
|
gem 'mysql2'
|
|
18
21
|
gem 'sqlite3'
|
|
19
22
|
gem 'chromedriver-helper'
|
|
20
|
-
|
|
21
|
-
gem 'simplecov', :platforms => :ruby_19
|
|
23
|
+
gem 'simplecov'
|
|
22
24
|
gem 'awesome_print'
|
|
23
|
-
gem "spork", "> 0.9.0.rc"
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
# skipped for heroku and travis
|
|
@@ -28,9 +29,8 @@ group :development do
|
|
|
28
29
|
gem 'relish'
|
|
29
30
|
gem 'pry'
|
|
30
31
|
gem 'pry-doc'
|
|
31
|
-
gem 'pry-stack_explorer'
|
|
32
|
-
gem 'pry-debugger'
|
|
32
|
+
gem 'pry-stack_explorer'
|
|
33
|
+
gem 'pry-debugger'
|
|
33
34
|
gem 'launchy'
|
|
34
|
-
gem "guard-spork"
|
|
35
35
|
end
|
|
36
36
|
|
data/Gemfile.lock
CHANGED
|
@@ -35,16 +35,13 @@ GEM
|
|
|
35
35
|
binding_of_caller (0.7.2)
|
|
36
36
|
debug_inspector (>= 0.0.1)
|
|
37
37
|
builder (3.0.4)
|
|
38
|
-
capybara (
|
|
38
|
+
capybara (2.2.1)
|
|
39
39
|
mime-types (>= 1.16)
|
|
40
40
|
nokogiri (>= 1.3.3)
|
|
41
41
|
rack (>= 1.0.0)
|
|
42
42
|
rack-test (>= 0.5.4)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
celluloid (0.15.2)
|
|
46
|
-
timers (~> 1.1.0)
|
|
47
|
-
childprocess (0.3.9)
|
|
43
|
+
xpath (~> 2.0)
|
|
44
|
+
childprocess (0.4.0)
|
|
48
45
|
ffi (~> 1.0, >= 1.0.11)
|
|
49
46
|
chromedriver-helper (0.0.5)
|
|
50
47
|
nokogiri
|
|
@@ -59,50 +56,34 @@ GEM
|
|
|
59
56
|
daemons (1.1.9)
|
|
60
57
|
database_cleaner (1.2.0)
|
|
61
58
|
debug_inspector (0.0.2)
|
|
62
|
-
debugger (1.6.
|
|
59
|
+
debugger (1.6.5)
|
|
63
60
|
columnize (>= 0.3.1)
|
|
64
61
|
debugger-linecache (~> 1.2.0)
|
|
65
|
-
debugger-ruby_core_source (~> 1.3.
|
|
62
|
+
debugger-ruby_core_source (~> 1.3.1)
|
|
66
63
|
debugger-linecache (1.2.0)
|
|
67
|
-
debugger-ruby_core_source (1.3.
|
|
64
|
+
debugger-ruby_core_source (1.3.1)
|
|
68
65
|
diff-lcs (1.2.5)
|
|
69
|
-
docile (1.1.
|
|
66
|
+
docile (1.1.2)
|
|
70
67
|
eventmachine (1.0.3)
|
|
71
68
|
ffi (1.9.3)
|
|
72
|
-
formatador (0.2.4)
|
|
73
69
|
gherkin (2.12.2)
|
|
74
70
|
multi_json (~> 1.3)
|
|
75
|
-
|
|
76
|
-
formatador (>= 0.2.4)
|
|
77
|
-
listen (~> 2.1)
|
|
78
|
-
lumberjack (~> 1.0)
|
|
79
|
-
pry (>= 0.9.12)
|
|
80
|
-
thor (>= 0.18.1)
|
|
81
|
-
guard-spork (1.5.1)
|
|
82
|
-
childprocess (>= 0.2.3)
|
|
83
|
-
guard (>= 1.1)
|
|
84
|
-
spork (>= 0.8.4)
|
|
85
|
-
haml (4.0.4)
|
|
71
|
+
haml (4.0.5)
|
|
86
72
|
tilt
|
|
87
73
|
i18n (0.6.9)
|
|
88
74
|
json (1.8.1)
|
|
89
75
|
launchy (2.4.2)
|
|
90
76
|
addressable (~> 2.3)
|
|
91
|
-
listen (2.4.0)
|
|
92
|
-
celluloid (>= 0.15.2)
|
|
93
|
-
rb-fsevent (>= 0.9.3)
|
|
94
|
-
rb-inotify (>= 0.9)
|
|
95
|
-
lumberjack (1.0.4)
|
|
96
77
|
method_source (0.8.2)
|
|
97
|
-
mime-types (2.
|
|
78
|
+
mime-types (2.1)
|
|
98
79
|
mini_portile (0.5.2)
|
|
99
|
-
multi_json (1.8.
|
|
100
|
-
multi_test (0.0.
|
|
101
|
-
mysql2 (0.3.
|
|
80
|
+
multi_json (1.8.4)
|
|
81
|
+
multi_test (0.0.3)
|
|
82
|
+
mysql2 (0.3.15)
|
|
102
83
|
nokogiri (1.6.1)
|
|
103
84
|
mini_portile (~> 0.5.0)
|
|
104
85
|
pg (0.17.1)
|
|
105
|
-
pry (0.9.12.
|
|
86
|
+
pry (0.9.12.6)
|
|
106
87
|
coderay (~> 1.0)
|
|
107
88
|
method_source (~> 0.8)
|
|
108
89
|
slop (~> 3.4)
|
|
@@ -116,14 +97,11 @@ GEM
|
|
|
116
97
|
binding_of_caller (>= 0.7)
|
|
117
98
|
pry (>= 0.9.11)
|
|
118
99
|
rack (1.5.2)
|
|
119
|
-
rack-protection (1.5.
|
|
100
|
+
rack-protection (1.5.2)
|
|
120
101
|
rack
|
|
121
102
|
rack-test (0.6.2)
|
|
122
103
|
rack (>= 1.0)
|
|
123
104
|
rake (10.1.1)
|
|
124
|
-
rb-fsevent (0.9.3)
|
|
125
|
-
rb-inotify (0.9.3)
|
|
126
|
-
ffi (>= 0.5.0)
|
|
127
105
|
relish (0.7)
|
|
128
106
|
archive-tar-minitar (>= 0.5.2)
|
|
129
107
|
json (>= 1.4.6)
|
|
@@ -144,7 +122,7 @@ GEM
|
|
|
144
122
|
multi_json (~> 1.0)
|
|
145
123
|
rubyzip (~> 1.0)
|
|
146
124
|
websocket (~> 1.0.4)
|
|
147
|
-
shoulda-matchers (2.
|
|
125
|
+
shoulda-matchers (2.5.0)
|
|
148
126
|
activesupport (>= 3.0.0)
|
|
149
127
|
simplecov (0.8.2)
|
|
150
128
|
docile (~> 1.1.0)
|
|
@@ -158,18 +136,15 @@ GEM
|
|
|
158
136
|
sinatra-flash (0.3.0)
|
|
159
137
|
sinatra (>= 1.0.0)
|
|
160
138
|
slop (3.4.7)
|
|
161
|
-
spork (1.0.0rc4)
|
|
162
139
|
sqlite3 (1.3.8)
|
|
163
140
|
thin (1.6.1)
|
|
164
141
|
daemons (>= 1.0.9)
|
|
165
142
|
eventmachine (>= 1.0.0)
|
|
166
143
|
rack (>= 1.0.0)
|
|
167
|
-
thor (0.18.1)
|
|
168
144
|
tilt (1.4.1)
|
|
169
|
-
timers (1.1.0)
|
|
170
145
|
tzinfo (0.3.38)
|
|
171
146
|
websocket (1.0.7)
|
|
172
|
-
xpath (0.
|
|
147
|
+
xpath (2.0.0)
|
|
173
148
|
nokogiri (~> 1.3)
|
|
174
149
|
yard (0.8.7.3)
|
|
175
150
|
|
|
@@ -179,11 +154,10 @@ PLATFORMS
|
|
|
179
154
|
DEPENDENCIES
|
|
180
155
|
anticipate
|
|
181
156
|
awesome_print
|
|
182
|
-
capybara
|
|
157
|
+
capybara
|
|
183
158
|
chromedriver-helper
|
|
184
159
|
cucumber
|
|
185
160
|
database_cleaner
|
|
186
|
-
guard-spork
|
|
187
161
|
launchy
|
|
188
162
|
mysql2
|
|
189
163
|
pg
|
|
@@ -196,7 +170,7 @@ DEPENDENCIES
|
|
|
196
170
|
relish
|
|
197
171
|
rest-assured!
|
|
198
172
|
rspec
|
|
173
|
+
selenium-webdriver
|
|
199
174
|
shoulda-matchers
|
|
200
175
|
simplecov
|
|
201
|
-
spork (> 0.9.0.rc)
|
|
202
176
|
sqlite3
|
data/README.markdown
CHANGED
|
@@ -112,20 +112,20 @@ JSON.parse(req.params).should == expected_params_hash
|
|
|
112
112
|
JSON.parse(req.rack_env)['HTTP_ACCEPT'].should == 'text/html'
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
Use
|
|
115
|
+
Use REST api to clear doubles/redirects between tests:
|
|
116
116
|
|
|
117
117
|
```ruby
|
|
118
118
|
RestClient.delete "#{RestAssured::Server.address}/redirects/all"
|
|
119
119
|
RestClient.delete "#{RestAssured::Server.address}/doubles/all"
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
###
|
|
122
|
+
### REST API
|
|
123
123
|
|
|
124
124
|
For those using REST-assured from non-ruby environments.
|
|
125
125
|
|
|
126
126
|
#### Create double
|
|
127
127
|
|
|
128
|
-
HTTP POST to `/doubles` creates a double and returns its json representation.
|
|
128
|
+
HTTP POST to `/doubles.json` creates a double and returns its json representation.
|
|
129
129
|
The following options can be passed as request parameters:
|
|
130
130
|
|
|
131
131
|
- __fullpath__ - e.g., `/some/api/object`, or with parameters in query string (useful for doubling GETs) - `/some/other/api/object?a=2&b=c`. Mandatory.
|
|
@@ -199,7 +199,7 @@ Here is the rest API for managing redirects:
|
|
|
199
199
|
|
|
200
200
|
### Create redirect
|
|
201
201
|
|
|
202
|
-
HTTP POST to `/redirects` creates redirect.
|
|
202
|
+
HTTP POST to `/redirects.json` creates redirect.
|
|
203
203
|
The following options can be passed as request parameters:
|
|
204
204
|
|
|
205
205
|
- __pattern__ - regex (perl5 style) tested against request fullpath. e.g, `^/auth/(.*)`. Mandatory
|
data/bin/console
CHANGED
data/bin/rest-assured
CHANGED
|
@@ -5,12 +5,12 @@ Given /^there are no doubles$/ do
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
When /^I create a double with "([^""]*)" as fullpath, "([^""]*)" as response content, "([^""]*)" as request verb and status as "([^""]*)"$/ do |fullpath, content, verb, status|
|
|
8
|
-
post '/doubles', { :fullpath => fullpath, :content => content, :verb => verb, :status => status }
|
|
8
|
+
post '/doubles.json', { :fullpath => fullpath, :content => content, :verb => verb, :status => status }
|
|
9
9
|
last_response.should be_ok
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
When /^I create a double$/ do
|
|
13
|
-
post '/doubles', { :fullpath => '/api/something' }
|
|
13
|
+
post '/doubles.json', { :fullpath => '/api/something' }
|
|
14
14
|
@create_a_double_response = last_response.body
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -81,10 +81,6 @@ Given /^the following doubles exist:$/ do |doubles|
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
Then /^I should see that I am on "([^""]*)" page$/ do |name|
|
|
85
|
-
find('title').text.should =~ /#{name} -/
|
|
86
|
-
end
|
|
87
|
-
|
|
88
84
|
Then /^I should see existing doubles:$/ do |doubles|
|
|
89
85
|
doubles.hashes.each do |row|
|
|
90
86
|
page.should have_content(row[:fullpath])
|
|
@@ -144,7 +140,7 @@ Then /^(first|second) double should be served$/ do |ord|
|
|
|
144
140
|
end
|
|
145
141
|
|
|
146
142
|
Given /^I choose to edit (?:double|redirect)$/ do
|
|
147
|
-
|
|
143
|
+
all('.edit-link a').first.click
|
|
148
144
|
end
|
|
149
145
|
|
|
150
146
|
When /^I change "([^"]*)" "([^"]*)" to "([^"]*)"$/ do |obj, prop, value|
|
|
@@ -3,7 +3,7 @@ Then /^I should get (\d+)$/ do |code|
|
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
When /^(?:I create|there is) redirect from "([^"]*)" to "([^"]*)"$/ do |pattern, url|
|
|
6
|
-
post '/redirects', { :pattern => pattern, :to => url }
|
|
6
|
+
post '/redirects.json', { :pattern => pattern, :to => url }
|
|
7
7
|
last_response.should be_ok
|
|
8
8
|
end
|
|
9
9
|
|
data/features/support/env.rb
CHANGED
|
@@ -1,80 +1,73 @@
|
|
|
1
1
|
$:.push File.expand_path('../../../lib', __FILE__)
|
|
2
|
-
|
|
3
|
-
require '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
def browser.env=(env)
|
|
26
|
-
@env = env
|
|
27
|
-
end
|
|
28
|
-
browser.env = headers
|
|
2
|
+
|
|
3
|
+
require 'timeout'
|
|
4
|
+
require 'rspec'
|
|
5
|
+
require 'rack/test'
|
|
6
|
+
require 'capybara'
|
|
7
|
+
require 'capybara/cucumber'
|
|
8
|
+
require 'database_cleaner'
|
|
9
|
+
require 'anticipate'
|
|
10
|
+
require 'awesome_print'
|
|
11
|
+
require 'rest-assured/utils/port_explorer'
|
|
12
|
+
require File.dirname(__FILE__) + '/world_helpers'
|
|
13
|
+
|
|
14
|
+
ENV['RACK_ENV'] = 'test'
|
|
15
|
+
|
|
16
|
+
module RackHeaderHack
|
|
17
|
+
def set_headers(headers)
|
|
18
|
+
browser = page.driver.browser
|
|
19
|
+
def browser.env
|
|
20
|
+
@env.merge(super)
|
|
21
|
+
end
|
|
22
|
+
def browser.env=(env)
|
|
23
|
+
@env = env
|
|
29
24
|
end
|
|
25
|
+
browser.env = headers
|
|
30
26
|
end
|
|
27
|
+
end
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
# Capybara.register_driver :selenium do |app|
|
|
30
|
+
# Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
|
31
|
+
# end
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
World(Capybara, Rack::Test::Methods, RackHeaderHack, WorldHelpers, Anticipate)
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
require 'rest-assured/config'
|
|
36
|
+
db_opts = { :adapter => 'mysql' }
|
|
37
|
+
RestAssured::Config.build(db_opts)
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
require 'rest-assured'
|
|
40
|
+
require 'shoulda-matchers'
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
RestAssured::Server.start(db_opts.merge(:port => 9876))
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
end
|
|
44
|
+
Before "@api_server" do
|
|
45
|
+
RestAssured::Server.stop
|
|
46
|
+
end
|
|
47
|
+
After "@api_server" do
|
|
48
|
+
RestAssured::Server.start(db_opts.merge(:port => 9876))
|
|
53
49
|
end
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
require 'rest-assured/application'
|
|
51
|
+
require 'rest-assured/application'
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
def app
|
|
54
|
+
RestAssured::Application
|
|
55
|
+
end
|
|
56
|
+
Capybara.app = app
|
|
62
57
|
|
|
63
|
-
|
|
58
|
+
DatabaseCleaner.strategy = :truncation
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
Before do
|
|
61
|
+
DatabaseCleaner.start
|
|
62
|
+
end
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
Before "@ui" do
|
|
65
|
+
set_headers "HTTP_USER_AGENT" => 'Firefox'
|
|
66
|
+
end
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
After do
|
|
69
|
+
sleep 0.1
|
|
70
|
+
DatabaseCleaner.clean
|
|
76
71
|
|
|
77
|
-
|
|
78
|
-
end
|
|
72
|
+
@t.join if @t.is_a?(Thread)
|
|
79
73
|
end
|
|
80
|
-
|
|
@@ -11,8 +11,7 @@ Feature: manage doubles via ui
|
|
|
11
11
|
| /url2/bbb | geo location | more content | POST |
|
|
12
12
|
| /u/b?c=1 | wikipedia | article | PUT |
|
|
13
13
|
When I visit "doubles" page
|
|
14
|
-
Then I should see
|
|
15
|
-
And I should see existing doubles:
|
|
14
|
+
Then I should see existing doubles:
|
|
16
15
|
| fullpath | description | verb |
|
|
17
16
|
| /url1/aaa | twitter | GET |
|
|
18
17
|
| /url2/bbb | geo location | POST |
|
|
@@ -47,8 +46,7 @@ Feature: manage doubles via ui
|
|
|
47
46
|
And I choose to edit double
|
|
48
47
|
When I change "double" "description" to "google"
|
|
49
48
|
And I save it
|
|
50
|
-
Then I should see
|
|
51
|
-
And I should see existing doubles:
|
|
49
|
+
Then I should see existing doubles:
|
|
52
50
|
| fullpath | description | verb | status |
|
|
53
51
|
| /url1/aaa | google | POST | 404 |
|
|
54
52
|
|
|
@@ -10,8 +10,7 @@ Feature: manage redirects via ui
|
|
|
10
10
|
| /url1/.* | http://google.com/api |
|
|
11
11
|
| /url2/bbb | http://twitter.com/api |
|
|
12
12
|
When I visit "redirects" page
|
|
13
|
-
Then I should see
|
|
14
|
-
And I should see existing redirects:
|
|
13
|
+
Then I should see existing redirects:
|
|
15
14
|
| pattern | to |
|
|
16
15
|
| /url1/.* | http://google.com/api |
|
|
17
16
|
| /url2/bbb | http://twitter.com/api |
|
|
@@ -36,8 +35,7 @@ Feature: manage redirects via ui
|
|
|
36
35
|
And I choose to edit redirect
|
|
37
36
|
When I change "redirect" "pattern" to "/some/remote.*"
|
|
38
37
|
And I save it
|
|
39
|
-
Then I should see
|
|
40
|
-
And I should see existing redirects:
|
|
38
|
+
Then I should see existing redirects:
|
|
41
39
|
| pattern | to |
|
|
42
40
|
| /some/remote.* | http://google.com/api |
|
|
43
41
|
|
|
@@ -17,12 +17,12 @@ module RestAssured
|
|
|
17
17
|
redirect to('/doubles')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
router.get %r{^/doubles(\.json)?$} do |
|
|
20
|
+
router.get %r{^/doubles(\.json)?$} do |needs_json|
|
|
21
21
|
@doubles = Models::Double.all
|
|
22
|
-
if
|
|
23
|
-
haml :'doubles/index'
|
|
24
|
-
else
|
|
22
|
+
if needs_json
|
|
25
23
|
body @doubles.to_json
|
|
24
|
+
else
|
|
25
|
+
haml :'doubles/index'
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ module RestAssured
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
router.post /^\/doubles(\.json)?$/ do
|
|
43
|
+
router.post /^\/doubles(\.json)?$/ do |needs_json|
|
|
44
44
|
begin
|
|
45
45
|
data = request.body.read
|
|
46
46
|
d = MultiJson.load(data)['double']
|
|
@@ -56,7 +56,14 @@ module RestAssured
|
|
|
56
56
|
|
|
57
57
|
@double = Models::Double.create(d)
|
|
58
58
|
|
|
59
|
-
if
|
|
59
|
+
if needs_json
|
|
60
|
+
if @double.errors.present?
|
|
61
|
+
status 422
|
|
62
|
+
body @double.errors.to_json
|
|
63
|
+
else
|
|
64
|
+
body @double.to_json
|
|
65
|
+
end
|
|
66
|
+
else
|
|
60
67
|
if @double.errors.blank?
|
|
61
68
|
flash[:notice] = "Double created"
|
|
62
69
|
redirect '/doubles'
|
|
@@ -64,13 +71,6 @@ module RestAssured
|
|
|
64
71
|
flash.now[:error] = "Crumps! " + @double.errors.full_messages.join("; ")
|
|
65
72
|
haml :'doubles/new'
|
|
66
73
|
end
|
|
67
|
-
else
|
|
68
|
-
if @double.errors.present?
|
|
69
|
-
status 422
|
|
70
|
-
body @double.errors.to_json
|
|
71
|
-
else
|
|
72
|
-
body @double.to_json
|
|
73
|
-
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -101,10 +101,10 @@ module RestAssured
|
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
router.delete %r{/doubles/(\d+)(\.json)?$} do |id,
|
|
104
|
+
router.delete %r{/doubles/(\d+)(\.json)?$} do |id, needs_json|
|
|
105
105
|
if Models::Double.destroy(id)
|
|
106
106
|
flash[:notice] = 'Double deleted'
|
|
107
|
-
redirect '/doubles' unless
|
|
107
|
+
redirect '/doubles' unless needs_json
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -11,10 +11,15 @@ module RestAssured
|
|
|
11
11
|
haml :'redirects/new'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
router.post
|
|
14
|
+
router.post /^\/redirects(.json)?$/ do |needs_json|
|
|
15
15
|
@redirect = Models::Redirect.create(params['redirect'] || { :pattern => params['pattern'], :to => params['to'] })
|
|
16
16
|
|
|
17
|
-
if
|
|
17
|
+
if needs_json
|
|
18
|
+
if @redirect.errors.present?
|
|
19
|
+
status 400
|
|
20
|
+
body @redirect.errors.full_messages.join("\n")
|
|
21
|
+
end
|
|
22
|
+
else
|
|
18
23
|
if @redirect.errors.blank?
|
|
19
24
|
flash[:notice] = "Redirect created"
|
|
20
25
|
redirect '/redirects'
|
|
@@ -22,11 +27,6 @@ module RestAssured
|
|
|
22
27
|
flash.now[:error] = "Crumps! " + @redirect.errors.full_messages.join("; ")
|
|
23
28
|
haml :'redirects/new'
|
|
24
29
|
end
|
|
25
|
-
else
|
|
26
|
-
if @redirect.errors.present?
|
|
27
|
-
status 400
|
|
28
|
-
body @redirect.errors.full_messages.join("\n")
|
|
29
|
-
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
data/lib/rest-assured/version.rb
CHANGED
|
@@ -125,7 +125,7 @@ module RestAssured
|
|
|
125
125
|
|
|
126
126
|
context "REST api", :ui => false do
|
|
127
127
|
it "creates double" do
|
|
128
|
-
post '/doubles', test_double
|
|
128
|
+
post '/doubles.json', test_double
|
|
129
129
|
|
|
130
130
|
last_response.should be_ok
|
|
131
131
|
|
|
@@ -134,7 +134,7 @@ module RestAssured
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
it "reports failure when creating with invalid parameters" do
|
|
137
|
-
post '/doubles', test_double.except(:fullpath)
|
|
137
|
+
post '/doubles.json', test_double.except(:fullpath)
|
|
138
138
|
|
|
139
139
|
last_response.should_not be_ok
|
|
140
140
|
last_response.body.should =~ /\{"fullpath":\["can't be blank"\]\}/
|
|
@@ -93,14 +93,14 @@ module RestAssured
|
|
|
93
93
|
|
|
94
94
|
context 'via api', :ui => false do
|
|
95
95
|
it "creates redirect" do
|
|
96
|
-
post '/redirects', redirect
|
|
96
|
+
post '/redirects.json', redirect
|
|
97
97
|
|
|
98
98
|
last_response.should be_ok
|
|
99
99
|
Models::Redirect.count.should == 1
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "reports failure when creating with invalid parameters" do
|
|
103
|
-
post '/redirects', redirect.except(:pattern)
|
|
103
|
+
post '/redirects.json', redirect.except(:pattern)
|
|
104
104
|
|
|
105
105
|
last_response.should_not be_ok
|
|
106
106
|
last_response.body.should =~ /Pattern can't be blank/
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if RUBY_VERSION =~ /^1.9/
|
|
1
|
+
if ENV['COVERAGE']
|
|
4
2
|
begin
|
|
5
3
|
require 'simplecov'
|
|
6
4
|
SimpleCov.start do
|
|
@@ -12,72 +10,65 @@ if RUBY_VERSION =~ /^1.9/
|
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
require 'spork'
|
|
16
|
-
|
|
17
13
|
$:.unshift(File.expand_path('../../lib'), __FILE__)
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
require File.expand_path('../support/reset-singleton', __FILE__)
|
|
15
|
+
require 'rspec'
|
|
16
|
+
require 'capybara/rspec'
|
|
17
|
+
require 'rack/test'
|
|
18
|
+
require 'database_cleaner'
|
|
19
|
+
require 'awesome_print'
|
|
20
|
+
require File.expand_path('../support/custom_matchers', __FILE__)
|
|
21
|
+
require File.expand_path('../support/reset-singleton', __FILE__)
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
ENV['RACK_ENV'] = 'test'
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
alias_method :ajax, :xhr
|
|
25
|
+
module XhrHelpers
|
|
26
|
+
def xhr(path, params = {})
|
|
27
|
+
verb = params.delete(:as) || :get
|
|
28
|
+
send(verb,path, params, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest")
|
|
36
29
|
end
|
|
30
|
+
alias_method :ajax, :xhr
|
|
31
|
+
end
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
RSpec.configure do |c|
|
|
34
|
+
c.include Capybara::DSL
|
|
35
|
+
c.include Rack::Test::Methods
|
|
36
|
+
c.include XhrHelpers
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
c.before(:each) do
|
|
39
|
+
DatabaseCleaner.start
|
|
40
|
+
end
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
c.after(:each) do
|
|
43
|
+
DatabaseCleaner.clean
|
|
44
|
+
end
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
c.before(:each, :ui => true) do
|
|
47
|
+
header 'User-Agent', 'Firefox'
|
|
48
|
+
end
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
c.before(:each, :ui => false) do
|
|
51
|
+
header 'User-Agent', nil
|
|
52
|
+
end
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
end
|
|
54
|
+
if defined?(SimpleCov)
|
|
55
|
+
c.after(:suite) do
|
|
56
|
+
SimpleCov.result.format!
|
|
63
57
|
end
|
|
64
58
|
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
require 'rest-assured'
|
|
70
|
-
require 'rest-assured/application'
|
|
71
|
-
require 'shoulda-matchers'
|
|
59
|
+
end
|
|
60
|
+
require 'rest-assured/config'
|
|
61
|
+
DB_OPTS = { :adapter => 'mysql' }
|
|
62
|
+
RestAssured::Config.build(DB_OPTS)
|
|
72
63
|
|
|
73
|
-
|
|
64
|
+
require 'rest-assured'
|
|
65
|
+
require 'rest-assured/application'
|
|
66
|
+
require 'shoulda-matchers'
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
RestAssured::Application
|
|
77
|
-
end
|
|
68
|
+
Capybara.app = RestAssured::Application
|
|
78
69
|
|
|
79
|
-
|
|
70
|
+
def app
|
|
71
|
+
RestAssured::Application
|
|
80
72
|
end
|
|
81
73
|
|
|
82
|
-
|
|
83
|
-
end
|
|
74
|
+
DatabaseCleaner.strategy = :truncation
|
metadata
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rest-assured
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Artem Avetisyan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sinatra
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 1.4.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
26
|
version: 1.4.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: childprocess
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0.3'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0.3'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: sinatra-flash
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: haml
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - ~>
|
|
59
|
+
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '4.0'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - ~>
|
|
66
|
+
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '4.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: activerecord
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- - ~>
|
|
73
|
+
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '3.0'
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- - ~>
|
|
80
|
+
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '3.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: activeresource
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- - ~>
|
|
87
|
+
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '3.0'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- - ~>
|
|
94
|
+
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '3.0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: thin
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- - ~>
|
|
101
|
+
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '1.6'
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
|
-
- - ~>
|
|
108
|
+
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '1.6'
|
|
111
111
|
description:
|
|
@@ -116,9 +116,9 @@ executables:
|
|
|
116
116
|
extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
|
118
118
|
files:
|
|
119
|
-
- .gitignore
|
|
120
|
-
- .rspec
|
|
121
|
-
- .travis.yml
|
|
119
|
+
- ".gitignore"
|
|
120
|
+
- ".rspec"
|
|
121
|
+
- ".travis.yml"
|
|
122
122
|
- CHANGELOG
|
|
123
123
|
- Gemfile
|
|
124
124
|
- Gemfile.lock
|
|
@@ -231,17 +231,17 @@ require_paths:
|
|
|
231
231
|
- lib
|
|
232
232
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
233
|
requirements:
|
|
234
|
-
- -
|
|
234
|
+
- - ">="
|
|
235
235
|
- !ruby/object:Gem::Version
|
|
236
236
|
version: 1.8.7
|
|
237
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
requirements:
|
|
239
|
-
- -
|
|
239
|
+
- - ">="
|
|
240
240
|
- !ruby/object:Gem::Version
|
|
241
241
|
version: '0'
|
|
242
242
|
requirements: []
|
|
243
243
|
rubyforge_project: rest-assured
|
|
244
|
-
rubygems_version: 2.
|
|
244
|
+
rubygems_version: 2.2.0
|
|
245
245
|
signing_key:
|
|
246
246
|
specification_version: 4
|
|
247
247
|
summary: Real stubs and spies for HTTP(S) services
|