module Inspector::Constraints
Public Instance Methods
be_email()
click to toggle source
# File lib/inspector/constraints.rb, line 38 def be_email Email.new end
Also aliased as: be_an_email
be_empty()
click to toggle source
# File lib/inspector/constraints.rb, line 21 def be_empty Empty.new end
be_false()
click to toggle source
# File lib/inspector/constraints.rb, line 13 def be_false False.new end
be_true()
click to toggle source
# File lib/inspector/constraints.rb, line 17 def be_true True.new end
eq(expected)
click to toggle source
# File lib/inspector/constraints.rb, line 43 def eq(expected) Eq.new(expected) end
have(n)
click to toggle source
# File lib/inspector/constraints.rb, line 33 def have(n) Have::Exactly.new(n) end
Also aliased as: have_exactly
have_at_least(n)
click to toggle source
# File lib/inspector/constraints.rb, line 25 def have_at_least(n) Have::AtLeast.new(n) end
have_at_most(n)
click to toggle source
# File lib/inspector/constraints.rb, line 29 def have_at_most(n) Have::AtMost.new(n) end
method_missing(method, *args, &block)
click to toggle source
be_empty
=> value.empty? be_nil => value.nil?
Calls superclass method
# File lib/inspector/constraints.rb, line 53 def method_missing(method, *args, &block) prefix, *predicate = method.to_s.split("_") predicate.shift if ["a", "an"].include?(predicate.first) return Inspector::Constraints::Predicate.new(predicate.join("_"), *args, &block) if prefix == "be" # return Inspector::Constraints::Has.new(method, *args, &block) if method.to_s =~ /^have_/ super end
validate(options = {})
click to toggle source
# File lib/inspector/constraints.rb, line 47 def validate(options = {}) Valid.new(options[:as]) end