Sha256: 173c3c70d269ddef31ea46f2322cce72b9313c6875ce5e44d683fbbaccb315ad

Contents?: true

Size: 528 Bytes

Versions: 3

Compression:

Stored size: 528 Bytes

Contents

class GenericExample
  Contract Args[String], Num => ArrayOf[String]
  def splat_then_arg(*vals, n)
    vals.map { |v| v * n }
  end

  if ruby_version <= 1.9
    Contract ({:foo => 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contracts-0.10.1 spec/ruby_version_specific/contracts_spec_1.9.rb
contracts-0.10 spec/ruby_version_specific/contracts_spec_1.9.rb
contracts-0.9 spec/ruby_version_specific/contracts_spec_1.9.rb