|
7 | 7 |
|
8 | 8 | describe '#generate_csv_stream' do |
9 | 9 | subject do |
10 | | - rows = "" |
11 | | - described_class.new(distributions: distributions, organization: organization, filters: filters).generate_csv_stream do |row| |
12 | | - rows << row |
13 | | - end |
14 | | - rows |
| 10 | + Proc.new { described_class.new(distributions: distributions, organization: organization, filters: filters).generate_csv_stream } |
15 | 11 | end |
16 | 12 |
|
17 | 13 | let(:duplicate_item) { create(:item, name: "Dupe Item", value_in_cents: 300, organization: organization, package_size: 2) } |
|
66 | 62 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 2,Disposable Diapers,0,0,2,0,0 |
67 | 63 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 3,Disposable Diapers,0,0,0,0,3 |
68 | 64 | CSV |
69 | | - expect(subject).to eq(csv) |
| 65 | + subject do |subject_row| |
| 66 | + expect(row).to eq(csv.next) |
| 67 | + end |
70 | 68 | end |
71 | 69 | end |
72 | 70 |
|
|
81 | 79 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 2,Disposable Diapers,0,0.00,0,0.00,2,60.00,0,0.00,0,0.00 |
82 | 80 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 3,Disposable Diapers,0,0.00,0,0.00,0,0.00,0,0.00,3,120.00 |
83 | 81 | CSV |
84 | | - expect(subject).to eq(csv) |
| 82 | + subject do |subject_row| |
| 83 | + expect(row).to eq(csv.next) |
| 84 | + end |
85 | 85 | end |
86 | 86 | end |
87 | 87 |
|
|
96 | 96 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 2,Disposable Diapers,0,0,0,0,2,0,0,0,0,0 |
97 | 97 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 3,Disposable Diapers,0,0,0,0,0,0,0,0,3,0 |
98 | 98 | CSV |
99 | | - expect(subject).to eq(csv) |
| 99 | + subject do |subject_row| |
| 100 | + expect(row).to eq(csv.next) |
| 101 | + end |
100 | 102 | end |
101 | 103 | end |
102 | 104 |
|
|
112 | 114 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 2,Disposable Diapers,0,0.00,0,0,0.00,0,2,60.00,0,0,0.00,0,0,0.00,0 |
113 | 115 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 3,Disposable Diapers,0,0.00,0,0,0.00,0,0,0.00,0,0,0.00,0,3,120.00,0 |
114 | 116 | CSV |
115 | | - expect(subject).to eq(csv) |
| 117 | + subject do |subject_row| |
| 118 | + expect(row).to eq(csv.next) |
| 119 | + end |
116 | 120 | end |
117 | 121 | end |
118 | 122 |
|
|
134 | 138 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 2,Disposable Diapers,0,0,2,0,0,0 |
135 | 139 | #{partner.name},04/04/2025,04/04/2025,#{storage_location.name},0,0.0,shipped,$15.01,scheduled,"",comment 3,Disposable Diapers,0,0,0,0,3,0 |
136 | 140 | CSV |
137 | | - expect(subject).to eq(csv) |
| 141 | + |
| 142 | + subject do |subject_row| |
| 143 | + expect(row).to eq(csv.next) |
| 144 | + end |
138 | 145 | end |
139 | 146 | end |
140 | 147 |
|
141 | 148 | context 'reporting category column' do |
142 | 149 | let(:filters) { {} } |
143 | 150 |
|
| 151 | + subject do |
| 152 | + rows = "" |
| 153 | + described_class.new(distributions: distributions, organization: organization, filters: filters).generate_csv_stream do |row| |
| 154 | + rows << row |
| 155 | + end |
| 156 | + rows |
| 157 | + end |
| 158 | + |
144 | 159 | it 'includes a Reporting Category column with the humanized category for each distribution' do |
145 | 160 | csv = CSV.parse(subject, headers: true) |
146 | 161 | expect(csv.headers).to include("Reporting Category") |
|
185 | 200 | csv = <<~CSV |
186 | 201 | Partner,Initial Allocation,Scheduled for,Source Inventory,Total Number of #{item_name},Total Value of #{item_name},Delivery Method,Shipping Cost,Status,Agency Representative,Comments,Reporting Category,Dupe Item |
187 | 202 | CSV |
188 | | - expect(subject).to eq(csv) |
| 203 | + subject do |subject_row| |
| 204 | + expect(row).to eq(csv.next) |
| 205 | + end |
189 | 206 | end |
190 | 207 | end |
191 | 208 | end |
|
0 commit comments