Created
September 30, 2011 19:07
-
-
Save fahim/1254682 to your computer and use it in GitHub Desktop.
What's the best way to test this method?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Employee Discount model | |
class Discount::Employee < Discount | |
def compute?(order) | |
raise "look at MerchandiserStandard.compute?" | |
order.front_end? && | |
order.credit_adjustments.empty? && | |
order.discount_adjustments.empty? && | |
order.promotion_credits.empty? && | |
order.has_only_customer_products? && | |
can_use?(self.user) | |
end | |
end | |
# Employee Discount spec | |
describe Discount::Employee do | |
subject { Discount::Employee.new } | |
describe "compute?" do | |
let(:order) { mock_model(Order, :credit_adjustments => [], :discount_adjustments => [], :promotion_credits => []) } | |
before { subject.stubs(:user) } | |
it "should call the right methods" do | |
order.discount_adjustments.should_receive(:empty?) | |
order.should_receive(:front_end?) | |
order.promotion_credits.should_receive(:empty?) | |
order.should_receive(:has_only_customer_products?) | |
subject.should_receive(:can_use?) | |
subject.compute?(order) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment