Forum: RSpec [rspec] How to pass route parameters to post method?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3d9c33db9c320c170d5593488200a911?d=identicon&s=25 Evgeny Bogdanov (Guest)
on 2009-06-02 09:53
(Received via mailing list)
Hello,

I am trying to spec an action in a controller, and rspec doesn't find
a route.
It seems that problem is in ":viewtype". If I change a line
"/:viewtype/asset/add"
into "/context/asset/add" in routes it works.

I tried also
post "/context/asset/add", no luck.

Could you please let me know how I can call the action through
that route with post method?

Thank you in advance,
Evgeny
=====================
  map.with_options(:controller => "assets", :conditions =>{:method
=> :post}) do |m|
    m.create_asset                   '/:viewtype/asset/
add',                        :action => 'create'
  end

describe AssetsController, "when working with formats" do
  it "should call a find_asset_format for some actions" do
    post :create
  end
end
B6adc9e099cf9c257e5e29d8be8ebe4c?d=identicon&s=25 Mike Sassak (Guest)
on 2009-06-04 22:18
(Received via mailing list)
Hi Evgeny,

You didn't include the error message in your email, so this is just a
guess,
but from your example, it looks like you need to specify :viewtype in
your
call to post, like so:

post :create, :viewtype => 'context'

The HTTP verb methods require you to specify the route parameters in
order
to work.

Mike

On Jun 2, 2009 3:53 AM, "Evgeny Bogdanov" <evgeny.bogdanov@gmail.com>
wrote:

Hello,

I am trying to spec an action in a controller, and rspec doesn't find
a route.
It seems that problem is in ":viewtype". If I change a line
"/:viewtype/asset/add"
into "/context/asset/add" in routes it works.

I tried also
post "/context/asset/add", no luck.

Could you please let me know how I can call the action through
that route with post method?

Thank you in advance,
Evgeny
=====================
 map.with_options(:controller => "assets", :conditions =>{:method
=> :post}) do |m|
   m.create_asset                   '/:viewtype/asset/
add',                        :action => 'create'
 end

describe AssetsController, "when working with formats" do
 it "should call a find_asset_format for some actions" do
   post :create
 end
end
3d9c33db9c320c170d5593488200a911?d=identicon&s=25 Evgeny Bogdanov (Guest)
on 2009-06-05 15:00
(Received via mailing list)
Hello Mike,

Thank you for your hint. Obviously, it worked!
Laughing at myself now: how post method was supposed to know what I
mean by :viewtype if don't specify it :)

Best,
Evgeny
This topic is locked and can not be replied to.