acpc_poker_basic_proxy 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d6dff95db6eef3d31825a87fc46bf7aec6090c5
4
- data.tar.gz: 4a80071d3e101764f00c8e0a1812881825a09d3e
3
+ metadata.gz: 8830e03ad490d6a24dac3b73c647fee5988aea43
4
+ data.tar.gz: e476afcc89336bd58bf33d5b2c2ae88776d9525d
5
5
  SHA512:
6
- metadata.gz: 04bd293fcb8daa161acd57ee2250596ea934dc604db45440f06a2e03ddfdc3b823311d61b1ffae02aeaaa5637106693792f62c659b9d2e406795955d6cf90d9d
7
- data.tar.gz: 432b48c811b643e16dc13aec3fe674ff556837a833c5cd265f615e9546d71f002b8fe89dc2ecfb7b6b028dbf01773b2222b844d1d3d788e2d4c85df8a0841581
6
+ metadata.gz: 3c160055f942244c12365e97893236e53c74acdb94329ebeedc41f53686eb535c4023fb33ba8fc142d2d8676666d1a228027636459dd530e9b8ecf6205fa13a2
7
+ data.tar.gz: f98d89ceb150f1c073abbb9a0a32ce2a6f26a11a70daa68ef5bcdcb2ebcd2bc347dd5abd4787d1b60015ada37d40c97b189bf06c7315d9fc150ea705f6c5cffd
data/Rakefile CHANGED
@@ -8,5 +8,6 @@ Rake::TestTask.new do |t|
8
8
  t.libs << "lib" << 'spec/support'
9
9
  t.test_files = FileList['spec/**/*_spec.rb']
10
10
  t.verbose = false
11
- t.warning = false # pry-rescue has a lot of warnings
11
+ t.warning = true
12
12
  end
13
+ task :default => :test
@@ -66,6 +66,7 @@ module AcpcPokerBasicProxy
66
66
  dealer_information.port_number,
67
67
  dealer_information.host_name
68
68
  )
69
+ @match_state = nil
69
70
  end
70
71
 
71
72
  # @param [PokerAction] action The action to send.
@@ -63,6 +63,7 @@ module AcpcPokerBasicProxy
63
63
  # @param [String] host_name The host on which the dealer is running. Defaults to 'localhost'
64
64
  # @raise AcpcDealerConnectionError, UnableToWriteToDealer
65
65
  def initialize(port, host_name='localhost')
66
+ @dealer_socket = nil
66
67
  begin
67
68
  @dealer_socket = TCPSocket.new(host_name, port)
68
69
  super @dealer_socket
@@ -94,7 +95,7 @@ module AcpcPokerBasicProxy
94
95
  # @raise UnableToWriteToDealer
95
96
  def write(string)
96
97
  begin
97
- num_bytes_written = send_string_to_dealer string
98
+ send_string_to_dealer string
98
99
  rescue => e
99
100
  handle_error UnableToWriteToDealer, "Unable to send the string, \"#{string}\", to the dealer", e
100
101
  end
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerBasicProxy
2
- VERSION = "3.2.0"
2
+ VERSION = "3.2.1"
3
3
  end
@@ -163,7 +163,6 @@ describe BasicProxy do
163
163
  next unless match.current_hand.next_action
164
164
 
165
165
  from_player_message = match.current_hand.next_action.state
166
- seat_taking_action = match.current_hand.next_action.seat
167
166
  action = match.current_hand.next_action.action
168
167
 
169
168
  action_that_should_be_sent = "#{from_player_message.to_s}:#{action.to_acpc}"
@@ -13,7 +13,6 @@ describe DealerStream do
13
13
  end
14
14
  describe '#new' do
15
15
  it 'works properly' do
16
- start_test_connection!
17
16
  end_test_connection!
18
17
  end
19
18
  it "fails if the port doesn't correspond to a running server" do
@@ -23,56 +22,56 @@ describe DealerStream do
23
22
  -> { DealerStream.new(port) }.must_raise DealerStream::UnableToConnectToDealer
24
23
  end
25
24
  end
25
+ let(:port) { 0 }
26
+ let(:fake_dealer) { TCPServer.open(port) }
27
+ let(:client_connection) { fake_dealer.accept }
28
+ let(:patient) do
29
+ DealerStream.new(
30
+ fake_dealer.addr[1],
31
+ 'localhost'
32
+ )
33
+ end
34
+ let(:match_state) { 'MATCHSTATE:0:0::5d5c' }
35
+
26
36
  describe "#ready_to_read?" do
27
37
  it 'lets the caller know that there is new input from the dealer' do
28
38
  connect_successfully!
29
- @client_connection.puts "New input"
30
- @patient.ready_to_read?.must_equal true
39
+ client_connection.puts "New input"
40
+ patient.ready_to_read?.must_equal true
31
41
  end
32
42
  end
33
43
  describe "#ready_to_write?" do
34
44
  it 'lets the caller know if the dealer is ready to receive data' do
35
45
  connect_successfully!
36
- @patient.ready_to_write?.must_equal true
46
+ patient.ready_to_write?.must_equal true
37
47
  end
38
48
  end
39
49
  describe "#write" do
40
50
  it "properly sends actions to the dealer" do
41
51
  connect_successfully!
42
- action = @match_state + ':c'
43
- @patient.write action
52
+ action = match_state + ':c'
53
+ patient.write action
44
54
 
45
- @client_connection.gets.chomp.must_equal(action)
55
+ client_connection.gets.chomp.must_equal(action)
46
56
  end
47
57
  end
48
58
  describe "#gets" do
49
59
  it "properly receives matchstate strings from the dealer" do
50
60
  connect_successfully!
51
- @client_connection.puts @match_state
52
- @patient.gets.must_equal(@match_state)
61
+ client_connection.puts match_state
62
+ patient.gets.must_equal(match_state)
53
63
  end
54
64
  end
55
65
 
56
66
  def end_test_connection!
57
- @patient.close if @patient && !@patient.closed?
58
- @client_connection.close if @client_connection && !@client_connection.closed?
59
- end
60
-
61
- def start_test_connection!(port = 0)
62
- fake_dealer = TCPServer.open(port)
63
- @patient = DealerStream.new(
64
- fake_dealer.addr[1],
65
- 'localhost'
66
- )
67
- @client_connection = fake_dealer.accept
67
+ patient.close if !patient.closed?
68
+ client_connection.close if !client_connection.closed?
68
69
  end
69
70
 
70
71
  def connect_successfully!
71
- start_test_connection!
72
- @client_connection.gets.chomp.must_equal(
72
+ patient
73
+ client_connection.gets.chomp.must_equal(
73
74
  "#{DealerStream::VERSION_LABEL}:#{DealerStream::VERSION_NUMBERS[:major]}.#{DealerStream::VERSION_NUMBERS[:minor]}.#{DealerStream::VERSION_NUMBERS[:revision]}"
74
75
  )
75
-
76
- @match_state = 'MATCHSTATE:0:0::5d5c'
77
76
  end
78
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_basic_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill