Class: RspecSequel::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/rspec_sequel/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attribute, options = {}) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
11
|
# File 'lib/rspec_sequel/base.rb', line 6
def initialize(attribute, options={})
raise ArgumentError, "not enough params for matcher, required attribute is missing" if attribute.nil?
@attribute = attribute
@options = options
@description = []
end
|
Instance Method Details
#failure_message ⇒ Object
22
23
24
|
# File 'lib/rspec_sequel/base.rb', line 22
def failure_message
[@prefix, description, @suffix].flatten.compact.join(" ")
end
|
#hash_to_nice_string(hash) ⇒ Object
28
29
30
|
# File 'lib/rspec_sequel/base.rb', line 28
def hash_to_nice_string(hash)
hash.sort{|a,b| a[0].to_s<=>b[0].to_s}.collect{|param| param.collect{|v| v.inspect}.join(" => ")}.join(", ")
end
|
#matches?(target) ⇒ Boolean
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rspec_sequel/base.rb', line 12
def matches?(target)
@suffix = []
if target.is_a?(Sequel::Model)
@prefix = "expected #{target.inspect} to"
valid?(target.db, target, target.class, @attribute, @options)
else
@prefix = "expected #{target.table_name.to_s.classify} to"
valid?(target.db, target.new, target, @attribute, @options)
end
end
|
#negative_failure_message ⇒ Object
25
26
27
|
# File 'lib/rspec_sequel/base.rb', line 25
def negative_failure_message
[@prefix, "not", description, @suffix].flatten.compact.join(" ")
end
|