I''m working on a Rails application having a REST API in JSON format and
versioned (according to this excellent Ryan''s cast:
http://railscasts.com/episodes/350-rest-api-versioning).
For instance, there is a spec/requests spec:
require ''spec_helper''
describe "My Friends" do
describe "GET /my/friends.json" do
it "should get my_friends_path" do
get v1_my_friends_path, {}, {''HTTP_ACCEPT'' =>
''application/vnd.myapp+json; level=1''}
response.status.should be(401)
end
end
end
And it works well.
But (keeping this example) how can we write the routing spec? For
instance this spec isn''t correct:
require ''spec_helper''
describe "friends routing" do
it "routes to #index" do
get("/my/friends.json", nil, {''HTTP_ACCEPT''
=>
''application/vnd.myapp+json; level=1''}).
should route_to({ action: "index",
controller: "api/v1/private/my/friends",
format: "json" })
end
end
...because `get` can take only 1 param.
I tried different ways (such as with request.headers[''Accept'']
or
@request.headers[''Accept'']... where request is undefined and
@request is
nil). I really don''t see how to do.
I''m on Ruby 1.9.3, Rails 3.2.6 and rspec-rails 2.11.0. Thanks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en-US.