tessa 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/.env.example +1 -1
- data/lib/tessa.rb +2 -0
- data/lib/tessa/config.rb +3 -1
- data/lib/tessa/response_factory.rb +1 -0
- data/lib/tessa/upload.rb +1 -1
- data/lib/tessa/version.rb +1 -1
- data/spec/tessa/config_spec.rb +9 -5
- data/spec/tessa/upload_spec.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93cafce92a98390762cbd8d7f1d033e7b03e15a1
|
4
|
+
data.tar.gz: ac5791937677c234980abb77e77caec40a7f6898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0146024146bcf5204facc53f4abf14df135a2728e8101715630dfa5b8b52634672296fd94e2655922d1bd1aa50aceb788c3428cb2e25f5baa105e1bd8a984ca
|
7
|
+
data.tar.gz: 28c21e8452a61969bba191101298638d1489a163ec4ea1d1be889dd892c7f7cfb91665691ccbbf077d56e62ff59f300467492c9f97c248b7d15f1e977ef767ac
|
data/.env.example
CHANGED
data/lib/tessa.rb
CHANGED
data/lib/tessa/config.rb
CHANGED
@@ -2,10 +2,12 @@ module Tessa
|
|
2
2
|
class Config
|
3
3
|
include Virtus.model
|
4
4
|
|
5
|
+
DEFAULT_STRATEGY = "default"
|
6
|
+
|
5
7
|
attribute :username, String, default: -> (*_) { ENV['TESSA_USERNAME'] }
|
6
8
|
attribute :password, String, default: -> (*_) { ENV['TESSA_PASSWORD'] }
|
7
9
|
attribute :url, String, default: -> (*_) { ENV['TESSA_URL'] }
|
8
|
-
attribute :
|
10
|
+
attribute :strategy, String, default: -> (*_) { ENV['TESSA_STRATEGY'] || DEFAULT_STRATEGY }
|
9
11
|
|
10
12
|
def connection
|
11
13
|
@connection ||= Faraday.new(url: url) do |conn|
|
data/lib/tessa/upload.rb
CHANGED
@@ -17,7 +17,7 @@ module Tessa
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.create(connection: Tessa.config.connection,
|
20
|
-
strategy: Tessa.config.
|
20
|
+
strategy: Tessa.config.strategy,
|
21
21
|
**options)
|
22
22
|
new_from_response connection.post('/uploads', options.merge(strategy: strategy))
|
23
23
|
end
|
data/lib/tessa/version.rb
CHANGED
data/spec/tessa/config_spec.rb
CHANGED
@@ -52,15 +52,19 @@ RSpec.describe Tessa::Config do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "#
|
55
|
+
describe "#strategy" do
|
56
56
|
it_behaves_like "defaults to environment variable" do
|
57
|
-
let(:variable_name) { '
|
58
|
-
subject(:
|
57
|
+
let(:variable_name) { 'TESSA_STRATEGY' }
|
58
|
+
subject(:strategy) { config.strategy }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "uses the string 'default' when no envvar passed" do
|
62
|
+
expect(config.strategy).to eq("default")
|
59
63
|
end
|
60
64
|
|
61
65
|
it "behaves like a normal accessor" do
|
62
|
-
config.
|
63
|
-
expect(config.
|
66
|
+
config.strategy = "my-new-value"
|
67
|
+
expect(config.strategy).to eq("my-new-value")
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
data/spec/tessa/upload_spec.rb
CHANGED
@@ -56,6 +56,18 @@ RSpec.describe Tessa::Upload do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
context "when response is not successful" do
|
60
|
+
let(:faraday_stubs) {
|
61
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
62
|
+
stub.send(method, path) { |env| [422, {}, { "error" => "error" }.to_json] }
|
63
|
+
end
|
64
|
+
}
|
65
|
+
|
66
|
+
it "raises Tessa::RequestFailed" do
|
67
|
+
expect{ call }.to raise_error(Tessa::RequestFailed)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
59
71
|
it "returns an instance of #{return_type}" do
|
60
72
|
expect(call).to be_a(return_type)
|
61
73
|
end
|
@@ -91,8 +103,8 @@ RSpec.describe Tessa::Upload do
|
|
91
103
|
end
|
92
104
|
|
93
105
|
describe ":strategy param" do
|
94
|
-
it "defaults to config.
|
95
|
-
expect(Tessa.config).to receive(:
|
106
|
+
it "defaults to config.strategy" do
|
107
|
+
expect(Tessa.config).to receive(:strategy).and_return(:my_default)
|
96
108
|
expect_post_with_hash_including(strategy: :my_default)
|
97
109
|
described_class.create(connection: connection)
|
98
110
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Powell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|