Created
April 11, 2012 17:08
-
-
Save kylewelsby/2360598 to your computer and use it in GitHub Desktop.
View Specs Real Example
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
if @grouped | |
object @days | |
node do |date| | |
node(:changed) { date[:changed].format } | |
node(:balance) { date[:balance].format } | |
child date[:transactions] => :transactions do | |
extends 'transactions/show' | |
end | |
node(:date) { date[:date] } | |
end | |
else | |
collection @transactions | |
extends 'transactions/show' | |
end |
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
require 'spec_helper' | |
describe "transactions/index" do | |
let(:user) {mock_model(User, accounts: [account])} | |
let(:account) { mock_model(Account, name: 'Test', balance: 0) } | |
let(:transaction) { | |
mock_model(Transaction, name: "test", amount: Money.new(1000)) | |
} | |
let(:day) { | |
{ | |
date: "2012-01-01", | |
balance: Money.new(100), | |
changed: Money.new(0), | |
transactions: [ | |
transaction | |
] | |
} | |
} | |
it "renders an array of transactions" do | |
assign(:days, [day]) | |
assign(:transactions, [transaction]) | |
render | |
JSON.parse(rendered).should be_an_instance_of Array | |
end | |
it "renders an array of days with transactions" do | |
assign(:days, [day]) | |
assign(:transactions, [transaction]) | |
assign(:grouped, true) | |
render | |
JSON.parse(rendered).should be_an_instance_of Array | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment