Sha256: a98dc2b52dd8f5a7cd5615ce91200c47a4b5a4291a29e4cd6666b0fbc4303259
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 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: "creates tuples dynamically" with: 'with_values: when: { Tuple with_values: [1,2,3] . is: (1,2,3) Tuple with_values: ["foo",'bar,42] . is: ("foo", 'bar, 42) Tuple with_values: ('hello, 'world) . is: ('hello, 'world) Tuple with_values: "test" . is: ("t","e","s","t") } 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] } it: "returns an array of all elements between two indices" with: 'from:to: when: { (1,2) from: 2 to: 3 . is: [] (1,2,3) from: 0 to: 2 . is: [1,2,3] (4,5,6,7,8,9) from: 3 to: 5 . is: [7,8,9] (1,2,3) from: 1 to: -1 . is: [2,3] } }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fancy-0.10.0 | tests/tuple.fy |
fancy-0.9.0 | tests/tuple.fy |
fancy-0.8.0 | tests/tuple.fy |