Sha256: 669c70f5e759f8690c6061569ca63c6cd6c25c66c979738ca806b83389da56bf

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

class ActiveSupport::TestCase
  ActiveRecord::Migration.check_pending!

  fixtures :all

  include FactoryGirl::Syntax::Methods

  # Get shoulda-context working in Rails 4
  include Shoulda::Context::Assertions
  include Shoulda::Context::InstanceMethods
  extend Shoulda::Context::ClassMethods

  # Get shoulda-matchers (for AR) working in Rails 4
  include Shoulda::Matchers::ActiveRecord
  extend Shoulda::Matchers::ActiveRecord
  include Shoulda::Matchers::ActiveModel
  extend Shoulda::Matchers::ActiveModel

  # Override shoulda-context
  #
  # Should be fixed by time Rails 4 actually comes out
  def assert_accepts(matcher, target, options = {})
    if matcher.respond_to?(:in_context)
      matcher.in_context(self)
    end

    if matcher.matches?(target)
      assert true
      if options[:message]
        assert_match options[:message], matcher.negative_failure_message
      end
    else
      assert false, matcher.failure_message
    end
  end

  # Override shoulda-context
  #
  # Should be fixed by time Rails 4 actually comes out
  def assert_rejects(matcher, target, options = {})
    if matcher.respond_to?(:in_context)
      matcher.in_context(self)
    end

    not_match = matcher.respond_to?(:does_not_match?) ? matcher.does_not_match?(target) : !matcher.matches?(target)

    if not_match
      assert true

      if options[:message]
        assert_match options[:message], matcher.failure_message
      end
    else
      assert false, matcher.failure_message
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
challah-1.1.0 test/edge_helper.rb
challah-1.0.0 test/edge_helper.rb
challah-1.0.0.beta3 test/edge_helper.rb
challah-1.0.0.beta2 test/edge_helper.rb