Guarana Joe
Guarana Joe

Reputation: 743

How to stub parameters from a controller?

For my tests I need a controller where I can set my own parameters. With parameters I mean the one you get when invoking controller.params

{"action"=>"show",
 "controller"=>"merchants",
 "wine_id"=>"1",
 "id"=>"346343"}

The problem is, I don't know what the proper way for stubbing is here. There are three occurrences:

In all three the same information is stored, but what's the interfaced way to set these values?

Upvotes: 9

Views: 6544

Answers (1)

usha
usha

Reputation: 29349

Usual way of accessing params is by controller.params. So i would advise you to stub params

controller.stub(:params).and_return({:param1 => "value", :param2 => "value"})

Upvotes: 14

Related Questions