Skip to content

Instantly share code, notes, and snippets.

@southpolesteve
Created October 11, 2012 04:57
Show Gist options
  • Save southpolesteve/3870266 to your computer and use it in GitHub Desktop.
Save southpolesteve/3870266 to your computer and use it in GitHub Desktop.
# 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