Skip to content

Commit

Permalink
respond to comments, add specs, make rubocop happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan committed Oct 15, 2015
1 parent 9787230 commit 050ec13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ require 'rspec/core/rake_task'
RuboCop::RakeTask.new

RSpec::Core::RakeTask.new

LATEST_WEB_TGZ = 'http://dynamodb-local.s3-website-us-west-2.amazonaws.com'\
'/dynamodb_local_latest.tar.gz'
JAR_NAME = 'DynamoDBLocal.jar'
LOCAL_JAR_DIR = '../lib/jars/dynamodb_local'
SPEC_JAR_DIR = File.expand_path('./spec/dynamo-local-ruby/support/jars/')
Expand All @@ -30,9 +31,7 @@ task build: :download_dynamodb_local

def download_jar(local_path)
latest = File.join(local_path, 'dynamodb_local_latest.tar.gz')
latest_web_tgz = 'http://dynamodb-local.s3-website-us-west-2.amazonaws.com'\
'/dynamodb_local_latest.tar.gz'
`wget #{latest_web_tgz} -O #{latest}` unless File.exist?(latest)
`wget #{LATEST_WEB_TGZ} -O #{latest}` unless File.exist?(latest)
`tar xzf #{latest} -C #{local_path}`
`rm #{latest}` if File.exist?(latest)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamo-local-ruby/dynamo_db_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def test_connection
end
end

private
def teardown(pid)
Process.kill('SIGINT', pid)
Process.waitpid2(pid)
rescue Errno::ESRCH
nil
end
end

Expand Down
14 changes: 14 additions & 0 deletions spec/dynamo-local-ruby/dynamo_db_local_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@

describe '.up' do
describe 'exit teardown' do
let(:pid) { 123 }

context 'pid exists' do
it 'kills and waits' do
Process.should_receive(:kill).with('SIGINT', pid)
Process.should_receive(:waitpid2).with(pid)
described_class.send(:teardown, pid)
end
end

context 'no pid' do
it 'does not raise' do
expect { described_class.send(:teardown, pid) }.not_to raise_error
end
end
end

after(:each) do
Expand Down

0 comments on commit 050ec13

Please sign in to comment.