File: attributable_spec.rb

package info (click to toggle)
pry 0.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,788 kB
  • sloc: ruby: 21,638; sh: 17; makefile: 11
file content (29 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (4)
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