Try self.extended. For instance, the following code should print 'PASS' =
along with the error message:

---

module AgeBasedApprovable
  def self.extended(base)
    unless base.respond_to?(:birthdate)
      raise 'Objects that extend AgeBasedApprovable must provide a =
birthdate method'
    end
  end
end

o =3D Object.new

# monkey patch o for testing purposes
def o.birthdate
  Time.now
end

# this should not raise an error
o.extend(AgeBasedApprovable)

o =3D Object.new

begin
  o.extend(AgeBasedApprovable)
  puts 'FAIL'
rescue =3D> e
  puts 'PASS: ', e.message
end

---

On Dec 11, 2011, at 7:59 PM, Grary Stimon wrote:

> Hey,
>=20
> What is the corresponding code in the AgeBasedApprovable module to =
beget
> the behavior in the test below? If it is use of self.included, I've =
not
> been able to get it to work...
>=20
> describe AgeBasedApprovable do
>  it "requires host object to provide a 'birthdate' method" do
>    host =3D Object.new
>    expect do
>      host.extend(AgeBasedApprovable)
>    end.to raise_error(/Objects that extend AgeBasedApprovable must
> provide a 'birthdate' method/)
>  end
> end
>=20
> Thanks,
>=20
> Grar
>=20
> --=20
> Posted via http://www.ruby-forum.com/.
>=20