-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Transloadit | ||
attr_accessor :key | ||
attr_accessor :secret | ||
|
||
def initialize(options = {}) | ||
self.key = options[:key] | ||
self.secret = options[:secret] | ||
|
||
_ensure_key_provided | ||
end | ||
|
||
private | ||
|
||
def _ensure_key_provided | ||
unless self.key | ||
raise ArgumentError, 'an authentication key must be provided' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Transloadit | ||
class Transloadit | ||
VERSION = '0.0.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'test_helper' | ||
|
||
class TestTransloadit < MiniTest::Unit::TestCase | ||
def test_initializer_works | ||
key = 'a' | ||
secret = 'b' | ||
t = Transloadit.new(:key => key, :secret => secret) | ||
|
||
assert_equal key, t.key | ||
assert_equal secret, t.secret | ||
end | ||
|
||
def test_initializer_requires_key | ||
assert_raises ArgumentError do | ||
t = Transloadit.new(:secret => 'x') | ||
end | ||
end | ||
|
||
def test_initializer_does_not_require_secret | ||
assert_kind_of Transloadit, Transloadit.new(:key => 'x') | ||
end | ||
end |