Sha256: a4d3c4bde7e80ff18890b48f609da057b566aba2bae4cdc3e339a8f33820275b

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

FancySpec describe: Tuple with: {
  it: "has the correct amount of elements" with: 'size when: {
    (1,2) size is: 2
    (1,2,3) size is: 3
    ('foo, "bar", 'baz, 123) size is: 4
  }

  it: "has the correct items at a given index" with: 'at: when: {
    tuple = ("foo", 'bar, "baz")
    tuple at: 0 . is: "foo"
    tuple at: 1 . is: 'bar
    tuple at: 2 . is: "baz"
  }

  it: "has the correct items at a given index" with: '[] when: {
    tuple = ("foo", 'bar, "baz")
    tuple[0] . is: "foo"
    tuple[1] . is: 'bar
    tuple[2] . is: "baz"
  }

  it: "creates a new tuple with values set to nil" with: 'new: when: {
    t = Tuple new: 2
    t size is: 2
    t[0] is: nil
    t[1] is: nil
  }

  it: "does not allow to create an empty Tuple" with: 'new when: {
    { Tuple new } raises: ArgumentError
  }

  it: "does not allow to create a Tuple with less than 2 elements" with: 'new: when: {
    { Tuple new: -1 } raises: ArgumentError
    { Tuple new: 0 } raises: ArgumentError
    { Tuple new: 1 } raises: ArgumentError
    { Tuple new: 2 } does_not raise: ArgumentError
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.4.0 tests/tuple.fy