Class: RSpec::Matchers::Sequel::ReferTo

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sequel_expectations/matchers/refer_to.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



31
32
33
34
35
36
37
38
39
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 31

def description
  text = [%(have reference to "#{@table}")]
  text << %(with column "#{@foreign_key}") if @foreign_key
  text << %(with primary key column "#{@primary_key}") if @primary_key
  text << %(with "#{@on_update}" action on update) if @on_update
  text << %(with "#{@on_delete}" action on delete) if @on_delete

  text.join(' ')
end

#failure_messageObject



41
42
43
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 41

def failure_message
  %(expected "#{@relation}" to #{description} but #{@error})
end

#failure_message_when_negatedObject



45
46
47
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 45

def failure_message_when_negated
  %(did not expect "#{@relation}" to #{description})
end

#from_fk(key) ⇒ Object



11
12
13
14
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 11

def from_fk(key)
  @foreign_key = key
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 5

def matches?(subject)
  get_reference_for(subject)

  refer_to? && correct_fk? && correct_pk? && correct_update? && correct_delete?
end

#on_delete(action) ⇒ Object



26
27
28
29
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 26

def on_delete(action)
  @on_delete = action
  self
end

#on_update(action) ⇒ Object



21
22
23
24
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 21

def on_update(action)
  @on_update = action
  self
end

#to_pk(key) ⇒ Object



16
17
18
19
# File 'lib/rspec/sequel_expectations/matchers/refer_to.rb', line 16

def to_pk(key)
  @primary_key = key
  self
end