Sha256: b3d92340ab4ca32a183a217606cbaa04af65f8d54c032b6b20da464bb666069b
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 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 } it: "runs a Block for each element" with: 'each: when: { sum = 0 vals = [] (1,2,3) each: |x| { sum = sum + x vals << x } sum is: 6 vals is: [1,2,3] } it: "runs a Block for each element in reverse order" with: 'reverse_each: when: { sum = 0 vals = [] (1,2,3) reverse_each: |x| { sum = sum + x vals << x } sum is: 6 vals is: [3,2,1] } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fancy-0.5.0 | tests/tuple.fy |