2014-10-26 20:51:42 -04:00
|
|
|
require 'unit_spec_helper'
|
2013-10-15 18:12:17 -04:00
|
|
|
|
2014-12-24 16:37:04 -05:00
|
|
|
describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
|
2013-10-15 18:12:17 -04:00
|
|
|
describe "#normalize" do
|
|
|
|
context "when the route parameters is a hash" do
|
|
|
|
it "stringifies the values in the hash" do
|
2014-01-17 17:01:43 -05:00
|
|
|
expect(build_route_params(controller: :examples, action: 'example', id: '1').normalize).
|
|
|
|
to eq({ controller: "examples", action: "example", id: "1" })
|
2013-10-15 18:12:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the route parameters is a string and a hash" do
|
|
|
|
it "produces a hash of route parameters" do
|
2014-01-17 17:01:43 -05:00
|
|
|
expect(build_route_params("examples#example", id: '1').normalize).
|
|
|
|
to eq({ controller: "examples", action: "example", id: "1" })
|
2013-10-15 18:12:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the route params is a string" do
|
|
|
|
it "produces a hash of route params" do
|
2014-01-17 17:01:43 -05:00
|
|
|
expect(build_route_params("examples#index").normalize).
|
|
|
|
to eq({ controller: "examples", action: "index"})
|
2013-10-15 18:12:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_route_params(*params)
|
|
|
|
Shoulda::Matchers::ActionController::RouteParams.new(params)
|
|
|
|
end
|
|
|
|
end
|