Skip to content

Instantly share code, notes, and snippets.

@sue445
Created February 19, 2013 02:40
Show Gist options
  • Save sue445/4982648 to your computer and use it in GitHub Desktop.
Save sue445/4982648 to your computer and use it in GitHub Desktop.
[RSpec custom matcher] instance of array element are same class
# -*- coding: utf-8 -*-
require "rspec"
=begin
example)
[1, 2, 3].should array_instance_of Fixnum
=end
RSpec::Matchers.define :array_instance_of do |element_class|
match do |array|
array.class == Array && array.all? {|element| element.class == element_class}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment