<commit_before>require "active_support/test_case"

module Idioms
  module Test
    module Assertions
      
      
      def refute_raises(exception)
        yield
      rescue exception
        flunk "#{$!.class} was raised\n#{$!.message}\n#{$!.backtrace.join("\n")}"
      end
      
      def assert_valid(record, message=nil)
        assert record.valid?, message || "You expected #{record.class.name.downcase} to be valid, but it wasn't"
      end
      
      def refute_valid(record, message=nil)
        refute record.valid?, message || "You expected #{record.class.name.downcase} to be **invalid**, but it wasn't"
      end
      
    end
  end
end

ActiveSupport::TestCase.send :include, Idioms::Test::Assertions<commit_msg>[refactor] Added validation error messages to assert_valid<commit_after>require "active_support/test_case"

module Idioms
  module Test
    module Assertions
      
      
      def refute_raises(exception)
        yield
      rescue exception
        flunk "#{$!.class} was raised\n#{$!.message}\n#{$!.backtrace.join("\n")}"
      end
      
      def assert_valid(record)
        assert record.valid?, "Expected #{record.class.name.downcase} to be valid, but\n" <<
          record.errors.full_messages.map { |message| " * #{message}" }.join("\n")
      end
      
      def refute_valid(record, message=nil)
        refute record.valid?, message || "Expected #{record.class.name.downcase} to be **invalid**, but it wasn't"
      end
      
    end
  end
end

ActiveSupport::TestCase.send :include, Idioms::Test::Assertions
{'fraction_non_alphanumeric': 0.12379730596536241, 'fraction_numerical': 0.0, 'mean_word_length': 2.7320574162679425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6318390', 'n_tokens_mistral': 476, 'n_tokens_neox': 462, 'n_words': 115}