Sha256: a279b56c530c65fb6703bbf722c7c4047205e0635267783ac93290ce99858663

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

class GenericExample
  Contract Args[String], { repeat: Maybe[Num] } => ArrayOf[String]
  def splat_then_optional_named(*vals, repeat: 2)
    vals.map { |v| v * repeat }
  end
end

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

  describe "Optional named arguments" do
    it "should work with optional named argument unfilled after splat" do
      expect { @o.splat_then_optional_named("hello", "world") }.to_not raise_error
    end

    it "should work with optional named argument filled after splat" do
      expect { @o.splat_then_optional_named("hello", "world", repeat: 3) }.to_not raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contracts-0.8 spec/ruby_version_specific/contracts_spec_2.0.rb