Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fast Rails Burro Test -- Modules
class BurritoDeliciousPolicy
def delicious?(burrito)
burrito.guacamole?
end
end
require_relative '../../app/models/burrito_delicious_policy'
describe BurritoDeliciousPolicy do
it "should be delicious when there is guac" do
subject.delicious?(stub( :guacamole? => true)).should be_true
end
it "should not de delicious without guac" do
subject.delicious?(stub( :guacamole? => false)).should be_false
end
end
class Burro < ActiveRecord::Base
include Deliciousness
# boolean guacamole defined in schema
end
require_relative '../../lib/deliciousness'
require_relative '../../app/models/burrito_delicious_policy'
class Burro
include Deliciousness
attr_accessor :guacamole
def guacamole?
true
end
end
describe Burro do
it "should tell the policy to decide if this is delicious" do
our_mock = mock BurritoDeliciousPolicy
our_mock.should_receive(:delicious?)
BurritoDeliciousPolicy.stub(:new => our_mock)
subject.delicious?
end
end
module Deliciousness
def delicious?
BurritoDeliciousPolicy.new.delicious?(self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.