Sha256: 0bb7d02f64ffc92ab304127aa7e791abe035a1f5b12850a95e1252f05aadacca

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/module/delegation'
require 'active_support/concern'
require 'active_model/conversion'
require 'active_model/naming'
require 'active_model/lint'

module SearchObject
  module Plugin
    class ExtendedModel
      include SearchObject.module(:model)

      scope { [] }

      # Fake errors
      # Since SearchObject is focused on plain search forms,
      # validations are not needed most of the time
      def errors
        Hash.new([])
      end
    end

    describe ExtendedModel do
      include ActiveModel::Lint::Tests

      let(:model) { subject }

      def assert(condition, message = nil)
        expect(condition).to be_truthy, message
      end

      def assert_kind_of(expected_kind, object, message = nil)
        expect(object).to be_kind_of(expected_kind), message
      end

      def assert_equal(expected_value, value, message = nil)
        expect(value).to eq(expected_value), message
      end

      ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |method|
        example(method.tr('_', ' ')) { send method }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
search_object-1.2.0 spec/search_object/plugin/model_spec.rb
search_object-1.1.3 spec/search_object/plugin/model_spec.rb
search_object-1.1.2 spec/search_object/plugin/model_spec.rb