api_taster 0.4.6 → 0.4.7
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.
- data/README.md +16 -1
- data/app/controllers/api_taster/application_controller.rb +8 -0
- data/lib/api_taster.rb +3 -0
- data/lib/api_taster/mapper.rb +2 -2
- data/lib/api_taster/version.rb +1 -1
- data/spec/mapper_spec.rb +20 -0
- data/spec/route_spec.rb +4 -0
- metadata +6 -4
data/README.md
CHANGED
@@ -19,7 +19,7 @@ API Taster compared to alternatives, have the following advantages:
|
|
19
19
|
Add API Taster in your gemfile:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem 'api_taster'
|
22
|
+
gem 'api_taster'
|
23
23
|
```
|
24
24
|
Mount API Taster, this will allow you to visit API Taster from within your app. For example:
|
25
25
|
|
@@ -63,6 +63,21 @@ end
|
|
63
63
|
|
64
64
|
If you use a test factory such as [FactoryGirl](https://github.com/thoughtbot/factory_girl), you can require your test factories and share the params. For example in FactoryGirl you can use the `attributes_for(:name_of_factory)` method.
|
65
65
|
|
66
|
+
### Global Params
|
67
|
+
|
68
|
+
If there are certain params (such as API version and auth token) that need to be present in every API endpoint, you may set them in `ApiTaster.global_params` before `ApiTaster.routes`:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
ApiTaster.global_params = {
|
72
|
+
:version => 1,
|
73
|
+
:auth_token => 'teGpfbVitpnUwm7qStf9'
|
74
|
+
}
|
75
|
+
|
76
|
+
ApiTaster.routes do
|
77
|
+
# your route definitions
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
66
81
|
### Missing Route Definitions Detection
|
67
82
|
|
68
83
|
Instead of manually finding out which route definitions you need, API Taster provides a warning page that shows you all the missing definitions.
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module ApiTaster
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
layout proc { |controller| controller.request.xhr? ? nil : 'api_taster/application' }
|
4
|
+
|
5
|
+
before_filter :reload_routes
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def reload_routes
|
10
|
+
load Rails.application.root.join('config/routes.rb')
|
11
|
+
end
|
4
12
|
end
|
5
13
|
end
|
data/lib/api_taster.rb
CHANGED
data/lib/api_taster/mapper.rb
CHANGED
data/lib/api_taster/version.rb
CHANGED
data/spec/mapper_spec.rb
CHANGED
@@ -24,7 +24,27 @@ module ApiTaster
|
|
24
24
|
|
25
25
|
before(:all) do
|
26
26
|
Rails.application.routes.draw { resources :dummy_users }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#global_params" do
|
30
|
+
before(:all) do
|
31
|
+
ApiTaster.global_params = { :foo => 'bar' }
|
32
|
+
|
33
|
+
ApiTaster.routes do
|
34
|
+
get '/dummy_users/:id', :id => 1
|
35
|
+
end
|
36
|
+
|
37
|
+
Route.map_routes
|
38
|
+
end
|
27
39
|
|
40
|
+
it "merges params" do
|
41
|
+
route = Route.find_by_verb_and_path(:get, '/dummy_users/:id')
|
42
|
+
|
43
|
+
Route.supplied_params[route[:id]].should == [{ :foo => 'bar', :id => 1 }]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
before(:all) do
|
28
48
|
ApiTaster.routes do
|
29
49
|
get '/dummy_users/:id', :id => 1
|
30
50
|
post '/dummy_users'
|
data/spec/route_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_taster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- spec/dummy/tmp/cache/sass/f455898439b6313d4297be03fbcfa4df713cf294/_bootstrap.scssc
|
340
340
|
- spec/dummy/tmp/cache/sass/fced329c33ec1fff188d99efbc4d1fd1c556b66a/bootstrap.min.cssc
|
341
341
|
- spec/dummy/tmp/cache/sass/fced329c33ec1fff188d99efbc4d1fd1c556b66a/layout.css.scssc
|
342
|
+
- spec/dummy/tmp/pids/server.pid
|
342
343
|
homepage: https://github.com/fredwu/api_taster
|
343
344
|
licenses: []
|
344
345
|
post_install_message:
|
@@ -353,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
353
354
|
version: '0'
|
354
355
|
segments:
|
355
356
|
- 0
|
356
|
-
hash:
|
357
|
+
hash: 2450223208085472037
|
357
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
358
359
|
none: false
|
359
360
|
requirements:
|
@@ -362,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
362
363
|
version: '0'
|
363
364
|
segments:
|
364
365
|
- 0
|
365
|
-
hash:
|
366
|
+
hash: 2450223208085472037
|
366
367
|
requirements: []
|
367
368
|
rubyforge_project:
|
368
369
|
rubygems_version: 1.8.24
|
@@ -500,6 +501,7 @@ test_files:
|
|
500
501
|
- spec/dummy/tmp/cache/sass/f455898439b6313d4297be03fbcfa4df713cf294/_bootstrap.scssc
|
501
502
|
- spec/dummy/tmp/cache/sass/fced329c33ec1fff188d99efbc4d1fd1c556b66a/bootstrap.min.cssc
|
502
503
|
- spec/dummy/tmp/cache/sass/fced329c33ec1fff188d99efbc4d1fd1c556b66a/layout.css.scssc
|
504
|
+
- spec/dummy/tmp/pids/server.pid
|
503
505
|
- spec/form_builder_spec.rb
|
504
506
|
- spec/mapper_spec.rb
|
505
507
|
- spec/route_spec.rb
|