File: support_spec.rb

package info (click to toggle)
ruby-contracts 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 624 kB
  • sloc: ruby: 3,805; makefile: 4; sh: 2
file content (21 lines) | stat: -rw-r--r-- 689 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
module Contracts
  RSpec.describe Support do
    describe "eigenclass?" do
      it "is falsey for non-singleton classes" do
        expect(Contracts::Support.eigenclass? String).to be_falsey
      end

      it "is truthy for singleton classes" do
        singleton_class = String.instance_exec { class << self; self; end }
        expect(Contracts::Support.eigenclass? singleton_class).to be_truthy
      end
    end

    describe "eigenclass_of" do
      it "returns the eigenclass of a given object" do
        singleton_class = String.instance_exec { class << self; self; end }
        expect(Contracts::Support.eigenclass_of String).to eq singleton_class
      end
    end
  end
end