|
9 | 9 |
|
10 | 10 | context "when file given as a String" do |
11 | 11 | let(:file) { fixture("the-http-gem.info").to_s } |
| 12 | + |
12 | 13 | it { is_expected.to eq fixture("the-http-gem.info").size } |
13 | 14 | end |
14 | 15 |
|
15 | 16 | context "when file given as a Pathname" do |
16 | 17 | let(:file) { fixture("the-http-gem.info") } |
| 18 | + |
17 | 19 | it { is_expected.to eq fixture("the-http-gem.info").size } |
18 | 20 | end |
19 | 21 |
|
20 | 22 | context "when file given as File" do |
21 | 23 | let(:file) { fixture("the-http-gem.info").open } |
| 24 | + |
22 | 25 | after { file.close } |
| 26 | + |
23 | 27 | it { is_expected.to eq fixture("the-http-gem.info").size } |
24 | 28 | end |
25 | 29 |
|
26 | 30 | context "when file given as IO" do |
27 | 31 | let(:file) { StringIO.new "привет мир!" } |
| 32 | + |
28 | 33 | it { is_expected.to eq 20 } |
29 | 34 | end |
30 | 35 | end |
|
34 | 39 |
|
35 | 40 | context "when file given as a String" do |
36 | 41 | let(:file) { fixture("the-http-gem.info").to_s } |
| 42 | + |
37 | 43 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
38 | 44 |
|
39 | 45 | it "rewinds content" do |
|
45 | 51 |
|
46 | 52 | context "when file given as a Pathname" do |
47 | 53 | let(:file) { fixture("the-http-gem.info") } |
| 54 | + |
48 | 55 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
49 | 56 |
|
50 | 57 | it "rewinds content" do |
|
56 | 63 |
|
57 | 64 | context "when file given as File" do |
58 | 65 | let(:file) { fixture("the-http-gem.info").open("rb") } |
| 66 | + |
59 | 67 | after { file.close } |
| 68 | + |
60 | 69 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
61 | 70 |
|
62 | 71 | it "rewinds content" do |
|
68 | 77 |
|
69 | 78 | context "when file given as IO" do |
70 | 79 | let(:file) { StringIO.new "привет мир!" } |
| 80 | + |
71 | 81 | it { is_expected.to eq "привет мир!" } |
72 | 82 |
|
73 | 83 | it "rewinds content" do |
|
83 | 93 |
|
84 | 94 | context "when file given as a String" do |
85 | 95 | let(:file) { fixture("the-http-gem.info").to_s } |
| 96 | + |
86 | 97 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
87 | 98 | end |
88 | 99 |
|
89 | 100 | context "when file given as a Pathname" do |
90 | 101 | let(:file) { fixture("the-http-gem.info") } |
| 102 | + |
91 | 103 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
92 | 104 | end |
93 | 105 |
|
94 | 106 | context "when file given as File" do |
95 | 107 | let(:file) { fixture("the-http-gem.info").open("rb") } |
| 108 | + |
96 | 109 | after { file.close } |
| 110 | + |
97 | 111 | it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } |
98 | 112 | end |
99 | 113 |
|
100 | 114 | context "when file given as IO" do |
101 | 115 | let(:file) { StringIO.new "привет мир!" } |
| 116 | + |
102 | 117 | it { is_expected.to eq "привет мир!" } |
103 | 118 | end |
104 | 119 | end |
|
126 | 141 |
|
127 | 142 | context "when file given as File" do |
128 | 143 | let(:file) { fixture("the-http-gem.info").open("rb") } |
| 144 | + |
129 | 145 | after { file.close } |
130 | 146 |
|
131 | 147 | it "rewinds the underlying IO object" do |
|
152 | 168 | context "when file given as a String" do |
153 | 169 | let(:file) { fixture("the-http-gem.info").to_s } |
154 | 170 |
|
155 | | - it { is_expected.to eq ::File.basename file } |
| 171 | + it { is_expected.to eq File.basename file } |
156 | 172 |
|
157 | | - context "and filename given with options" do |
| 173 | + context "with filename given in options" do |
158 | 174 | let(:opts) { { :filename => "foobar.txt" } } |
| 175 | + |
159 | 176 | it { is_expected.to eq "foobar.txt" } |
160 | 177 | end |
161 | 178 | end |
162 | 179 |
|
163 | 180 | context "when file given as a Pathname" do |
164 | 181 | let(:file) { fixture("the-http-gem.info") } |
165 | 182 |
|
166 | | - it { is_expected.to eq ::File.basename file } |
| 183 | + it { is_expected.to eq File.basename file } |
167 | 184 |
|
168 | | - context "and filename given with options" do |
| 185 | + context "with filename given in options" do |
169 | 186 | let(:opts) { { :filename => "foobar.txt" } } |
| 187 | + |
170 | 188 | it { is_expected.to eq "foobar.txt" } |
171 | 189 | end |
172 | 190 | end |
173 | 191 |
|
174 | 192 | context "when file given as File" do |
175 | 193 | let(:file) { fixture("the-http-gem.info").open } |
| 194 | + |
176 | 195 | after { file.close } |
177 | 196 |
|
178 | 197 | it { is_expected.to eq "the-http-gem.info" } |
179 | 198 |
|
180 | | - context "and filename given with options" do |
| 199 | + context "with filename given in options" do |
181 | 200 | let(:opts) { { :filename => "foobar.txt" } } |
| 201 | + |
182 | 202 | it { is_expected.to eq "foobar.txt" } |
183 | 203 | end |
184 | 204 | end |
|
188 | 208 |
|
189 | 209 | it { is_expected.to eq "stream-#{file.object_id}" } |
190 | 210 |
|
191 | | - context "and filename given with options" do |
| 211 | + context "with filename given in options" do |
192 | 212 | let(:opts) { { :filename => "foobar.txt" } } |
| 213 | + |
193 | 214 | it { is_expected.to eq "foobar.txt" } |
194 | 215 | end |
195 | 216 | end |
196 | 217 | end |
197 | 218 |
|
198 | 219 | describe "#content_type" do |
199 | | - let(:file) { StringIO.new } |
200 | 220 | subject { form_file.content_type } |
201 | 221 |
|
| 222 | + let(:file) { StringIO.new } |
| 223 | + |
202 | 224 | it { is_expected.to eq "application/octet-stream" } |
203 | 225 |
|
204 | 226 | context "when it was given with options" do |
205 | 227 | let(:opts) { { :content_type => "application/json" } } |
| 228 | + |
206 | 229 | it { is_expected.to eq "application/json" } |
207 | 230 | end |
208 | 231 | end |
209 | 232 |
|
210 | 233 | describe "#mime_type" do |
211 | | - it "should be an alias of #content_type" do |
| 234 | + it "is an alias of #content_type" do |
212 | 235 | expect(described_class.instance_method(:mime_type)) |
213 | 236 | .to eq(described_class.instance_method(:content_type)) |
214 | 237 | end |
|
0 commit comments