Sha256: fe7e2faad995f1a2c511fa3262ea864d4bca671ee9c578c8488ffb9f0491452d

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

describe Interactor do
  describe ".require_in_context" do
    let(:interactor) do
      Class.new do
        include Interactor
        require_in_context :foo
      end
    end

    it "fails if the argument isn't passed in" do
      expect { interactor.call }.to raise_error(ArgumentError)
    end

    it "fails if the argument is is nil" do
      expect { interactor.call(foo: nil) }.to raise_error(ArgumentError)
    end

    it "succeeds if the argument is passed in" do
      expect { interactor.call(foo: "bar") }.not_to raise_error
    end
  end

  describe ".delegate_to_context" do
    let(:interactor) do
      Class.new do
        include Interactor
        delegate_to_context :foo

        def call
          foo
        end
      end
    end
    let(:context) { double("Context") }

    it "delegates to the context" do
      expect_any_instance_of(Interactor::Context).to receive(:[]).with(:foo).once
      interactor.call
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
interactor-schema-0.2.2 spec/interactor/schema/interactor_extension_spec.rb
interactor-schema-0.2.1 spec/interactor/schema/interactor_extension_spec.rb
interactor-schema-0.2.0 spec/interactor/schema/interactor_extension_spec.rb