Module: ActiveAttr::Matchers

Defined in:
lib/active_attr/matchers.rb,
lib/active_attr/matchers/have_attribute_matcher.rb

Overview

Matchers that can be used with RSpec and Shoulda to declaritively verify models based on ActiveAttr modules

Examples:

Integrate with RSPec

require "active_attr/rspec"

Since:

  • 0.2.0

Defined Under Namespace

Classes: HaveAttributeMatcher

Instance Method Summary collapse

Instance Method Details

#have_attribute(attribute_name) ⇒ ActiveAttr::HaveAttributeMatcher

Specify that a model should have an attribute matching the criteria. See HaveAttributeMatcher

Examples:

Person should have a name attribute

describe Person do
  it { should have_attribute(:first_name) }
end

Parameters:

  • attribute_name (Symbol, String, #to_sym)

Returns:

  • (ActiveAttr::HaveAttributeMatcher)

Since:

  • 0.2.0



18
19
20
# File 'lib/active_attr/matchers/have_attribute_matcher.rb', line 18

def have_attribute(attribute_name)
  HaveAttributeMatcher.new(attribute_name)
end