class SchemaExpectations::RSpecMatchers::Base

Public Instance Methods

except(*args) click to toggle source

Specifies a list of columns for matcher to ignore

@return self

# File lib/schema_expectations/rspec_matchers/base.rb, line 21
def except(*args)
  fail 'cannot use only and except' if @only
  @except = Array(args)
  fail 'empty except list' if @except.empty?
  self
end
only(*args) click to toggle source

Specifies a list of columns to restrict matcher

@return self

# File lib/schema_expectations/rspec_matchers/base.rb, line 11
def only(*args)
  fail 'cannot use only and except' if @except
  @only = Array(args)
  fail 'empty only list' if @only.empty?
  self
end

Private Instance Methods

cast_model(model) click to toggle source
# File lib/schema_expectations/rspec_matchers/base.rb, line 36
def cast_model(model)
  model = model.class if model.is_a?(::ActiveRecord::Base)
  unless model.is_a?(Class) && model.ancestors.include?(::ActiveRecord::Base)
    fail "#{model.inspect} does not inherit from ActiveRecord::Base"
  end
  model
end
setup(model) click to toggle source
# File lib/schema_expectations/rspec_matchers/base.rb, line 30
def setup(model)
  @model = cast_model model
  @validation_reflector = ActiveRecord::ValidationReflector.new(@model)
  @column_reflector = ActiveRecord::ColumnReflector.new(@model)
end