rest-assured 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ bundle_bin
6
6
  .sass-cache
7
7
  test.log
8
8
  coverage
9
+ .rvmrc
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest-assured (1.1.5)
4
+ rest-assured (1.1.6)
5
5
  activerecord (~> 3.2.0)
6
6
  activeresource (~> 3.2.0)
7
7
  childprocess (~> 0.3.0)
8
8
  haml (>= 3.1.3)
9
+ json
9
10
  sinatra (~> 1.3.2)
10
11
  sinatra-flash
11
12
 
@@ -6,20 +6,20 @@
6
6
 
7
7
  Stub/spy http(s) based external dependencies in your integration/acceptance tests.
8
8
 
9
- In a nutshell, here is how you can use it:
9
+ In a nutshell, you can:
10
10
 
11
11
  * replace external data sources with predefined data (stubbing)
12
12
  * verify requests to external services (spying)
13
13
  * simulate different behavior of external services using web UI; useful in development
14
14
 
15
- Here is how it works. REST-assured starts a webapp that can be instructed (via ruby client library or plain REST api) to respond to any request in any way. You configure api endpoints of the application under test to point to that webapp instead of real dependencies. Then in your tests create doubles to match whatever the app is supposed to be requesting. Double is more than just a data stub, it also keeps track of its request history. So that it can be verified.
15
+ Here is how it works. REST-assured starts an application that can be instructed (via ruby client library or plain REST api) to respond to any request with arbitrary content, status, headers, etc. Configure api endpoints of the application under test to point to that application instead of real services. Then in tests use the API (create doubles) that match requests your application is supposed to be firing. Either to stub content or to verify various aspects of how your application requests dependencies (headers, payload, etc).
16
16
 
17
17
  Check out [example](https://github.com/artemave/REST-assured-example)
18
18
 
19
19
 
20
20
  ## Set up
21
21
 
22
- You are going to need ruby >= 1.8.7 on Linux/MacOS. Also, either sqlite3, postgres or mysql is required.
22
+ You are going to need ruby >= 1.8.7 on Linux/MacOS. Also, one of sqlite3, postgres or mysql.
23
23
 
24
24
  ### Ruby Client
25
25
 
@@ -39,7 +39,7 @@ RestAssured::Server.address = 'http://localhost:4578' # or wherever it is
39
39
 
40
40
  ### Standalone instance
41
41
 
42
- Rest-assured requires a database to run. Either sqlite, mysql or postgres. So, make sure there is one and its backed with corresponding client gem:
42
+ Install db client gem:
43
43
 
44
44
  bash$ gem install sqlite3 # or mysql2 or pg
45
45
 
@@ -135,11 +135,13 @@ For those using REST-assured from non-ruby environments.
135
135
 
136
136
  Example:
137
137
 
138
+ ```
138
139
  bash$ curl -d 'fullpath=/api/something&content=awesome&response_headers%5BContent-Type%5D=text%2Fhtml' http://localhost:4578/doubles
139
140
  {"double":{"active":true,"content":"awesome","description":null,"fullpath":"/api/something","id":1,"response_headers":{"Content-Type":"text/html"},"status":200,"verb":"GET"}}
140
141
 
141
142
  bash$ curl http://localhost:4578/api/something
142
143
  awesome
144
+ ```
143
145
 
144
146
  If there is more than one double for the same fullpath and verb, the last created one gets served. In UI you can manually control which double is 'active' (gets served).
145
147
 
@@ -0,0 +1,22 @@
1
+ @ruby_api
2
+ Feature: destroy double
3
+ As api user
4
+ I want to be able to destroy double
5
+ So that I can emulate 'service gone' in the middle of a test
6
+
7
+ Scenario: list doubles
8
+ Given I created a double:
9
+ """
10
+ @double = RestAssured::Double.create :fullpath => 'path'
11
+ """
12
+
13
+ When I destroy that double:
14
+ """
15
+ @double.destroy
16
+ """
17
+
18
+ Then the following should be true:
19
+ """
20
+ RestAssured::Double.all.size.should == 0
21
+ """
22
+
@@ -0,0 +1,21 @@
1
+ @ruby_api
2
+ Feature: list doubles
3
+ As api user
4
+ I want to be able to get list of doubles
5
+ So that I can do batch operations on them (e.g. remove doubles that match criteria)
6
+
7
+ Scenario: list doubles
8
+ Given there are the following doubles:
9
+ | fullpath |
10
+ | first |
11
+ | second |
12
+
13
+ When I get the list of doubles:
14
+ """
15
+ @doubles = RestAssured::Double.all
16
+ """
17
+
18
+ Then the following should be true:
19
+ """
20
+ @doubles.size.should == 2
21
+ """
@@ -75,7 +75,8 @@ Given /^the following doubles exist:$/ do |doubles|
75
75
  :fullpath => row['fullpath'],
76
76
  :description => row['description'],
77
77
  :content => row['content'],
78
- :verb => row['verb']
78
+ :verb => row['verb'],
79
+ :status => row['status']
79
80
  )
80
81
  end
81
82
  end
@@ -89,6 +90,7 @@ Then /^I should see existing doubles:$/ do |doubles|
89
90
  page.should have_content(row[:fullpath])
90
91
  page.should have_content(row[:description])
91
92
  page.should have_content(row[:verb])
93
+ page.should have_content(row[:status])
92
94
  end
93
95
  end
94
96
 
@@ -107,6 +109,7 @@ When /^I enter double details:$/ do |details|
107
109
  fill_in 'Content', :with => double['content']
108
110
  select double['verb'], :from => 'Verb'
109
111
  fill_in 'Description', :with => double['description']
112
+ select double['status'], :from => 'Status'
110
113
  end
111
114
 
112
115
  When /^I save it$/ do
@@ -148,10 +151,15 @@ When /^I change "([^"]*)" "([^"]*)" to "([^"]*)"$/ do |obj, prop, value|
148
151
  end
149
152
 
150
153
  Given /^I choose to delete double with fullpath "([^"]*)"$/ do |fullpath|
151
- find(:xpath, "//tr[td[text()='#{fullpath}']]//a[text()='Delete']").click
154
+ find(:xpath, "//tr[td[a[text()='#{fullpath}']]]//a[text()='Delete']").click
152
155
  end
153
156
 
154
157
  Then /^I should be asked to confirm delete$/ do
155
158
  page.driver.browser.switch_to.alert.accept
156
159
  end
157
160
 
161
+ Given /^there are the following doubles:$/ do |table|
162
+ table.hashes.each do |row|
163
+ RestAssured::Models::Double.create :fullpath => row['fullpath']
164
+ end
165
+ end
@@ -111,3 +111,11 @@ end
111
111
  Then /^it should be stopped:$/ do |code|
112
112
  eval code
113
113
  end
114
+
115
+ When /^I get the list of doubles:$/ do |code|
116
+ eval code
117
+ end
118
+
119
+ When /^I destroy that double:$/ do |code|
120
+ eval code
121
+ end
@@ -22,13 +22,13 @@ Feature: manage doubles via ui
22
22
  Given I am on "doubles" page
23
23
  When I choose to create a double
24
24
  And I enter double details:
25
- | fullpath | description | content | verb |
26
- | /url2/bb?a=b5 | google api | test content | POST |
25
+ | fullpath | description | content | verb | status |
26
+ | /url2/bb?a=b5 | google api | test content | POST | 200 |
27
27
  And I save it
28
28
  Then I should see "Double created"
29
29
  And I should see existing doubles:
30
- | fullpath | description | verb |
31
- | /url2/bb?a=b5 | google api | POST |
30
+ | fullpath | description | verb | status |
31
+ | /url2/bb?a=b5 | google api | POST | 200 |
32
32
 
33
33
  @javascript
34
34
  Scenario: choose active double
@@ -41,16 +41,16 @@ Feature: manage doubles via ui
41
41
 
42
42
  Scenario: edit double
43
43
  Given the following doubles exist:
44
- | fullpath | description | content | verb |
45
- | /url1/aaa | twitter | test content | POST |
44
+ | fullpath | description | content | verb | status |
45
+ | /url1/aaa | twitter | test content | POST | 404 |
46
46
  And I visit "doubles" page
47
47
  And I choose to edit double
48
48
  When I change "double" "description" to "google"
49
49
  And I save it
50
50
  Then I should see that I am on "doubles" page
51
51
  And I should see existing doubles:
52
- | fullpath | description | verb |
53
- | /url1/aaa | google | POST |
52
+ | fullpath | description | verb | status |
53
+ | /url1/aaa | google | POST | 404 |
54
54
 
55
55
  @javascript
56
56
  Scenario: delete double
@@ -8,6 +8,10 @@ module RestAssured
8
8
  def verbs
9
9
  RestAssured::Models::Double::VERBS
10
10
  end
11
+
12
+ def statuses
13
+ RestAssured::Models::Double::STATUSES.sort
14
+ end
11
15
  end
12
16
 
13
17
  router.get '/' do
@@ -1,3 +1,3 @@
1
1
  module RestAssured
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.6'
3
3
  end
@@ -26,5 +26,6 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency 'haml', '>= 3.1.3'
27
27
  s.add_dependency 'activerecord', '~> 3.2.0'
28
28
  s.add_dependency 'activeresource', '~> 3.2.0'
29
+ s.add_dependency 'json'
29
30
  end
30
31
 
@@ -16,6 +16,12 @@
16
16
  %label{:for => 'double_description'} Description
17
17
  %textarea.wide#double_description{:name => 'double[description]', :rows => 3}= @double.description
18
18
 
19
+ %p
20
+ %label{:for => 'double_status'} Status
21
+ %select#double_status{:name => 'double[status]'}
22
+ - statuses.each do |s|
23
+ %option{:name => s, :selected => (@double.status == s)}= s
24
+
19
25
  %p
20
26
  %input{:type => 'submit', :value => 'Save'}
21
27
  |
@@ -6,6 +6,7 @@
6
6
  %th Request fullpath
7
7
  %th Verb
8
8
  %th Description
9
+ %th Status
9
10
  %th Active?
10
11
  %th  
11
12
  %tbody
@@ -13,9 +14,11 @@
13
14
  - fs.each_with_index do |f, i|
14
15
  %tr{:id => "double_row_#{f.id}"}
15
16
  - if i == 0
16
- %td{:rowspan => fs.size}= fullpath
17
+ %td{:rowspan => fs.size}
18
+ %a{:href => fullpath, :target => '_blank'}= fullpath
17
19
  %td= f.verb
18
20
  %td= f.description
21
+ %td= f.status
19
22
  %td.label.text-center
20
23
  %input.active-double-toggle{:type => 'radio', :name => fullpath, :checked => f.active, :data => { :double_id => f.id }}
21
24
  %td.edit-link.text-center.white-space-nowrap
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-assured
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &2156724640 !ruby/object:Gem::Requirement
16
+ requirement: &2153725420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156724640
24
+ version_requirements: *2153725420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: childprocess
27
- requirement: &2156724180 !ruby/object:Gem::Requirement
27
+ requirement: &2153721660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156724180
35
+ version_requirements: *2153721660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra-flash
38
- requirement: &2156723800 !ruby/object:Gem::Requirement
38
+ requirement: &2153717260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156723800
46
+ version_requirements: *2153717260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: haml
49
- requirement: &2156723260 !ruby/object:Gem::Requirement
49
+ requirement: &2153713100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.1.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2156723260
57
+ version_requirements: *2153713100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activerecord
60
- requirement: &2156722760 !ruby/object:Gem::Requirement
60
+ requirement: &2153709880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.2.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2156722760
68
+ version_requirements: *2153709880
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activeresource
71
- requirement: &2156722300 !ruby/object:Gem::Requirement
71
+ requirement: &2153707700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,18 @@ dependencies:
76
76
  version: 3.2.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2156722300
79
+ version_requirements: *2153707700
80
+ - !ruby/object:Gem::Dependency
81
+ name: json
82
+ requirement: &2153706540 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *2153706540
80
91
  description:
81
92
  email:
82
93
  - artem.avetisyan@bbc.co.uk
@@ -116,6 +127,8 @@ files:
116
127
  - features/rest_api/doubles.feature
117
128
  - features/rest_api/redirects.feature
118
129
  - features/ruby_api/create_double.feature
130
+ - features/ruby_api/destroy_double.feature
131
+ - features/ruby_api/list_doubles.feature
119
132
  - features/ruby_api/test_server.feature
120
133
  - features/ruby_api/verify_requests.feature
121
134
  - features/ruby_api/wait_for_requests.feature
@@ -208,6 +221,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
221
  - - ! '>='
209
222
  - !ruby/object:Gem::Version
210
223
  version: '0'
224
+ segments:
225
+ - 0
226
+ hash: 3710356704569330003
211
227
  requirements: []
212
228
  rubyforge_project: rest-assured
213
229
  rubygems_version: 1.8.10
@@ -219,6 +235,8 @@ test_files:
219
235
  - features/rest_api/doubles.feature
220
236
  - features/rest_api/redirects.feature
221
237
  - features/ruby_api/create_double.feature
238
+ - features/ruby_api/destroy_double.feature
239
+ - features/ruby_api/list_doubles.feature
222
240
  - features/ruby_api/test_server.feature
223
241
  - features/ruby_api/verify_requests.feature
224
242
  - features/ruby_api/wait_for_requests.feature