tessa 0.0.1 → 0.1.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: df31d024f842fa270757fcb281f5da0d13d20e73
4
- data.tar.gz: 960964ffc7c0cc1fa31e204e8fd060252c6c03a7
3
+ metadata.gz: 81149b78c787bad3ecc780af3813bdd561a6bee6
4
+ data.tar.gz: 47db4550ad97c731ead3e96578108b0017422247
5
5
  SHA512:
6
- metadata.gz: 23ae568117b5557461903020fa46951bf53eeac4a22a80d85e4f70f314432d550253a8558b91edf904de71a0d8a4bbaa5aeef47878a95400e9849f94814dd5e9
7
- data.tar.gz: 440bb8479caad87ceeb4b12448c50f4799b6d6038129a14b30f92d7bf7c06286485ff7db44e9cdf90a92a35242690ba8ac51145560373eabe3704f471e4950e9
6
+ metadata.gz: 61d136b95f0682a8609a43130d2cd1bf5f91d6195c8ccadd99a152cee2b9ad6660f80311f41f008227ced1f4fee885e9d90d5b0bcad9151b8b158386e3ce2678
7
+ data.tar.gz: 15c2e37be659860fbb28b9e525f1316c924e14fea7ed64b72ef91948e1a923a9f1812d17a5dc5249cf1bab762952a9f00561e2ba45dae37cb70a261959e6ad4e
data/.env.example ADDED
@@ -0,0 +1,5 @@
1
+ TESSA_USERNAME=username
2
+ TESSA_PASSWORD=password
3
+ TESSA_URL=http://tessa.dev
4
+ TESSA_DEFAULT_STRATEGY=default
5
+
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .env
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ before_install: gem update bundler
2
+ language: ruby
3
+ notifications:
4
+ email: false
5
+ rvm:
6
+ - 2.1.0
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in tessa.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'dotenv'
9
+ end
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Tessa
1
+ # [Tessa][0]
2
2
 
3
- TODO: Write a gem description
3
+ [ ![Gem Version][1] ][2]
4
+ [ ![Build Status][3] ][4]
5
+ [ ![Coverage Status][5] ][6]
6
+ [ ![Code Climate][7] ][8]
7
+
8
+ Manage your assets.
4
9
 
5
10
  ## Installation
6
11
 
@@ -24,8 +29,18 @@ TODO: Write usage instructions here
24
29
 
25
30
  ## Contributing
26
31
 
27
- 1. Fork it ( https://github.com/[my-github-username]/tessa/fork )
32
+ 1. Fork it ( https://github.com/watermarkchurch/tessa/fork )
28
33
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
34
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
35
  4. Push to the branch (`git push origin my-new-feature`)
31
36
  5. Create a new Pull Request
37
+
38
+ [0]: https://github.com/watermarkchurch/tessa
39
+ [1]: https://img.shields.io/gem/v/tessa.svg?style=flat
40
+ [2]: http://rubygems.org/gems/tessa "Gem Version"
41
+ [3]: https://img.shields.io/travis/watermarkchurch/tessa/master.svg?style=flat
42
+ [4]: https://travis-ci.org/watermarkchurch/tessa "Build Status"
43
+ [5]: https://codeclimate.com/github/watermarkchurch/tessa/badges/coverage.svg
44
+ [6]: https://codeclimate.com/github/watermarkchurch/tessa "Coverage Status"
45
+ [7]: https://img.shields.io/codeclimate/github/watermarkchurch/tessa.svg?style=flat
46
+ [8]: https://codeclimate.com/github/watermarkchurch/tessa "Code Climate"
data/Rakefile CHANGED
@@ -1,2 +1,19 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
6
+
7
+ task :environment do
8
+ require 'dotenv'
9
+ Dotenv.load
10
+
11
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
12
+ require 'tessa'
13
+ end
14
+
15
+ desc "Launch a pry shell with Tessa library loaded"
16
+ task :pry => :environment do
17
+ require 'pry'
18
+ Pry.start
19
+ end
data/lib/tessa.rb CHANGED
@@ -1,5 +1,21 @@
1
1
  require "tessa/version"
2
2
 
3
+ require "faraday"
4
+ require "faraday/digestauth"
5
+ require "virtus"
6
+ require "json"
7
+
8
+ require "tessa/config"
9
+ require "tessa/response_factory"
10
+ require "tessa/asset"
11
+ require "tessa/upload"
12
+
3
13
  module Tessa
4
- # Your code goes here...
14
+ def self.config
15
+ @config ||= Config.new
16
+ end
17
+
18
+ def self.setup
19
+ yield config
20
+ end
5
21
  end
@@ -0,0 +1,19 @@
1
+ module Tessa
2
+ class Asset
3
+ include Virtus.model
4
+ extend ResponseFactory
5
+
6
+ attribute :id, Integer
7
+ attribute :status, String
8
+ attribute :strategy, String
9
+ attribute :meta, Hash[Symbol => String]
10
+ attribute :public_url, String
11
+ attribute :private_url, String
12
+ attribute :delete_url, String
13
+
14
+ def self.find(*ids,
15
+ connection: Tessa.config.connection)
16
+ new_from_response connection.get("/assets/#{ids.join(",")}")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module Tessa
2
+ class Config
3
+ include Virtus.model
4
+
5
+ attribute :username, String, default: -> (*_) { ENV['TESSA_USERNAME'] }
6
+ attribute :password, String, default: -> (*_) { ENV['TESSA_PASSWORD'] }
7
+ attribute :url, String, default: -> (*_) { ENV['TESSA_URL'] }
8
+ attribute :default_strategy, String, default: -> (*_) { ENV['TESSA_DEFAULT_STRATEGY'] }
9
+
10
+ def connection
11
+ @connection ||= Faraday.new(url: url) do |conn|
12
+ conn.request :digest, username, password
13
+ conn.request :url_encoded
14
+ conn.adapter Faraday.default_adapter
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Tessa
2
+ module ResponseFactory
3
+
4
+ def new_from_response(response)
5
+ case json = JSON.parse(response.body)
6
+ when Array
7
+ json.map { |record| new record }
8
+ when Hash
9
+ new json
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ module Tessa
2
+ class Upload
3
+ include Virtus.model
4
+ extend ResponseFactory
5
+
6
+ attribute :success_url, String
7
+ attribute :cancel_url, String
8
+ attribute :upload_url, String
9
+ attribute :upload_method, String
10
+
11
+ def complete!(connection: Tessa.config.connection)
12
+ Asset.new_from_response connection.patch(success_url)
13
+ end
14
+
15
+ def cancel!(connection: Tessa.config.connection)
16
+ Asset.new_from_response connection.patch(cancel_url)
17
+ end
18
+
19
+ def self.create(connection: Tessa.config.connection,
20
+ strategy: Tessa.config.default_strategy,
21
+ **options)
22
+ new_from_response connection.post('/uploads', options.merge(strategy: strategy))
23
+ end
24
+ end
25
+ end
data/lib/tessa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tessa
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,89 +1,23 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
- # file to always be loaded, without a need to explicitly require it in any files.
5
- #
6
- # Given that it is always loaded, you are encouraged to keep this file as
7
- # light-weight as possible. Requiring heavyweight dependencies from this file
8
- # will add to the boot time of your test suite on EVERY test run, even for an
9
- # individual file that may not need all of that loaded. Instead, consider making
10
- # a separate helper file that requires the additional dependencies and performs
11
- # the additional setup, and require it from the spec files that actually need it.
12
- #
13
- # The `.rspec` file also contains a few flags that are not defaults but that
14
- # users commonly want.
15
- #
16
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
1
+ require 'tessa'
2
+
17
3
  RSpec.configure do |config|
18
- # rspec-expectations config goes here. You can use an alternate
19
- # assertion/expectation library such as wrong or the stdlib/minitest
20
- # assertions if you prefer.
21
4
  config.expect_with :rspec do |expectations|
22
- # This option will default to `true` in RSpec 4. It makes the `description`
23
- # and `failure_message` of custom matchers include text for helper methods
24
- # defined using `chain`, e.g.:
25
- # be_bigger_than(2).and_smaller_than(4).description
26
- # # => "be bigger than 2 and smaller than 4"
27
- # ...rather than:
28
- # # => "be bigger than 2"
29
5
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
6
  end
31
7
 
32
- # rspec-mocks config goes here. You can use an alternate test double
33
- # library (such as bogus or mocha) by changing the `mock_with` option here.
34
8
  config.mock_with :rspec do |mocks|
35
- # Prevents you from mocking or stubbing a method that does not exist on
36
- # a real object. This is generally recommended, and will default to
37
- # `true` in RSpec 4.
38
9
  mocks.verify_partial_doubles = true
39
10
  end
40
11
 
41
- # The settings below are suggested to provide a good initial experience
42
- # with RSpec, but feel free to customize to your heart's content.
43
- =begin
44
- # These two settings work together to allow you to limit a spec run
45
- # to individual examples or groups you care about by tagging them with
46
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
- # get run.
48
- config.filter_run :focus
49
- config.run_all_when_everything_filtered = true
50
-
51
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
- # For more details, see:
53
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
- config.disable_monkey_patching!
57
-
58
- # This setting enables warnings. It's recommended, but in some cases may
59
- # be too noisy due to issues in dependencies.
60
- config.warnings = true
61
-
62
- # Many RSpec users commonly either run the entire suite or an individual
63
- # file, and it's useful to allow more verbose output when running an
64
- # individual spec file.
65
12
  if config.files_to_run.one?
66
- # Use the documentation formatter for detailed output,
67
- # unless a formatter has already been configured
68
- # (e.g. via a command-line flag).
69
13
  config.default_formatter = 'doc'
70
14
  end
71
15
 
72
- # Print the 10 slowest examples and example groups at the
73
- # end of the spec run, to help surface which specs are running
74
- # particularly slow.
75
- config.profile_examples = 10
76
-
77
- # Run specs in random order to surface order dependencies. If you find an
78
- # order dependency and want to debug it, you can fix the order by providing
79
- # the seed, which is printed after each run.
80
- # --seed 1234
16
+ config.filter_run :focus
17
+ config.run_all_when_everything_filtered = true
18
+ config.disable_monkey_patching!
19
+ config.warnings = true
81
20
  config.order = :random
82
21
 
83
- # Seed global randomization in this process using the `--seed` CLI option.
84
- # Setting this allows you to use `--seed` to deterministically reproduce
85
- # test failures related to randomization by passing the same `--seed` value
86
- # as the one that triggered the failure.
87
22
  Kernel.srand config.seed
88
- =end
89
23
  end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tessa::Asset do
4
+ let(:args) {
5
+ {
6
+ id: 123,
7
+ status: 'completed',
8
+ strategy: 'default',
9
+ meta: { name: "foo" },
10
+ public_url: "http://example.com/public",
11
+ private_url: "http://example.com/private",
12
+ delete_url: "http://example.com/delete",
13
+ }
14
+ }
15
+
16
+ describe "#initialize" do
17
+ context "with all arguments" do
18
+ subject(:asset) { described_class.new(args) }
19
+
20
+ it "sets id to attribute" do
21
+ expect(asset.id).to eq(args[:id])
22
+ end
23
+
24
+ it "sets status to attribute" do
25
+ expect(asset.status).to eq(args[:status])
26
+ end
27
+
28
+ it "sets strategy to attribute" do
29
+ expect(asset.strategy).to eq(args[:strategy])
30
+ end
31
+
32
+ it "sets meta to attribute" do
33
+ expect(asset.meta).to eq(args[:meta])
34
+ end
35
+
36
+ it "sets public_url to attribute" do
37
+ expect(asset.public_url).to eq(args[:public_url])
38
+ end
39
+
40
+ it "sets private_url to attribute" do
41
+ expect(asset.private_url).to eq(args[:private_url])
42
+ end
43
+
44
+ it "sets delete_url to attribute" do
45
+ expect(asset.delete_url).to eq(args[:delete_url])
46
+ end
47
+
48
+ end
49
+ end
50
+
51
+ describe "#find" do
52
+ let(:faraday_stubs) {
53
+ Faraday::Adapter::Test::Stubs.new do |stub|
54
+ stub.get("/assets/#{id_query}") { |env| [200, {}, remote_response.to_json] }
55
+ end
56
+ }
57
+ let(:connection) { Faraday.new { |f| f.adapter :test, faraday_stubs } }
58
+
59
+ context "with a single id" do
60
+ let(:id_query) { "ID" }
61
+ let(:remote_response) { {} }
62
+
63
+ it "calls get('/assets/ID') on connection" do
64
+ expect(connection).to receive(:get).with("/assets/ID").and_call_original
65
+ described_class.find("ID", connection: connection)
66
+ end
67
+
68
+ it "returns an instance of Asset" do
69
+ response = described_class.find("ID", connection: connection)
70
+ expect(response).to be_a(described_class)
71
+ end
72
+
73
+ it "defaults connection to Tessa.config.connection" do
74
+ expect(Tessa.config).to receive(:connection).and_return(connection)
75
+ expect(connection).to receive(:get).and_call_original
76
+ described_class.find("ID")
77
+ end
78
+
79
+ context "with attributes in response" do
80
+ subject(:response) { described_class.find("ID", connection: connection) }
81
+ let(:remote_response) { args }
82
+
83
+ it "sets attributes on models" do
84
+ expect(response.id).to eq(args[:id])
85
+ expect(response.status).to eq(args[:status])
86
+ expect(response.meta).to eq(args[:meta])
87
+ end
88
+ end
89
+ end
90
+
91
+ context "with multiple ids" do
92
+ subject(:response) {
93
+ described_class.find("ID1", "ID2", connection: connection)
94
+ }
95
+ let(:remote_response) { [{}] }
96
+ let(:id_query) { "ID1,ID2" }
97
+
98
+ it "calls get('/assets/ID1,ID2') on connection" do
99
+ expect(connection).to receive(:get).with("/assets/ID1,ID2").and_call_original
100
+ response
101
+ end
102
+
103
+ it "returns instances of Asset" do
104
+ expect(response).to all(be_a(described_class))
105
+ end
106
+
107
+ context "with attributes in response" do
108
+ let(:remote_response) { [args, args] }
109
+
110
+ it "sets attributes on models" do
111
+ expect(response[0].id).to eq(args[:id])
112
+ expect(response[1].id).to eq(args[:id])
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tessa::Config do
4
+ subject(:config) { Tessa::Config.new }
5
+
6
+ shared_examples_for "defaults to environment variable" do
7
+ around { |ex| swap_environment_var(variable_name, 'from-env') { ex.run } }
8
+
9
+ it { is_expected.to eq("from-env") }
10
+
11
+ def swap_environment_var(var, new_val)
12
+ old_val = ENV[var]
13
+ ENV[var] = new_val
14
+ yield
15
+ ENV[var] = old_val
16
+ end
17
+ end
18
+
19
+ describe "#username" do
20
+ it_behaves_like "defaults to environment variable" do
21
+ let(:variable_name) { 'TESSA_USERNAME' }
22
+ subject(:username) { config.username }
23
+ end
24
+
25
+ it "behaves like a normal accessor" do
26
+ config.username = "my-new-value"
27
+ expect(config.username).to eq("my-new-value")
28
+ end
29
+ end
30
+
31
+ describe "#password" do
32
+ it_behaves_like "defaults to environment variable" do
33
+ let(:variable_name) { 'TESSA_PASSWORD' }
34
+ subject(:password) { config.password }
35
+ end
36
+
37
+ it "behaves like a normal accessor" do
38
+ config.password = "my-new-value"
39
+ expect(config.password).to eq("my-new-value")
40
+ end
41
+ end
42
+
43
+ describe "#url" do
44
+ it_behaves_like "defaults to environment variable" do
45
+ let(:variable_name) { 'TESSA_URL' }
46
+ subject(:url) { config.url }
47
+ end
48
+
49
+ it "behaves like a normal accessor" do
50
+ config.url = "my-new-value"
51
+ expect(config.url).to eq("my-new-value")
52
+ end
53
+ end
54
+
55
+ describe "#default_strategy" do
56
+ it_behaves_like "defaults to environment variable" do
57
+ let(:variable_name) { 'TESSA_DEFAULT_STRATEGY' }
58
+ subject(:default_strategy) { config.default_strategy }
59
+ end
60
+
61
+ it "behaves like a normal accessor" do
62
+ config.default_strategy = "my-new-value"
63
+ expect(config.default_strategy).to eq("my-new-value")
64
+ end
65
+ end
66
+
67
+ describe "#connection" do
68
+ it "is a Faraday::Connection" do
69
+ expect(config.connection).to be_a(Faraday::Connection)
70
+ end
71
+
72
+ context "with values configured" do
73
+ subject(:connection) { config.connection }
74
+ before { args.each { |k, v| config.send("#{k}=", v) } }
75
+ let(:args) {
76
+ {
77
+ url: "http://tessa.test",
78
+ username: "username",
79
+ password: "password",
80
+ }
81
+ }
82
+
83
+ it "sets faraday's url prefix to our url" do
84
+ expect(connection.url_prefix.to_s).to match(config.url)
85
+ end
86
+
87
+ context "with faraday spy" do
88
+ let(:spy) { instance_spy(Faraday::Connection) }
89
+ before do
90
+ expect(Faraday).to receive(:new).and_yield(spy)
91
+ connection
92
+ end
93
+
94
+ it "sets up digest auth params" do
95
+ expect(spy).to have_received(:request).with(:digest, args[:username], args[:password])
96
+ end
97
+
98
+ it "sets up url_encoded request handler" do
99
+ expect(spy).to have_received(:request).with(:url_encoded)
100
+ end
101
+
102
+ it "configures the default adapter" do
103
+ expect(spy).to have_received(:adapter).with(:net_http)
104
+ end
105
+ end
106
+ end
107
+
108
+ it "caches the result" do
109
+ expect(config.connection.object_id).to eq(config.connection.object_id)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,128 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tessa::Upload do
4
+ subject(:upload) { described_class.new(args) }
5
+ let(:args) {
6
+ {
7
+ success_url: "/success",
8
+ cancel_url: "/cancel",
9
+ upload_url: "/upload",
10
+ upload_method: "put",
11
+ }
12
+ }
13
+
14
+ describe "#initialize" do
15
+ context "with all arguments" do
16
+ it "sets success_url to attribute" do
17
+ expect(upload.success_url).to eq(args[:success_url])
18
+ end
19
+
20
+ it "sets cancel_url to attribute" do
21
+ expect(upload.cancel_url).to eq(args[:cancel_url])
22
+ end
23
+
24
+ it "sets upload_url to attribute" do
25
+ expect(upload.upload_url).to eq(args[:upload_url])
26
+ end
27
+
28
+ it "sets upload_method to attribute" do
29
+ expect(upload.upload_method).to eq(args[:upload_method])
30
+ end
31
+ end
32
+ end
33
+
34
+ shared_examples_for "remote call macro" do |method, path, return_type|
35
+ let(:remote_response) { {} }
36
+ let(:faraday_stubs) {
37
+ Faraday::Adapter::Test::Stubs.new do |stub|
38
+ stub.send(method, path) { |env| [200, {}, remote_response.to_json] }
39
+ end
40
+ }
41
+ let(:connection) { Faraday.new { |f| f.adapter :test, faraday_stubs } }
42
+ let(:call_args) { { connection: connection } }
43
+
44
+ it "calls #{method} method with #{path}" do
45
+ expect(connection).to receive(method).with(path, any_args).and_call_original
46
+ call
47
+ end
48
+
49
+ context "with no connection passed" do
50
+ let(:call_args) { {} }
51
+
52
+ it "defaults connection to Tessa.config.connection" do
53
+ expect(Tessa.config).to receive(:connection).and_return(connection)
54
+ expect(connection).to receive(method).and_call_original
55
+ call
56
+ end
57
+ end
58
+
59
+ it "returns an instance of #{return_type}" do
60
+ expect(call).to be_a(return_type)
61
+ end
62
+ end
63
+
64
+ describe "#complete!" do
65
+ subject(:call) { upload.complete!(call_args) }
66
+
67
+ include_examples "remote call macro", :patch, "/success", Tessa::Asset
68
+ end
69
+
70
+ describe "#cancel!" do
71
+ subject(:call) { upload.cancel!(call_args) }
72
+
73
+ include_examples "remote call macro", :patch, "/cancel", Tessa::Asset
74
+ end
75
+
76
+ describe "::create" do
77
+ subject(:call) { described_class.create(call_args) }
78
+
79
+ include_examples "remote call macro", :post, "/uploads", Tessa::Upload
80
+
81
+ context "with a full response" do
82
+ let(:remote_response) { args }
83
+
84
+ it "returns a new object initialized with the response" do
85
+ upload = described_class.create(connection: connection)
86
+ expect(upload.success_url).to eq(args[:success_url])
87
+ expect(upload.cancel_url).to eq(args[:cancel_url])
88
+ expect(upload.upload_url).to eq(args[:upload_url])
89
+ expect(upload.upload_method).to eq(args[:upload_method])
90
+ end
91
+ end
92
+
93
+ describe ":strategy param" do
94
+ it "defaults to config.default_strategy" do
95
+ expect(Tessa.config).to receive(:default_strategy).and_return(:my_default)
96
+ expect_post_with_hash_including(strategy: :my_default)
97
+ described_class.create(connection: connection)
98
+ end
99
+
100
+ it "overrides with :strategy argument" do
101
+ expect_post_with_hash_including(strategy: :my_default)
102
+ described_class.create(connection: connection, strategy: :my_default)
103
+ end
104
+ end
105
+
106
+ it "sets :name param from argument" do
107
+ expect_post_with_hash_including(name: "my-file.txt")
108
+ described_class.create(connection: connection, name: "my-file.txt")
109
+ end
110
+
111
+ it "sets :size param from argument" do
112
+ expect_post_with_hash_including(size: 12345)
113
+ described_class.create(connection: connection, size: 12345)
114
+ end
115
+
116
+ it "sets :mime_type param from argument" do
117
+ expect_post_with_hash_including(mime_type: "text/plain")
118
+ described_class.create(connection: connection, mime_type: "text/plain")
119
+ end
120
+
121
+ def expect_post_with_hash_including(expected)
122
+ expect(connection).to receive(:post)
123
+ .with("/uploads", hash_including(expected))
124
+ .and_call_original
125
+ end
126
+ end
127
+
128
+ end
data/tessa.gemspec CHANGED
@@ -18,6 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "faraday", "~>0.9.1"
22
+ spec.add_dependency "faraday-digestauth", "~>0.2.0"
23
+ spec.add_dependency "virtus", "~>1.0.4"
24
+
21
25
  spec.add_development_dependency "bundler", "~> 1.7"
22
26
  spec.add_development_dependency "rake", "~> 10.0"
23
27
  spec.add_development_dependency "rspec", "~> 3.1"
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.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Powell
@@ -9,8 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-26 00:00:00.000000000 Z
12
+ date: 2015-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.9.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.9.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday-digestauth
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.2.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.2.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: virtus
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 1.0.4
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.4
14
56
  - !ruby/object:Gem::Dependency
15
57
  name: bundler
16
58
  requirement: !ruby/object:Gem::Requirement
@@ -61,15 +103,24 @@ executables: []
61
103
  extensions: []
62
104
  extra_rdoc_files: []
63
105
  files:
106
+ - ".env.example"
64
107
  - ".gitignore"
65
108
  - ".rspec"
109
+ - ".travis.yml"
66
110
  - Gemfile
67
111
  - LICENSE.txt
68
112
  - README.md
69
113
  - Rakefile
70
114
  - lib/tessa.rb
115
+ - lib/tessa/asset.rb
116
+ - lib/tessa/config.rb
117
+ - lib/tessa/response_factory.rb
118
+ - lib/tessa/upload.rb
71
119
  - lib/tessa/version.rb
72
120
  - spec/spec_helper.rb
121
+ - spec/tessa/asset_spec.rb
122
+ - spec/tessa/config_spec.rb
123
+ - spec/tessa/upload_spec.rb
73
124
  - tessa.gemspec
74
125
  homepage: https://github.com/watermarkchurch/tessa
75
126
  licenses:
@@ -97,3 +148,6 @@ specification_version: 4
97
148
  summary: Manage your assets.
98
149
  test_files:
99
150
  - spec/spec_helper.rb
151
+ - spec/tessa/asset_spec.rb
152
+ - spec/tessa/config_spec.rb
153
+ - spec/tessa/upload_spec.rb