double_entry 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -1
  3. data/.rubocop.yml +55 -0
  4. data/.travis.yml +23 -12
  5. data/README.md +5 -1
  6. data/Rakefile +8 -3
  7. data/double_entry.gemspec +4 -3
  8. data/lib/active_record/locking_extensions.rb +28 -40
  9. data/lib/active_record/locking_extensions/log_subscriber.rb +4 -4
  10. data/lib/double_entry.rb +0 -2
  11. data/lib/double_entry/account.rb +13 -16
  12. data/lib/double_entry/account_balance.rb +0 -4
  13. data/lib/double_entry/balance_calculator.rb +4 -5
  14. data/lib/double_entry/configurable.rb +0 -2
  15. data/lib/double_entry/configuration.rb +2 -3
  16. data/lib/double_entry/errors.rb +2 -2
  17. data/lib/double_entry/line.rb +13 -16
  18. data/lib/double_entry/locking.rb +13 -18
  19. data/lib/double_entry/reporting.rb +2 -3
  20. data/lib/double_entry/reporting/aggregate.rb +90 -88
  21. data/lib/double_entry/reporting/aggregate_array.rb +58 -58
  22. data/lib/double_entry/reporting/day_range.rb +37 -35
  23. data/lib/double_entry/reporting/hour_range.rb +40 -37
  24. data/lib/double_entry/reporting/line_aggregate.rb +27 -28
  25. data/lib/double_entry/reporting/month_range.rb +67 -67
  26. data/lib/double_entry/reporting/time_range.rb +40 -38
  27. data/lib/double_entry/reporting/time_range_array.rb +3 -5
  28. data/lib/double_entry/reporting/week_range.rb +77 -78
  29. data/lib/double_entry/reporting/year_range.rb +27 -27
  30. data/lib/double_entry/transfer.rb +14 -15
  31. data/lib/double_entry/validation/line_check.rb +92 -86
  32. data/lib/double_entry/version.rb +1 -1
  33. data/lib/generators/double_entry/install/install_generator.rb +1 -2
  34. data/lib/generators/double_entry/install/templates/migration.rb +0 -2
  35. data/script/jack_hammer +1 -1
  36. data/spec/active_record/locking_extensions_spec.rb +45 -38
  37. data/spec/double_entry/account_balance_spec.rb +4 -5
  38. data/spec/double_entry/account_spec.rb +43 -44
  39. data/spec/double_entry/balance_calculator_spec.rb +6 -8
  40. data/spec/double_entry/configuration_spec.rb +14 -16
  41. data/spec/double_entry/line_spec.rb +25 -26
  42. data/spec/double_entry/locking_spec.rb +34 -39
  43. data/spec/double_entry/reporting/aggregate_array_spec.rb +8 -10
  44. data/spec/double_entry/reporting/aggregate_spec.rb +84 -44
  45. data/spec/double_entry/reporting/line_aggregate_spec.rb +7 -6
  46. data/spec/double_entry/reporting/month_range_spec.rb +109 -103
  47. data/spec/double_entry/reporting/time_range_array_spec.rb +145 -135
  48. data/spec/double_entry/reporting/time_range_spec.rb +36 -35
  49. data/spec/double_entry/reporting/week_range_spec.rb +82 -76
  50. data/spec/double_entry/reporting_spec.rb +9 -13
  51. data/spec/double_entry/transfer_spec.rb +13 -15
  52. data/spec/double_entry/validation/line_check_spec.rb +73 -79
  53. data/spec/double_entry_spec.rb +65 -68
  54. data/spec/generators/double_entry/install/install_generator_spec.rb +7 -10
  55. data/spec/spec_helper.rb +68 -10
  56. data/spec/support/accounts.rb +2 -4
  57. data/spec/support/double_entry_spec_helper.rb +4 -4
  58. data/spec/support/gemfiles/Gemfile.rails-3.2.x +1 -0
  59. metadata +31 -2
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
- require 'spec_helper'
3
- module DoubleEntry::Reporting
4
- describe LineAggregate do
5
-
6
- it "has a table name prefixed with double_entry_" do
7
- expect(LineAggregate.table_name).to eq "double_entry_line_aggregates"
2
+ module DoubleEntry
3
+ module Reporting
4
+ RSpec.describe LineAggregate do
5
+ describe '.table_name' do
6
+ subject { LineAggregate.table_name }
7
+ it { should eq('double_entry_line_aggregates') }
8
+ end
8
9
  end
9
10
  end
10
11
  end
@@ -1,133 +1,139 @@
1
1
  # encoding: utf-8
2
- require "spec_helper"
3
- module DoubleEntry::Reporting
4
- describe MonthRange do
5
-
6
- describe "::from_time" do
7
- subject(:from_time) { MonthRange.from_time(given_time) }
8
-
9
- context "given the Time 31st March 2012" do
10
- let(:given_time) { Time.new(2012, 3, 31) }
11
- its(:year) { should eq 2012 }
12
- its(:month) { should eq 3 }
13
- end
2
+ module DoubleEntry
3
+ module Reporting
4
+ RSpec.describe MonthRange do
5
+ describe '.from_time' do
6
+ subject(:from_time) { MonthRange.from_time(given_time) }
7
+
8
+ context 'given the Time 31st March 2012' do
9
+ let(:given_time) { Time.new(2012, 3, 31) }
10
+ its(:year) { should eq 2012 }
11
+ its(:month) { should eq 3 }
12
+ end
14
13
 
15
- context "given the Date 31st March 2012" do
16
- let(:given_time) { Date.parse("2012-03-31") }
17
- its(:year) { should eq 2012 }
18
- its(:month) { should eq 3 }
19
- end
20
- end
14
+ context 'given the Date 31st March 2012' do
15
+ let(:given_time) { Date.parse('2012-03-31') }
16
+ its(:year) { should eq 2012 }
17
+ its(:month) { should eq 3 }
18
+ end
19
+ end
21
20
 
22
- describe "::reportable_months" do
23
- subject(:reportable_months) { MonthRange.reportable_months }
21
+ describe '.reportable_months' do
22
+ subject(:reportable_months) { MonthRange.reportable_months }
24
23
 
25
- context "The date is 1st March 1970" do
26
- before { Timecop.freeze(Time.new(1970, 3, 1)) }
24
+ context 'The date is 1st March 1970' do
25
+ before { Timecop.freeze(Time.new(1970, 3, 1)) }
27
26
 
28
- it { should eq [
29
- MonthRange.new(year: 1970, month: 1),
30
- MonthRange.new(year: 1970, month: 2),
31
- MonthRange.new(year: 1970, month: 3),
32
- ] }
27
+ specify do
28
+ should eq [
29
+ MonthRange.new(:year => 1970, :month => 1),
30
+ MonthRange.new(:year => 1970, :month => 2),
31
+ MonthRange.new(:year => 1970, :month => 3),
32
+ ]
33
+ end
33
34
 
34
- context "My business started on 5th Feb 1970" do
35
- before do
36
- DoubleEntry::Reporting.configure do |config|
37
- config.start_of_business = Time.new(1970, 2, 5)
35
+ context 'My business started on 5th Feb 1970' do
36
+ before do
37
+ DoubleEntry::Reporting.configure do |config|
38
+ config.start_of_business = Time.new(1970, 2, 5)
39
+ end
40
+ end
41
+
42
+ specify do
43
+ should eq [
44
+ MonthRange.new(:year => 1970, :month => 2),
45
+ MonthRange.new(:year => 1970, :month => 3),
46
+ ]
47
+ end
38
48
  end
39
49
  end
40
50
 
41
- it { should eq [
42
- MonthRange.new(year: 1970, month: 2),
43
- MonthRange.new(year: 1970, month: 3),
44
- ] }
45
- end
46
- end
51
+ context 'The date is 1st Jan 1970' do
52
+ before { Timecop.freeze(Time.new(1970, 1, 1)) }
47
53
 
48
- context "The date is 1st Jan 1970" do
49
- before { Timecop.freeze(Time.new(1970, 1, 1)) }
50
-
51
- it { should eq [ MonthRange.new(year: 1970, month: 1) ] }
52
- end
53
- end
54
-
55
- describe "::beginning_of_financial_year" do
56
- let(:month_range) { MonthRange.new(:year => year, :month => month) }
57
- let(:year) { 2014 }
58
-
59
- context "the first month of the financial year is July" do
60
- subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
61
- context "returns the current year if the month is after July" do
62
- let(:month) { 10 }
63
- it { should eq(MonthRange.new(:year => 2014, :month => 7)) }
54
+ it { should eq [MonthRange.new(:year => 1970, :month => 1)] }
55
+ end
64
56
  end
65
57
 
66
- context "returns the previous year if the month is before July" do
67
- let(:month) { 3 }
68
- it { should eq(MonthRange.new(:year => 2013, :month => 7)) }
69
- end
70
- end
58
+ describe '.beginning_of_financial_year' do
59
+ let(:month_range) { MonthRange.new(:year => year, :month => month) }
60
+ let(:year) { 2014 }
71
61
 
72
- context "the first month of the financial year is January" do
73
- subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
62
+ context 'the first month of the financial year is July' do
63
+ subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
64
+ context 'returns the current year if the month is after July' do
65
+ let(:month) { 10 }
66
+ it { should eq(MonthRange.new(:year => 2014, :month => 7)) }
67
+ end
74
68
 
75
- before do
76
- DoubleEntry::Reporting.configure do |config|
77
- config.first_month_of_financial_year = 1
69
+ context 'returns the previous year if the month is before July' do
70
+ let(:month) { 3 }
71
+ it { should eq(MonthRange.new(:year => 2013, :month => 7)) }
72
+ end
78
73
  end
79
- end
80
74
 
81
- context "returns the current year if the month is after January" do
82
- let(:month) { 10 }
83
- it { should eq(MonthRange.new(:year => 2014, :month => 1)) }
84
- end
75
+ context 'the first month of the financial year is January' do
76
+ subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
85
77
 
86
- context "returns the current year if the month is January" do
87
- let(:month) { 1 }
88
- it { should eq(MonthRange.new(:year => 2014, :month => 1)) }
89
- end
90
- end
78
+ before do
79
+ DoubleEntry::Reporting.configure do |config|
80
+ config.first_month_of_financial_year = 1
81
+ end
82
+ end
91
83
 
92
- context "the first month of the financial year is December" do
93
- subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
84
+ context 'returns the current year if the month is after January' do
85
+ let(:month) { 10 }
86
+ it { should eq(MonthRange.new(:year => 2014, :month => 1)) }
87
+ end
94
88
 
95
- before do
96
- DoubleEntry::Reporting.configure do |config|
97
- config.first_month_of_financial_year = 12
89
+ context 'returns the current year if the month is January' do
90
+ let(:month) { 1 }
91
+ it { should eq(MonthRange.new(:year => 2014, :month => 1)) }
92
+ end
98
93
  end
99
- end
100
94
 
101
- context "returns the previous year if the month is before December (in the same year)" do
102
- let(:month) { 11 }
103
- it { should eq(MonthRange.new(:year => 2013, :month => 12)) }
104
- end
95
+ context 'the first month of the financial year is December' do
96
+ subject(:beginning_of_financial_year) { month_range.beginning_of_financial_year }
105
97
 
106
- context "returns the previous year if the month is after December (in the next year)" do
107
- let(:year) { 2015 }
108
- let(:month) { 1 }
109
- it { should eq(MonthRange.new(:year => 2014, :month => 12)) }
110
- end
98
+ before do
99
+ DoubleEntry::Reporting.configure do |config|
100
+ config.first_month_of_financial_year = 12
101
+ end
102
+ end
111
103
 
112
- context "returns the current year if the month is December" do
113
- let(:month) { 12 }
114
- it { should eq(MonthRange.new(:year => 2014, :month => 12)) }
115
- end
116
- end
104
+ context 'returns the previous year if the month is before December (in the same year)' do
105
+ let(:month) { 11 }
106
+ it { should eq(MonthRange.new(:year => 2013, :month => 12)) }
107
+ end
108
+
109
+ context 'returns the previous year if the month is after December (in the next year)' do
110
+ let(:year) { 2015 }
111
+ let(:month) { 1 }
112
+ it { should eq(MonthRange.new(:year => 2014, :month => 12)) }
113
+ end
117
114
 
118
- context "Given a start time of 3rd Dec 1982" do
119
- subject(:reportable_months) { MonthRange.reportable_months(from: Time.new(1982, 12, 3)) }
115
+ context 'returns the current year if the month is December' do
116
+ let(:month) { 12 }
117
+ it { should eq(MonthRange.new(:year => 2014, :month => 12)) }
118
+ end
119
+ end
120
+
121
+ context 'Given a start time of 3rd Dec 1982' do
122
+ subject(:reportable_months) { MonthRange.reportable_months(:from => Time.new(1982, 12, 3)) }
120
123
 
121
- context "The date is 2nd Feb 1983" do
122
- before { Timecop.freeze(Time.new(1983, 2, 2)) }
124
+ context 'The date is 2nd Feb 1983' do
125
+ before { Timecop.freeze(Time.new(1983, 2, 2)) }
123
126
 
124
- it { should eq [
125
- MonthRange.new(year: 1982, month: 12),
126
- MonthRange.new(year: 1983, month: 1),
127
- MonthRange.new(year: 1983, month: 2),
128
- ] }
127
+ specify do
128
+ should eq [
129
+ MonthRange.new(:year => 1982, :month => 12),
130
+ MonthRange.new(:year => 1983, :month => 1),
131
+ MonthRange.new(:year => 1983, :month => 2),
132
+ ]
133
+ end
134
+ end
135
+ end
129
136
  end
130
137
  end
131
138
  end
132
- end
133
139
  end
@@ -1,159 +1,169 @@
1
- require 'spec_helper'
2
- module DoubleEntry::Reporting
3
- describe TimeRangeArray do
4
- describe '.make' do
5
- subject(:time_range_array) { TimeRangeArray.make(range_type, start, finish) }
6
-
7
- context 'for "hour" range type' do
8
- let(:range_type) { 'hour' }
9
-
10
- context 'given start is "2007-05-03 15:00:00" and finish is "2007-05-03 18:00:00"' do
11
- let(:start) { '2007-05-03 15:00:00' }
12
- let(:finish) { '2007-05-03 18:00:00' }
13
- it { should eq [
14
- HourRange.from_time(Time.new(2007, 5, 3, 15)),
15
- HourRange.from_time(Time.new(2007, 5, 3, 16)),
16
- HourRange.from_time(Time.new(2007, 5, 3, 17)),
17
- HourRange.from_time(Time.new(2007, 5, 3, 18)),
18
- ] }
19
- end
1
+ module DoubleEntry
2
+ module Reporting
3
+ RSpec.describe TimeRangeArray do
4
+ describe '.make' do
5
+ subject(:time_range_array) { TimeRangeArray.make(range_type, start, finish) }
6
+
7
+ context 'for "hour" range type' do
8
+ let(:range_type) { 'hour' }
9
+
10
+ context 'given start is "2007-05-03 15:00:00" and finish is "2007-05-03 18:00:00"' do
11
+ let(:start) { '2007-05-03 15:00:00' }
12
+ let(:finish) { '2007-05-03 18:00:00' }
13
+ specify do
14
+ should eq [
15
+ HourRange.from_time(Time.new(2007, 5, 3, 15)),
16
+ HourRange.from_time(Time.new(2007, 5, 3, 16)),
17
+ HourRange.from_time(Time.new(2007, 5, 3, 17)),
18
+ HourRange.from_time(Time.new(2007, 5, 3, 18)),
19
+ ]
20
+ end
21
+ end
20
22
 
21
- context 'given start and finish are nil' do
22
- it 'should raise an error' do
23
- expect { TimeRangeArray.make(range_type, nil, nil) }.
24
- to raise_error 'Must specify start of range'
23
+ context 'given start and finish are nil' do
24
+ it 'should raise an error' do
25
+ expect { TimeRangeArray.make(range_type, nil, nil) }.
26
+ to raise_error 'Must specify start of range'
27
+ end
28
+ end
25
29
  end
26
- end
27
- end
28
30
 
29
- context 'for "day" range type' do
30
- let(:range_type) { 'day' }
31
-
32
- context 'given start is "2007-05-03" and finish is "2007-05-07"' do
33
- let(:start) { '2007-05-03' }
34
- let(:finish) { '2007-05-07' }
35
- it { should eq [
36
- DayRange.from_time(Time.new(2007, 5, 3)),
37
- DayRange.from_time(Time.new(2007, 5, 4)),
38
- DayRange.from_time(Time.new(2007, 5, 5)),
39
- DayRange.from_time(Time.new(2007, 5, 6)),
40
- DayRange.from_time(Time.new(2007, 5, 7)),
41
- ] }
42
- end
43
-
44
- context 'given start and finish are nil' do
45
- it 'should raise an error' do
46
- expect { TimeRangeArray.make(range_type, nil, nil) }.
47
- to raise_error 'Must specify start of range'
48
- end
49
- end
50
- end
31
+ context 'for "day" range type' do
32
+ let(:range_type) { 'day' }
51
33
 
52
- context 'for "week" range type' do
53
- let(:range_type) { 'week' }
54
-
55
- context 'given start is "2007-05-03" and finish is "2007-05-24"' do
56
- let(:start) { '2007-05-03' }
57
- let(:finish) { '2007-05-24' }
58
- it { should eq [
59
- WeekRange.from_time(Time.new(2007, 5, 3)),
60
- WeekRange.from_time(Time.new(2007, 5, 10)),
61
- WeekRange.from_time(Time.new(2007, 5, 17)),
62
- WeekRange.from_time(Time.new(2007, 5, 24)),
63
- ] }
64
- end
34
+ context 'given start is "2007-05-03" and finish is "2007-05-07"' do
35
+ let(:start) { '2007-05-03' }
36
+ let(:finish) { '2007-05-07' }
37
+ specify do
38
+ should eq [
39
+ DayRange.from_time(Time.new(2007, 5, 3)),
40
+ DayRange.from_time(Time.new(2007, 5, 4)),
41
+ DayRange.from_time(Time.new(2007, 5, 5)),
42
+ DayRange.from_time(Time.new(2007, 5, 6)),
43
+ DayRange.from_time(Time.new(2007, 5, 7)),
44
+ ]
45
+ end
46
+ end
65
47
 
66
- context 'given start and finish are nil' do
67
- it 'should raise an error' do
68
- expect { TimeRangeArray.make(range_type, nil, nil) }.
69
- to raise_error 'Must specify start of range'
48
+ context 'given start and finish are nil' do
49
+ it 'should raise an error' do
50
+ expect { TimeRangeArray.make(range_type, nil, nil) }.
51
+ to raise_error 'Must specify start of range'
52
+ end
53
+ end
70
54
  end
71
- end
72
- end
73
55
 
74
- context 'for "month" range type' do
75
- let(:range_type) { 'month' }
76
-
77
- context 'given start is "2007-05-03" and finish is "2007-08-24"' do
78
- let(:start) { '2007-05-03' }
79
- let(:finish) { '2007-08-24' }
80
- it { should eq [
81
- MonthRange.from_time(Time.new(2007, 5)),
82
- MonthRange.from_time(Time.new(2007, 6)),
83
- MonthRange.from_time(Time.new(2007, 7)),
84
- MonthRange.from_time(Time.new(2007, 8)),
85
- ] }
86
- end
56
+ context 'for "week" range type' do
57
+ let(:range_type) { 'week' }
87
58
 
88
- context 'given finish is nil' do
89
- let(:start) { '2006-08-03' }
90
- let(:finish) { nil }
91
-
92
- context 'and the date is "2007-04-13"' do
93
- before { Timecop.freeze(Time.new(2007, 4, 13)) }
94
-
95
- it { should eq [
96
- MonthRange.from_time(Time.new(2006, 8)),
97
- MonthRange.from_time(Time.new(2006, 9)),
98
- MonthRange.from_time(Time.new(2006, 10)),
99
- MonthRange.from_time(Time.new(2006, 11)),
100
- MonthRange.from_time(Time.new(2006, 12)),
101
- MonthRange.from_time(Time.new(2007, 1)),
102
- MonthRange.from_time(Time.new(2007, 2)),
103
- MonthRange.from_time(Time.new(2007, 3)),
104
- MonthRange.from_time(Time.new(2007, 4)),
105
- ] }
106
- end
107
- end
108
- end
59
+ context 'given start is "2007-05-03" and finish is "2007-05-24"' do
60
+ let(:start) { '2007-05-03' }
61
+ let(:finish) { '2007-05-24' }
62
+ specify do
63
+ should eq [
64
+ WeekRange.from_time(Time.new(2007, 5, 3)),
65
+ WeekRange.from_time(Time.new(2007, 5, 10)),
66
+ WeekRange.from_time(Time.new(2007, 5, 17)),
67
+ WeekRange.from_time(Time.new(2007, 5, 24)),
68
+ ]
69
+ end
70
+ end
109
71
 
110
- context 'for "year" range type' do
111
- let(:range_type) { 'year' }
72
+ context 'given start and finish are nil' do
73
+ it 'should raise an error' do
74
+ expect { TimeRangeArray.make(range_type, nil, nil) }.
75
+ to raise_error 'Must specify start of range'
76
+ end
77
+ end
78
+ end
112
79
 
113
- context 'given the date is "2009-11-23"' do
114
- before { Timecop.freeze(Time.new(2009, 11, 23)) }
80
+ context 'for "month" range type' do
81
+ let(:range_type) { 'month' }
115
82
 
116
- context 'given start is "2007-05-03" and finish is "2008-08-24"' do
117
- let(:start) { '2007-05-03' }
118
- let(:finish) { '2008-08-24' }
83
+ context 'given start is "2007-05-03" and finish is "2007-08-24"' do
84
+ let(:start) { '2007-05-03' }
85
+ let(:finish) { '2007-08-24' }
86
+ specify do
87
+ should eq [
88
+ MonthRange.from_time(Time.new(2007, 5)),
89
+ MonthRange.from_time(Time.new(2007, 6)),
90
+ MonthRange.from_time(Time.new(2007, 7)),
91
+ MonthRange.from_time(Time.new(2007, 8)),
92
+ ]
93
+ end
94
+ end
119
95
 
96
+ context 'given finish is nil' do
97
+ let(:start) { '2006-08-03' }
98
+ let(:finish) { nil }
120
99
 
121
- it 'takes notice of start and finish' do
122
- should eq [
123
- YearRange.from_time(Time.new(2007)),
124
- YearRange.from_time(Time.new(2008)),
125
- ]
100
+ context 'and the date is "2007-04-13"' do
101
+ before { Timecop.freeze(Time.new(2007, 4, 13)) }
102
+
103
+ specify do
104
+ should eq [
105
+ MonthRange.from_time(Time.new(2006, 8)),
106
+ MonthRange.from_time(Time.new(2006, 9)),
107
+ MonthRange.from_time(Time.new(2006, 10)),
108
+ MonthRange.from_time(Time.new(2006, 11)),
109
+ MonthRange.from_time(Time.new(2006, 12)),
110
+ MonthRange.from_time(Time.new(2007, 1)),
111
+ MonthRange.from_time(Time.new(2007, 2)),
112
+ MonthRange.from_time(Time.new(2007, 3)),
113
+ MonthRange.from_time(Time.new(2007, 4)),
114
+ ]
115
+ end
116
+ end
126
117
  end
127
118
  end
128
119
 
129
- context 'given the start of business is "2006-07-10"' do
130
- before do
131
- allow(DoubleEntry::Reporting).
132
- to receive_message_chain('configuration.start_of_business').
133
- and_return(Time.new(2006, 7, 10))
120
+ context 'for "year" range type' do
121
+ let(:range_type) { 'year' }
122
+
123
+ context 'given the date is "2009-11-23"' do
124
+ before { Timecop.freeze(Time.new(2009, 11, 23)) }
125
+
126
+ context 'given start is "2007-05-03" and finish is "2008-08-24"' do
127
+ let(:start) { '2007-05-03' }
128
+ let(:finish) { '2008-08-24' }
129
+
130
+ it 'takes notice of start and finish' do
131
+ should eq [
132
+ YearRange.from_time(Time.new(2007)),
133
+ YearRange.from_time(Time.new(2008)),
134
+ ]
135
+ end
136
+ end
137
+
138
+ context 'given the start of business is "2006-07-10"' do
139
+ before do
140
+ allow(DoubleEntry::Reporting).
141
+ to receive_message_chain('configuration.start_of_business').
142
+ and_return(Time.new(2006, 7, 10))
143
+ end
144
+
145
+ context 'given start and finish are nil' do
146
+ let(:start) { nil }
147
+ let(:finish) { nil }
148
+ specify do
149
+ should eq [
150
+ YearRange.from_time(Time.new(2006)),
151
+ YearRange.from_time(Time.new(2007)),
152
+ YearRange.from_time(Time.new(2008)),
153
+ YearRange.from_time(Time.new(2009)),
154
+ ]
155
+ end
156
+ end
157
+ end
134
158
  end
159
+ end
135
160
 
136
- context 'given start and finish are nil' do
137
- let(:start) { nil }
138
- let(:finish) { nil }
139
- it {
140
- should eq [
141
- YearRange.from_time(Time.new(2006)),
142
- YearRange.from_time(Time.new(2007)),
143
- YearRange.from_time(Time.new(2008)),
144
- YearRange.from_time(Time.new(2009)),
145
- ]
146
- }
161
+ context 'given an invalid range type "ueue"' do
162
+ it 'should raise an error' do
163
+ expect { TimeRangeArray.make('ueue') }.to raise_error ArgumentError
147
164
  end
148
165
  end
149
166
  end
150
167
  end
151
-
152
- context 'given an invalid range type "ueue"' do
153
- it 'should raise an error' do
154
- expect { TimeRangeArray.make('ueue') }.to raise_error ArgumentError
155
- end
156
- end
157
168
  end
158
- end
159
169
  end