0
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
-describe AccountOutlineViewDelegate, '
initWithTransactionView(transaction_view)' do
0
+describe AccountOutlineViewDelegate, '
.initWithTransactionView(transaction_view)' do
0
it "store the transaction_view reference in the class" do
0
transaction_view = mock('transaction_view')
0
delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(transaction_view)
0
@@ -8,18 +8,53 @@ describe AccountOutlineViewDelegate, 'initWithTransactionView(transaction_view)'
0
-describe AccountOutlineViewDelegate, 'outlineViewSelectionDidChange(notification)' do
0
- it "create a new TransactionOutlineViewDataSource with the selected account and set it as the transaction view data source (TODO: Make this less messy)" do
0
+describe AccountOutlineViewDelegate, '#outlineViewSelectionDidChange(notification)' do
0
+ it "sets up the transaction view with the selected account" do
0
account = stub('account')
0
- outline_view = stub('outline_view')
0
- outline_view.stub!(:selectedRow).and_return(1)
0
- outline_view.stub!(:itemAtRow).and_return(account)
0
- notification = stub('notification', :object => outline_view)
0
+ notification = stub('notification', :object => stub('outline_view', :selectedItem => account))
0
+ account_delegate = AccountOutlineViewDelegate.alloc
0
+ account_delegate.should_receive(:set_transaction_view_data_source).with(account)
0
+ account_delegate.should_receive(:set_transaction_view_column_titles).with(account)
0
+ account_delegate.initWithTransactionView(stub('transaction_view')).outlineViewSelectionDidChange(notification)
0
+describe AccountOutlineViewDelegate, '#set_transaction_view_data_source(account)' do
0
+ @account = stub('account')
0
+ @transaction_view = stub_everything('transaction view')
0
+ @delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(@transaction_view)
0
+ it "creates a new TransactionOutlineViewDataSource with the account" do
0
transaction_view_data_source = mock('transaction_view_data_source')
0
TransactionOutlineViewDataSource.should_receive(:alloc).and_return(transaction_view_data_source)
0
- transaction_view_data_source.should_receive(:initWithAccount).with(account).and_return(transaction_view_data_source)
0
- transaction_view = mock('transaction_view')
0
- transaction_view.should_receive(:dataSource=).with(transaction_view_data_source)
0
- AccountOutlineViewDelegate.alloc.initWithTransactionView(transaction_view).outlineViewSelectionDidChange(notification)
0
+ transaction_view_data_source.should_receive(:initWithAccount).with(@account)
0
+ @delegate.set_transaction_view_data_source(@account)
0
+ it "sets the transaction view data source to the new object" do
0
+ data_source = stub_everything('data source')
0
+ TransactionOutlineViewDataSource.should_receive(:alloc).and_return(data_source)
0
+ @transaction_view.should_receive(:dataSource=).with(data_source)
0
+ @delegate.set_transaction_view_data_source(@account)
0
+describe AccountOutlineViewDelegate, '#set_transaction_view_column_titles(account)' do
0
+ @account = stub('account', :debit_title => 'debit', :credit_title => 'credit')
0
+ @transaction_view = stub_everything('transaction view')
0
+ @delegate = AccountOutlineViewDelegate.alloc.initWithTransactionView(@transaction_view)
0
+ it "sets the debit_cents column title with debit_title for the account" do
0
+ @transaction_view.should_receive(:setTableColumnWithIdentifier_headerStringValue).with('debit_cents', 'debit')
0
+ @delegate.set_transaction_view_column_titles(@account)
0
+ it "sets the credit_cents column title with credit_title for the account" do
0
+ @transaction_view.should_receive(:setTableColumnWithIdentifier_headerStringValue).with('credit_cents', 'credit')
0
+ @delegate.set_transaction_view_column_titles(@account)
0
\ No newline at end of file
Comments
No one has commented yet.