summaryrefslogtreecommitdiff
path: root/spec/config/attributable_spec.rb
blob: 9b6ea561c4305b36fd75d8d0572a60c6c10d83c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

RSpec.describe Pry::Config::Attributable do
  subject { klass.new }

  describe "#attribute" do
    let(:klass) do
      Class.new do
        extend Pry::Config::Attributable
        attribute :foo
      end
    end

    it "creates a reader attribute for the given name" do
      expect(klass.instance_method(:foo)).to be_a(UnboundMethod)
    end

    it "creates a writer attribute for the given name" do
      expect(klass.instance_method(:foo=)).to be_a(UnboundMethod)
    end

    context "and when the attribute is invoked" do
      it "sends the 'call' message to the value" do
        expect_any_instance_of(Pry::Config::Value).to receive(:call)
        subject.foo
      end
    end
  end
end