Sha256: b4c75e429b026a05c1b2939fe256825d38c715305ec4a4fd5b04ae6498088985

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

RSpec.describe Aldous::Params do
  describe "::build" do
    it "instantiates a new params object" do
      expect(described_class).to receive(:new)
      described_class.build({})
    end
  end

  describe "#fetch" do
    let(:params_object) {described_class.new(params)}
    let(:params) { {} }

    context "when error occurs" do
      before do
        allow(params_object).to receive(:permitted_params).and_raise(RuntimeError.new)
        allow(Aldous::LoggingWrapper).to receive(:log)
      end

      it "logs the error" do
        expect(Aldous::LoggingWrapper).to receive(:log)
        params_object.fetch
      end

      it "returns nil" do
        expect(params_object.fetch).to be_nil
      end
    end

    context "when no error occurs" do
      before do
        allow(params_object).to receive(:permitted_params).and_return('hello')
      end

      it "returns the permitted_params" do
        expect(params_object.fetch).to eq 'hello'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aldous-1.1.3 spec/aldous/params_spec.rb
aldous-1.1.2 spec/aldous/params_spec.rb
aldous-1.0.1 spec/aldous/params_spec.rb
aldous-1.0.0 spec/aldous/params_spec.rb