Skip to content

Instantly share code, notes, and snippets.

@adamgamble
Created May 6, 2010 19:00
Show Gist options
  • Save adamgamble/392555 to your computer and use it in GitHub Desktop.
Save adamgamble/392555 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe TellerIncentiveReport do
before(:all) do
teller1 = flexmock(User.new)
teller2 = flexmock(User.new)
teller3 = flexmock(User.new)
teller4 = flexmock(User.new)
stores = flexmock(Store.new)
flexmock(stores).should_receive(:last).and_return stores
flexmock(stores).should_receive(:store_number).and_return("abc")
teller1.should_receive(:id).and_return 1
teller1.should_receive(:login).and_return "test_login1"
teller1.should_receive(:teller_id).and_return 1
teller1.should_receive(:name).and_return "test1"
teller1.should_receive(:stores).and_return stores
teller2.should_receive(:id).and_return 2
teller2.should_receive(:login).and_return "test_login2"
teller2.should_receive(:teller_id).and_return 2
teller2.should_receive(:name).and_return "test2"
teller2.should_receive(:stores).and_return stores
teller3.should_receive(:id).and_return 3
teller3.should_receive(:login).and_return "test_login3"
teller3.should_receive(:teller_id).and_return 3
teller3.should_receive(:name).and_return "test3"
teller3.should_receive(:stores).and_return stores
teller4.should_receive(:id).and_return 4
teller4.should_receive(:login).and_return "test_login4"
teller4.should_receive(:teller_id).and_return 4
teller4.should_receive(:name).and_return "test4"
teller4.should_receive(:stores).and_return stores
tellers = [teller1,teller2,teller3,teller4]
flexmock(tellers).should_receive(:all).and_return tellers
flexmock(Agent).should_receive(:find)
@controller = TellerIncentiveReport.new
flexmock(@controller).should_receive(:get_tellers).and_return tellers
flexmock(@controller).should_receive(:get_card_creation_transaction_count).with(1).and_return(25)
flexmock(@controller).should_receive(:get_card_creation_transaction_count).with(2).and_return(19)
flexmock(@controller).should_receive(:get_card_creation_transaction_count).with(3).and_return(9)
flexmock(@controller).should_receive(:get_card_creation_transaction_count).with(4).and_return(4)
@response = @controller.run
end
it "should return an array with 4 elements" do
@response.count.should == 4
end
it "element 1 should payout 180" do
@response[0][:amount_to_payout].should == 180
end
it "element 2 should payout 115" do
@response[1][:amount_to_payout].should == 115
end
it "element 3 should payout 45" do
@response[2][:amount_to_payout].should == 45
end
it "element 4 should payout 0" do
@response[3][:amount_to_payout].should == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment