|
9 | 9 | } |
10 | 10 | ) |
11 | 11 | end |
| 12 | + |
12 | 13 | specify { expect(subject.path).to eq('public/downloads/cites_listings/') } |
13 | 14 | end |
14 | | - describe :export do |
| 15 | + |
| 16 | + describe :export, cache: true do |
15 | 17 | context 'when no results' do |
16 | 18 | subject do |
17 | 19 | Species::ListingsExportFactory.new( |
|
22 | 24 | } |
23 | 25 | ) |
24 | 26 | end |
| 27 | + |
25 | 28 | specify { expect(subject.export).to be_falsey } |
26 | 29 | end |
| 30 | + |
27 | 31 | context 'when results' do |
28 | 32 | before(:each) do |
29 | 33 | FileUtils.mkpath( |
|
32 | 36 | allow_any_instance_of(Species::ListingsExport).to receive(:path). |
33 | 37 | and_return('spec/public/downloads/cites_listings/') |
34 | 38 | end |
| 39 | + |
35 | 40 | after(:each) do |
36 | 41 | FileUtils.remove_dir('spec/public/downloads/cites_listings', true) |
37 | 42 | end |
| 43 | + |
38 | 44 | subject do |
39 | 45 | Species::ListingsExportFactory.new( |
40 | 46 | { |
|
44 | 50 | } |
45 | 51 | ) |
46 | 52 | end |
| 53 | + |
47 | 54 | context 'when file not cached' do |
48 | 55 | specify do |
49 | 56 | subject.export |
50 | 57 | expect(File.file?(subject.file_name)).to be_truthy |
51 | 58 | end |
52 | 59 | end |
| 60 | + |
53 | 61 | context 'when file cached' do |
54 | 62 | specify do |
55 | 63 | FileUtils.touch(subject.file_name) |
|
59 | 67 | end |
60 | 68 | end |
61 | 69 | end |
| 70 | + |
62 | 71 | describe :query do |
63 | 72 | context 'when CITES' do |
64 | 73 | context 'when Appendix I' do |
|
70 | 79 | } |
71 | 80 | ) |
72 | 81 | end |
| 82 | + |
73 | 83 | specify { expect(subject.query.to_a.size).to eq(1) } |
74 | 84 |
|
75 | 85 | context 'when Poland' do |
|
82 | 92 | } |
83 | 93 | ) |
84 | 94 | end |
| 95 | + |
85 | 96 | specify { expect(subject.query.to_a.size).to eq(0) } |
86 | 97 | end |
87 | 98 |
|
|
95 | 106 | } |
96 | 107 | ) |
97 | 108 | end |
| 109 | + |
98 | 110 | specify { expect(subject.query.to_a.size).to eq(1) } |
99 | 111 | end |
100 | 112 | end |
| 113 | + |
101 | 114 | context 'when higher taxon ids' do |
102 | 115 | subject do |
103 | 116 | Species::ListingsExportFactory.new( |
|
107 | 120 | } |
108 | 121 | ) |
109 | 122 | end |
| 123 | + |
110 | 124 | specify { expect(subject.query.to_a.size).to eq(1) } |
111 | 125 | end |
| 126 | + |
112 | 127 | context 'when implicitly listed subspecies present' do |
113 | 128 | before(:each) do |
114 | 129 | create_cites_eu_subspecies( |
115 | 130 | parent_id: @species.id |
116 | 131 | ) |
117 | 132 | SapiModule::StoredProcedures.rebuild_cites_taxonomy_and_listings |
118 | 133 | end |
| 134 | + |
119 | 135 | subject do |
120 | 136 | Species::ListingsExportFactory.new( |
121 | 137 | { |
|
124 | 140 | } |
125 | 141 | ) |
126 | 142 | end |
| 143 | + |
127 | 144 | specify { expect(subject.query.to_a.size).to eq(1) } |
128 | 145 | end |
129 | 146 | end |
| 147 | + |
130 | 148 | context 'when EU' do |
131 | 149 | context 'when Annex A' do |
132 | 150 | subject do |
|
137 | 155 | } |
138 | 156 | ) |
139 | 157 | end |
| 158 | + |
140 | 159 | specify { expect(subject.query.to_a.size).to eq(1) } |
141 | 160 |
|
142 | 161 | context 'when Spain' do |
|
149 | 168 | } |
150 | 169 | ) |
151 | 170 | end |
| 171 | + |
152 | 172 | specify { expect(subject.query.to_a.size).to eq(0) } |
153 | 173 | end |
154 | 174 |
|
|
162 | 182 | } |
163 | 183 | ) |
164 | 184 | end |
| 185 | + |
165 | 186 | specify { expect(subject.query.to_a.size).to eq(1) } |
166 | 187 | end |
167 | 188 | end |
| 189 | + |
168 | 190 | context 'when higher taxon ids' do |
169 | 191 | subject do |
170 | 192 | Species::ListingsExportFactory.new( |
|
174 | 196 | } |
175 | 197 | ) |
176 | 198 | end |
| 199 | + |
177 | 200 | specify { expect(subject.query.to_a.size).to eq(1) } |
178 | 201 | end |
179 | 202 | end |
|
0 commit comments