fluke/devops-service/spec/support/array_matcher.rb

13 lines
363 B
Ruby
Raw Normal View History

2015-11-20 18:31:54 +03:00
RSpec::Matchers.define :be_an_array_of do |klass|
match do |actual|
actual.class == Array &&
actual.all? {|item| item.class == klass}
end
end
RSpec::Matchers.define :have_size do |length|
match { |actual| actual.length == length }
failure_message do |actual|
"expected #{actual} to have size #{expected} but have #{actual.length}"
end
end