Skip to content

Adding RSpec and first test #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rbhive.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
spec.add_dependency('thrift', '~> 0.9')
spec.add_dependency('json')

spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'bundler', '>= 1.3'

Expand Down
23 changes: 23 additions & 0 deletions spec/rbhive/connection_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rbhive/connection'

describe RBHive do
describe '.connect' do

# Mock any attempts to open a socket
let(:socket) { double('Thrift::Socket').as_null_object }
before do
allow(Thrift::Socket).to receive(:new).and_return(socket)
end

let(:server) { 'localhost' }
let(:port) { 10_000 }

it 'yields the connection to the block' do
expect(@connection).to be(nil)
RBHive.connect(server, port) do |connection|
@connection = connection
end
expect(@connection.class).to be(RBHive::Connection)
end
end
end