Created
October 11, 2012 04:57
-
-
Save southpolesteve/3870266 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Custom RSpec matcher to test that an array contains only a single class of object | |
| RSpec::Matchers.define :contain_only_instances_of do |expected| | |
| match do |actual| | |
| classes = actual.map(&:class).uniq | |
| classes.size == 1 && classes.first == expected | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment