Module: Warp::ModelMatchers

Defined in:
lib/warp/model_matchers/matcher.rb,
lib/warp/model_matchers/error_matcher.rb,
lib/warp/model_matchers/attribute_matcher.rb,
lib/warp/model_matchers/validation_matcher.rb,
lib/warp/model_matchers/association_matcher.rb

Defined Under Namespace

Classes: AssociationMatcher, AttributeMatcher, ErrorMatcher, Matcher, ValidationMatcher

Instance Method Summary collapse

Instance Method Details

#belong_to(key) ⇒ Object



54
55
56
# File 'lib/warp/model_matchers/association_matcher.rb', line 54

def belong_to(key)
  AssociationMatcher.new(:belongs_to, key)
end

#have_and_belong_to_many(key) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/warp/model_matchers/association_matcher.rb', line 58

def have_and_belong_to_many(key)
  if ActiveRecord::VERSION::STRING[0] == "4" && ActiveRecord::VERSION::STRING[3] != "0"
    raise NotImplementedError, "In Rail 4.1+ the has_and_belongs_to_many helper produces a has_many :through association."
  else
    AssociationMatcher.new(:has_and_belongs_to_many, key)
  end
end

#have_attribute(attr_name) ⇒ Object



37
38
39
# File 'lib/warp/model_matchers/attribute_matcher.rb', line 37

def have_attribute(attr_name)
  AttributeMatcher.new(attr_name)
end

#have_errorObject



7
8
9
# File 'lib/warp/model_matchers/error_matcher.rb', line 7

def have_error

end

#have_many(key) ⇒ Object



46
47
48
# File 'lib/warp/model_matchers/association_matcher.rb', line 46

def have_many(key)
  AssociationMatcher.new(:has_many, key)
end

#have_one(key) ⇒ Object



50
51
52
# File 'lib/warp/model_matchers/association_matcher.rb', line 50

def have_one(key)
  AssociationMatcher.new(:has_one, key)
end