Class: Remarkable::ActiveRecord::Matchers::ColumnMatcher

Inherits:
Matcher::Base
  • Object
show all
Defined in:
lib/remarkable/active_record/macros/database/have_db_column_matcher.rb

Instance Method Summary collapse

Methods inherited from Matcher::Base

#negative, #spec

Methods included from Matcher::DSL

included, #matches?

Instance Method Details

#descriptionObject



36
37
38
39
40
41
42
43
44
# File 'lib/remarkable/active_record/macros/database/have_db_column_matcher.rb', line 36

def description
  description = if @columns.size == 1
    "have column named :#{@columns[0]}"
  else
    "have columns #{@columns.to_sentence}"
  end
  description << " with options " + @options.inspect unless @options.empty?
  description
end

#failure_messageObject



28
29
30
# File 'lib/remarkable/active_record/macros/database/have_db_column_matcher.rb', line 28

def failure_message
  "Expected #{expectation} (#{@missing})"
end

#negative_failure_messageObject



32
33
34
# File 'lib/remarkable/active_record/macros/database/have_db_column_matcher.rb', line 32

def negative_failure_message
  "Did not expect #{expectation}"
end

#of_type(type) ⇒ Object

TODO: remove it



12
13
14
15
16
# File 'lib/remarkable/active_record/macros/database/have_db_column_matcher.rb', line 12

def of_type(type)
  warn "[DEPRECATION] option of_type is deprecated in have_db_column. Use type instead."
  @options[:type] = type
  self
end

#with_options(opts = {}) ⇒ Object

Method used to load all options via hash. (:type, :default, :precision, :limit, :scale, :sql_type, :primary, :null)



21
22
23
24
# File 'lib/remarkable/active_record/macros/database/have_db_column_matcher.rb', line 21

def with_options(opts = {})
  @options.merge!(opts)
  self
end