File: invariants_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 (17 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Contracts
  RSpec.describe Invariants do
    def new_subject
      MyBirthday.new(31, 12)
    end

    it "works when all invariants are holding" do
      expect { new_subject.clever_next_day! }.not_to raise_error
      expect { new_subject.clever_next_month! }.not_to raise_error
    end

    it "raises invariant violation error when any of invariants are not holding" do
      expect { new_subject.silly_next_day! }.to raise_error(InvariantError, /day condition to be true/)
      expect { new_subject.silly_next_month! }.to raise_error(InvariantError, /month condition to be true/)
    end
  end
end