tessa 0.8.0 → 0.9.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f249bb180317b0210a3ccb8ac00990203ef3b958
4
- data.tar.gz: d1977678af1fd84081e3ecc11b67469461c9d0ac
3
+ metadata.gz: ac462c5f0a7aa2daace117558422af800c250103
4
+ data.tar.gz: 62f7cccb50d516daa41af3be26cc4b8ad21e1f1e
5
5
  SHA512:
6
- metadata.gz: 6cfbfe4952713a3d56f5f35fe440135f1da9bc41d44e43e2a0db496729a599bf78916b587ea9f4c897765410630755f7ac32442591e8dc365c04f1da96a04caa
7
- data.tar.gz: 590c79b194d50cb6e0d5db7399ab8e65ed4b6e47d4bd3396cc3eca03be8b0068e787b6d5185bf1a7ddf29bd159a2e76d5710fb1ff7f70332911c12e57161fd76
6
+ metadata.gz: 0c4160d6068721988ed852f6402562c770f851c72cec0db7abbef3422e3bcf053772b77a472b6e657ca9dd8f81217ac0c4139ba9c7976e4a5fb807d638fc06ce
7
+ data.tar.gz: e0bc84f6c3941eb8ca00f80a2f54c08bf22473e29a26dfc6663790b8bc8b21d597851f38690c2308c3525df3bb98cf554e72b68edcadd156a4439158377b4f3a
@@ -30,7 +30,12 @@ module Tessa
30
30
  end
31
31
 
32
32
  def self.create(file:, **options)
33
- Upload.create(options).upload_file(file)
33
+ default_options = {
34
+ size: File.size(file),
35
+ name: File.basename(file),
36
+ date: File.mtime(file),
37
+ }
38
+ Upload.create(default_options.merge(options)).upload_file(file)
34
39
  end
35
40
 
36
41
  def failure?
@@ -1,3 +1,3 @@
1
1
  module Tessa
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -153,18 +153,44 @@ RSpec.describe Tessa::Asset do
153
153
 
154
154
  it "requires a file param" do
155
155
  expect { described_class.create }.to raise_error(ArgumentError)
156
- expect { described_class.create(file: "abc") }.to_not raise_error
156
+ expect { described_class.create(file: __FILE__) }.to_not raise_error
157
157
  end
158
158
 
159
159
  it "creates a new upload" do
160
- expect(Tessa::Upload).to receive(:create).with(foo: :bar, baz: :boom).and_return(upload)
161
- described_class.create(file: "abc", foo: :bar, baz: :boom)
160
+ expect(Tessa::Upload)
161
+ .to receive(:create).with(hash_including(foo: :bar, baz: :boom)).and_return(upload)
162
+ described_class.create(file: __FILE__, foo: :bar, baz: :boom)
162
163
  end
163
164
 
164
165
  it "uploads the passed file to the upload's URL" do
165
166
  expect(Tessa::Upload).to receive(:create).and_return(upload)
166
- expect(upload).to receive(:upload_file).with(:file)
167
- described_class.create(file: :file)
167
+ expect(upload).to receive(:upload_file).with(__FILE__)
168
+ described_class.create(file: __FILE__)
169
+ end
170
+
171
+ it "infers the file size, name, and date" do
172
+ file = Tempfile.new("test")
173
+ file.write "abc"
174
+ file.close
175
+ expected_values = {
176
+ size: 3,
177
+ name: File.basename(file.path),
178
+ date: File.mtime(file.path),
179
+ }
180
+ expect(Tessa::Upload)
181
+ .to receive(:create).with(hash_including(expected_values)).and_return(upload)
182
+ described_class.create(file: file.path)
183
+ end
184
+
185
+ it "allows overriding inferred values" do
186
+ expected_values = {
187
+ size: 1,
188
+ name: "my-file",
189
+ date: "123",
190
+ }
191
+ expect(Tessa::Upload)
192
+ .to receive(:create).with(hash_including(expected_values)).and_return(upload)
193
+ described_class.create(file: __FILE__, **expected_values)
168
194
  end
169
195
  end
170
196
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tessa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Powell