Sha256: 62a72efc71f1edf4fa35fd96d6f4e344c0eba3f6110e236d0f465c4ae1ea8157

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

require 'spec_helper'

class DummyInterFaceForPurifiableWithError
  
  include ParamsPurifier::Purifiable

end

class DummyInterFaceForPurifiable
  
  include ParamsPurifier::Purifiable

  private

    def params  
      { "ids" => [""] }
    end

end


describe ParamsPurifier::Purifiable do

  describe "#purified_params" do

    it "raises error if interface doesn't implement params method" do
      expect do 
        DummyInterFaceForPurifiableWithError.new.purified_params
      end.to raise_error ParamsPurifier::Purifiable::ParamsMethodNotImplementedError
    end

    it "returns purified params" do
      result = { "ids" => [] }
      expect(DummyInterFaceForPurifiable.new.purified_params).to eq result
    end

    it "returns instance of ActionController::Parameters" do
      expect(DummyInterFaceForPurifiable.new.purified_params).to be_instance_of ActionController::Parameters
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
params_purifier-0.0.1 spec/params_purifier/purifiable_spec.rb