Sha256: aa3929afc0b50d6bd79f89c242ad2ffe8289b1440e346073332346b3814ed286

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

require 'unit_spec_helper'

describe Shoulda::Matchers::ActionController::RouteParams, type: :controller 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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
shoulda-matchers-3.1.3 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-4.0.0.rc1 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.1.2 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.1.1 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.1.0 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.0.1 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.0.0 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-3.0.0.rc1 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/action_controller/route_params_spec.rb