anmo 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .vimlocal
data/README.md CHANGED
@@ -25,10 +25,4 @@ Anmo.create_request({
25
25
  ```
26
26
  curl http://localhost:8787/lookatmyhorse
27
27
  my horse is amazing
28
- ```
29
-
30
- Multiple Hosts?
31
- ---------------
32
-
33
- Yep. If you have one running anmo server then each domain that points to that server will have it's own data in anmo.
34
- For example the hosts anmo2.example.org and anmo2.example.org can point at the same anmo instance, and each will have their own data.
28
+ ```
@@ -82,28 +82,39 @@ module Anmo
82
82
  end
83
83
 
84
84
  def find_stored_request actual_request
85
- actual_request_url = actual_request.path_info
86
- if actual_request.query_string != ""
87
- actual_request_url << "?" + actual_request.query_string
85
+ actual_request_query = Rack::Utils.parse_query(actual_request.query_string)
86
+
87
+ suspected_request = ApplicationDataStore.stored_objects.find do |r|
88
+ r["path"].gsub(/\?.*/, "") == actual_request.path_info
88
89
  end
89
90
 
90
- found_request = ApplicationDataStore.stored_objects.find {|r| r["path"] == actual_request_url}
91
- if found_request
92
- if found_request["method"]
93
- if actual_request.request_method != found_request["method"].upcase
94
- return
95
- end
96
- end
91
+ if suspected_request
92
+ return unless request_has_same_method actual_request, suspected_request
93
+ return unless request_has_same_query actual_request, suspected_request
94
+ return unless request_has_required_headers actual_request, suspected_request
95
+ end
96
+ suspected_request
97
+ end
98
+
99
+ def request_has_same_method initial_request, suspected_request
100
+ return true if suspected_request["method"] == nil
101
+ suspected_request["method"].upcase == initial_request.request_method
102
+ end
103
+
104
+ def request_has_same_query initial_request, suspected_request
105
+ return true if suspected_request["path"].include?("?") == false
106
+ query = Rack::Utils.parse_query(suspected_request["path"].gsub(/.*\?/, ""))
107
+ query == Rack::Utils.parse_query(initial_request.query_string)
108
+ end
97
109
 
98
- required_headers = found_request["required_headers"] || []
99
- required_headers.each do |name, value|
100
- if actual_request.env[convert_header_name_to_rack_style_name(name)] != value
101
- found_request = nil
102
- break
103
- end
110
+ def request_has_required_headers initial_request, suspected_request
111
+ required_headers = suspected_request["required_headers"] || []
112
+ required_headers.each do |name, value|
113
+ if initial_request.env[convert_header_name_to_rack_style_name(name)] != value
114
+ return false
104
115
  end
105
116
  end
106
- found_request
117
+ true
107
118
  end
108
119
 
109
120
  def convert_header_name_to_rack_style_name name
@@ -1,3 +1,3 @@
1
1
  module Anmo
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
3
3
  end
@@ -59,6 +59,13 @@ module Anmo
59
59
  assert_equal "please save this", last_response.body
60
60
  end
61
61
 
62
+ def test_returns_object_if_request_has_query_parameters_in_different_order
63
+ save_object "/?aaa=aaa&bbb=bbb", "please save this", nil, nil, nil
64
+ get "/?bbb=bbb&aaa=aaa"
65
+ assert_equal 200, last_response.status
66
+ assert_equal "please save this", last_response.body
67
+ end
68
+
62
69
  def test_stores_status_code
63
70
  save_object "/monkeys", nil, 123, nil, nil
64
71
  get "/monkeys"
metadata CHANGED
@@ -1,183 +1,172 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: anmo
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.17
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 18
10
+ version: 0.0.18
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Andrew Vos
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-05-14 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rack
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: thin
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: thin
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: httparty
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: httparty
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
63
  name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: minitest
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
86
74
  type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: minitest
87
78
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rack-test
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
102
88
  type: :development
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: rack-test
103
92
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: cucumber
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
118
102
  type: :development
103
+ version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
105
+ name: cucumber
119
106
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
134
116
  type: :development
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: rspec
135
120
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: guard
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
150
130
  type: :development
131
+ version_requirements: *id008
132
+ - !ruby/object:Gem::Dependency
133
+ name: guard
151
134
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- - !ruby/object:Gem::Dependency
159
- name: guard-shell
160
- requirement: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
135
+ requirement: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
166
144
  type: :development
145
+ version_requirements: *id009
146
+ - !ruby/object:Gem::Dependency
147
+ name: guard-shell
167
148
  prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- description: ''
175
- email:
149
+ requirement: &id010 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ type: :development
159
+ version_requirements: *id010
160
+ description: ""
161
+ email:
176
162
  - andrew.vos@gmail.com
177
163
  executables: []
164
+
178
165
  extensions: []
166
+
179
167
  extra_rdoc_files: []
180
- files:
168
+
169
+ files:
181
170
  - .gitignore
182
171
  - .rvmrc
183
172
  - .travis.yml
@@ -193,31 +182,40 @@ files:
193
182
  - lib/anmo/application.rb
194
183
  - lib/anmo/version.rb
195
184
  - test/anmo/application_test.rb
196
- homepage: ''
185
+ homepage: ""
197
186
  licenses: []
187
+
198
188
  post_install_message:
199
189
  rdoc_options: []
200
- require_paths:
190
+
191
+ require_paths:
201
192
  - lib
202
- required_ruby_version: !ruby/object:Gem::Requirement
193
+ required_ruby_version: !ruby/object:Gem::Requirement
203
194
  none: false
204
- requirements:
205
- - - ! '>='
206
- - !ruby/object:Gem::Version
207
- version: '0'
208
- required_rubygems_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ hash: 3
199
+ segments:
200
+ - 0
201
+ version: "0"
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
203
  none: false
210
- requirements:
211
- - - ! '>='
212
- - !ruby/object:Gem::Version
213
- version: '0'
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ hash: 3
208
+ segments:
209
+ - 0
210
+ version: "0"
214
211
  requirements: []
212
+
215
213
  rubyforge_project: anmo
216
- rubygems_version: 1.8.21
214
+ rubygems_version: 1.8.17
217
215
  signing_key:
218
216
  specification_version: 3
219
- summary: ''
220
- test_files:
217
+ summary: ""
218
+ test_files:
221
219
  - features/api.feature
222
220
  - features/step_definitions/api_steps.rb
223
221
  - features/support/env.rb