Created
August 7, 2008 22:26
-
-
Save arthurschreiber/4508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveSupport::ArrayExtensions::flatten() | |
- should correctly flatten the passed multi-dimensional arrays down to a single-dimensional array | |
- should correctly flatten associative arrays | |
ActiveSupport::ArrayExtensions::first() | |
- should return the first item of the passed array | |
ActiveSupport::ArrayExtensions::last() | |
- should return the last item of the passed array | |
Finished in 0.0016219615936279 seconds | |
4 examples, 0 failures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FsckUnit; | |
require_once dirname(__FILE__) . "/spec_helper.php"; | |
describe("ActiveSupport::ArrayExtensions::flatten()", function() { | |
it("should correctly flatten the passed multi-dimensional arrays down to a single-dimensional array", function() { | |
$flattened = ActiveSupport::ArrayExtensions::flatten(array(1, 2, 3, array(4, 5, 6))); | |
expect($flattened)->to("equal", array(1, 2, 3, 4, 5, 6)); | |
}); | |
it("should correctly flatten associative arrays", function() { | |
$flattened = ActiveSupport::ArrayExtensions::flatten(array("a" => 1, "b" => 2, "c" => 3)); | |
expect($flattened)->to("equal", array(1, 2, 3)); | |
}); | |
}); | |
describe("ActiveSupport::ArrayExtensions::first()", function() { | |
it("should return the first item of the passed array", function() { | |
$first = ActiveSupport::ArrayExtensions::first(array(1, 2, 3)); | |
expect($first)->to("equal", 1); | |
}); | |
}); | |
describe("ActiveSupport::ArrayExtensions::last()", function() { | |
it("should return the last item of the passed array", function() { | |
$last = ActiveSupport::ArrayExtensions::last(array(1, 2, 3)); | |
expect($last)->to("equal", 3); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment