# Common matchers for hexx/exceptions specs RSpec::Matchers.define :inherit do |ancestor| match do |subject| expect(subject.ancestors).to be_include ancestor end end RSpec::Matchers.define :have_error_message do |header| match do |subject| object = double "object" errors = double "errors" allow(object).to receive(:errors) { errors } begin fail subject.new(object) rescue => error expect(error.message).to eq "#{ header }: #{ errors.inspect }" end end end