mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00

* Change 'spec' Rake task to 'spec:unit' * Require unit_spec_helper.rb in unit tests, not spec_helper.rb * Re-namespace files in spec/support/unit under UnitTests * Files in spec/support/unit/helpers no longer automatically add themselves to RSpec - this happens in unit_spec_helper.rb * Extract RecordWithDifferentErrorAttributeBuilder and RecordValidatingConfirmationBuilder to separate files
30 lines
1 KiB
Ruby
30 lines
1 KiB
Ruby
require 'unit_spec_helper'
|
|
|
|
describe Shoulda::Matchers::ActionController::RouteParams do
|
|
describe "#normalize" do
|
|
context "when the route parameters is a hash" do
|
|
it "stringifies the values in the hash" do
|
|
expect(build_route_params(controller: :examples, action: 'example', id: '1').normalize).
|
|
to eq({ controller: "examples", action: "example", id: "1" })
|
|
end
|
|
end
|
|
|
|
context "when the route parameters is a string and a hash" do
|
|
it "produces a hash of route parameters" do
|
|
expect(build_route_params("examples#example", id: '1').normalize).
|
|
to eq({ controller: "examples", action: "example", id: "1" })
|
|
end
|
|
end
|
|
|
|
context "when the route params is a string" do
|
|
it "produces a hash of route params" do
|
|
expect(build_route_params("examples#index").normalize).
|
|
to eq({ controller: "examples", action: "index"})
|
|
end
|
|
end
|
|
end
|
|
|
|
def build_route_params(*params)
|
|
Shoulda::Matchers::ActionController::RouteParams.new(params)
|
|
end
|
|
end
|