Permalink
Browse files

stake in the ground for Publisher

  • Loading branch information...
1 parent 4e8bcf8 commit 57e9da8dd51ac0ac3cb345de2d049943cc72ce3c @gorsuch gorsuch committed Aug 28, 2012
Showing with 27 additions and 0 deletions.
  1. +4 −0 lib/backstop.rb
  2. +10 −0 lib/backstop/publisher.rb
  3. +11 −0 spec/backstop/publisher_spec.rb
  4. +2 −0 spec/spec_helper.rb
View
@@ -0,0 +1,4 @@
+require 'socket'
+require 'uri'
+
+require 'backstop/publisher'
@@ -0,0 +1,10 @@
+module Backstop
+ class Publisher
+ attr_reader :connections
+
+ def initialize(urls)
+ @connections = []
+ @connections = urls.map { |u| URI.parse(u) }.map { |u| TCPSocket.new(u.host, u.port) }
+ end
+ end
+end
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe Backstop::Publisher do
+ it "should initialize with an array of urls" do
+ urls = ['tcp://10.0.0.1:5000', 'tcp://10.0.0.1:5001']
+ TCPSocket.should_receive(:new).with('10.0.0.1', 5000)
+ TCPSocket.should_receive(:new).with('10.0.0.1', 5001)
+ b = Backstop::Publisher.new(urls)
+ b.connections.count.should eq 2
+ end
+end
View
@@ -4,6 +4,8 @@
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+require 'backstop'
+
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true

0 comments on commit 57e9da8

Please sign in to comment.