Skip to content

Commit

Permalink
Initial Transloadit class and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stouset committed Jan 16, 2011
1 parent 34475eb commit 9c082f1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/transloadit.rb
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
2 changes: 1 addition & 1 deletion lib/transloadit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Transloadit
class Transloadit
VERSION = '0.0.1'
end
22 changes: 22 additions & 0 deletions test/transloadit_test.rb
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

0 comments on commit 9c082f1

Please sign in to comment.