lib/tram/policy/rspec.rb in tram-policy-1.0.0 vs lib/tram/policy/rspec.rb in tram-policy-1.0.1

- old
+ new

@@ -15,12 +15,15 @@ attr_reader :errors def missed_translations @missed_translations ||= \ - errors.flat_map { |rec| rec.values_at(*locales) } - .select { |message| message.start_with? "translation missing" } + errors + .flat_map { |rec| rec.values_at(*locales) } + .select do |message| + message.is_a?(String) && message.start_with?("translation missing") + end end def report_errors locales.each_with_object("Actual errors:\n") do |loc, text| text << " #{loc}:\n" @@ -55,13 +58,15 @@ end end RSpec::Matchers.define :be_invalid do match do |policy| + return expect(policy.valid?).to(be_falsey) unless policy.is_a?(Tram::Policy) expect(policy).to be_invalid_at end match_when_negated do |policy| + return expect(policy.valid?).to(be_truthy) unless policy.is_a?(Tram::Policy) expect(policy).not_to be_invalid_at end end RSpec::Matchers.define :be_valid_at do |**tags|