rack-test-rest 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,7 +21,8 @@ that is testing a specific resource e.g.:
21
21
  @rack_test_rest = {
22
22
  #:debug => true,
23
23
  :root_uri => "/v1/metrics",
24
- :resource => "gauges"
24
+ :resource => "gauges",
25
+ :extension => ".json" #other possibilities ".xml", "_json",".html", etc
25
26
  }
26
27
  end
27
28
 
@@ -57,12 +58,12 @@ required to test any particular resource. You need only specify `:root_uri` and
57
58
  in your test setup (through the `@rack_test_rest` instance variable). These are combined
58
59
  to create either the URI for creating/indexing resources or the URI for a particular resource:
59
60
 
60
- :root_uri + '/' + :resource + '.json'
61
- :root_uri + '/' + :resource + '/' + params[:id].to_s + '.json'
61
+ :root_uri + '/' + :resource + :extension
62
+ :root_uri + '/' + :resource + '/' + params[:id].to_s + :extension
62
63
 
63
64
  ## `create_resource(params={})`
64
65
 
65
- Performs a POST to with any specified parameters to `:root_uri/:resource.json`
66
+ Performs a POST to with any specified parameters to `:root_uri/:resource:extension`
66
67
  and ensures that it returns `201`. Returns the string value found in the response's
67
68
  `Location` header.
68
69
 
@@ -70,18 +71,18 @@ and ensures that it returns `201`. Returns the string value found in the respons
70
71
 
71
72
  Performs a GET with any specified parameters and validates that it returns `200`.
72
73
  If `:id` is specified the GET is performed against a singular resource i.e.
73
- `:root_uri/:resource/:id.json`. In the absence of `:id` the GET is performed
74
- as an index operation against `:root_uri/:resource.json`. Returns parsed
74
+ `:root_uri/:resource/:id:extension`. In the absence of `:id` the GET is performed
75
+ as an index operation against `:root_uri/:resource:extension`. Returns parsed
75
76
  JSON of the response body on a `200`.
76
77
 
77
78
  ## `update_resource(params={})`
78
79
 
79
- Requires an :id parameter. Performs a PUT against `:root_uri/:resource/:id.json`
80
+ Requires an :id parameter. Performs a PUT against `:root_uri/:resource/:id:extension`
80
81
  with any other specified parameters and asserts that it returns `204`.
81
82
 
82
83
  ## `delete_resource(params={})`
83
84
 
84
- Requires an :id parameter. Performs a DELETE against `:root_uri/:resource/:id.json`
85
+ Requires an :id parameter. Performs a DELETE against `:root_uri/:resource/:id:extension`
85
86
  and asserts that it returns `204`.
86
87
 
87
88
  ## Testing invalid input
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -10,8 +10,8 @@ module Rack
10
10
  expected_code = params[:code]
11
11
  params.delete :code
12
12
 
13
- puts "Posting to: '#{resource_uri}.json'" if @rack_test_rest[:debug]
14
- post "#{resource_uri}.json", params
13
+ puts "Posting to: '#{resource_uri}#{@rack_test_rest[:extension]}'" if @rack_test_rest[:debug]
14
+ post "#{resource_uri}#{@rack_test_rest[:extension]}", params
15
15
 
16
16
  if expected_code
17
17
  assert_equal(expected_code, last_response.status)
@@ -36,9 +36,9 @@ module Rack
36
36
  if params[:id]
37
37
  id = params[:id]
38
38
  params.delete(:id)
39
- uri = resource_uri + "/#{id}.json"
39
+ uri = "#{resource_uri}/#{id}#{@rack_test_rest[:extension]}"
40
40
  else
41
- uri = resource_uri + ".json"
41
+ uri = "#{resource_uri}#{@rack_test_rest[:extension]}"
42
42
  end
43
43
 
44
44
  puts "GET #{uri} #{params}" if @rack_test_rest[:debug]
@@ -67,7 +67,7 @@ module Rack
67
67
 
68
68
  puts "Attempting to update #{id} with #{params}" if @rack_test_rest[:debug]
69
69
 
70
- put "#{resource_uri}/#{id}.json", params
70
+ put "#{resource_uri}/#{id}#{@rack_test_rest[:extension]}", params
71
71
 
72
72
  puts "#{last_response.status}: #{last_response.body}" if @rack_test_rest[:debug]
73
73
 
@@ -79,7 +79,7 @@ module Rack
79
79
  end
80
80
 
81
81
  def delete_resource(params={})
82
- delete "#{resource_uri}/#{params[:id]}.json"
82
+ delete "#{resource_uri}/#{params[:id]}#{@rack_test_rest[:extension]}"
83
83
 
84
84
  if params[:code]
85
85
  assert_equal(params[:code], last_response.status)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-test-rest}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joseph Ruscio"]
12
- s.date = %q{2011-09-06}
12
+ s.date = %q{2011-10-02}
13
13
  s.description = %q{rack-test-rest is an extension to rack-test that when combined with Test::Unit simplifies the process of unit testing properly designed RESTful API's.}
14
14
  s.email = %q{joe@ruscio.org}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test-rest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joseph Ruscio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-06 00:00:00 -07:00
18
+ date: 2011-10-02 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency