File: contracts_spec_1.9.rb

package info (click to toggle)
ruby-contracts 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 624 kB
  • sloc: ruby: 3,805; makefile: 4; sh: 2
file content (24 lines) | stat: -rw-r--r-- 540 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
class GenericExample
  Contract C::Args[String], C::Num => C::ArrayOf[String]
  def splat_then_arg(*vals, n)
    vals.map { |v| v * n }
  end

  if ruby_version <= 1.9
    Contract ({:foo => C::Nat}) => nil
    def nat_test_with_kwarg(a_hash)
    end
  end
end

RSpec.describe "Contracts:" do
  before :all do
    @o = GenericExample.new
  end

  describe "Splat not last (or penultimate to block)" do
    it "should work with arg after splat" do
      expect { @o.splat_then_arg("hello", "world", 3) }.to_not raise_error
    end
  end
end