pusher-fake 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42a6b06339e9aa4e4933b9c0f02b9984a130ab11
4
- data.tar.gz: 57d8cd546b75b7940c85e85d45a3515d69968916
3
+ metadata.gz: c3f79253d72f830d37f4a25a95b9bde1d58cdb19
4
+ data.tar.gz: fa1401d5a24e2d49f2ed0b89cd02b663e5dd0361
5
5
  SHA512:
6
- metadata.gz: 5ad02105f89ff309de49faa8c2373cefc0871c8d4a65775f110c6b146aff935419254b616afc411448a1c4a11f6770d2457ae2c912e57bebd580eb18495364ca
7
- data.tar.gz: a87b942726c3cd12d2fd11e46eebc285fe8e2e742f6fe704625a81b0ebfc7139fe6288d97bc348876e871bd772d6578d4eba1e9f02b174e44f788cacea0cf0e9
6
+ metadata.gz: 4b629399e6094408686c54492d02e40a19a5331f85057a97146fe879e88d6f3f44812e0d334dd759bd33051a0495c55cecae80ae150710ffe0d30516f0e56425
7
+ data.tar.gz: e9a65e650f03408fe170c9d88fac0cfa05b8061ade712812304ddabe270c9853fedf63a3a960ac879e2cae5dd41f530a8487ca6c828147fc09dc49fe0696de1c
@@ -1,4 +1,6 @@
1
- Pusher.url = "http://PUSHER_API_KEY:PUSHER_API_SECRET@localhost:8081/apps/PUSHER_APP_ID"
1
+ PusherFake.configuration.web_options.tap do |options|
2
+ Pusher.url = "http://PUSHER_API_KEY:PUSHER_API_SECRET@#{options[:host]}:#{options[:port]}/apps/PUSHER_APP_ID"
3
+ end
2
4
 
3
5
  Thread.new { PusherFake::Server.start }.tap do |thread|
4
6
  at_exit { thread.exit }
data/lib/pusher-fake.rb CHANGED
@@ -6,7 +6,7 @@ require "thin"
6
6
 
7
7
  module PusherFake
8
8
  # The current version string.
9
- VERSION = "1.1.0"
9
+ VERSION = "1.2.0"
10
10
 
11
11
  autoload :Channel, "pusher-fake/channel"
12
12
  autoload :Configuration, "pusher-fake/configuration"
@@ -37,8 +37,8 @@ module PusherFake
37
37
  self.verbose = false
38
38
  self.webhooks = []
39
39
 
40
- self.socket_options = { host: "127.0.0.1", port: 8080 }
41
- self.web_options = { host: "127.0.0.1", port: 8081 }
40
+ self.socket_options = { host: "127.0.0.1", port: available_port }
41
+ self.web_options = { host: "127.0.0.1", port: available_port }
42
42
  end
43
43
 
44
44
  # Convert the configuration to a hash sutiable for Pusher JS options.
@@ -50,5 +50,15 @@ module PusherFake
50
50
  wsPort: socket_options[:port]
51
51
  )
52
52
  end
53
+
54
+ private
55
+
56
+ def available_port
57
+ socket = Socket.new(:INET, :STREAM, 0)
58
+ socket.bind(Addrinfo.tcp("127.0.0.1", 0))
59
+ socket.local_address.ip_port.tap do
60
+ socket.close
61
+ end
62
+ end
53
63
  end
54
64
  end
@@ -5,10 +5,24 @@ describe PusherFake::Configuration do
5
5
  it { should have_configuration_option(:key).with_default("PUSHER_API_KEY") }
6
6
  it { should have_configuration_option(:logger).with_default(STDOUT.to_io) }
7
7
  it { should have_configuration_option(:secret).with_default("PUSHER_API_SECRET") }
8
- it { should have_configuration_option(:socket_options).with_default({ host: "127.0.0.1", port: 8080 }) }
9
8
  it { should have_configuration_option(:verbose).with_default(false) }
10
- it { should have_configuration_option(:web_options).with_default({ host: "127.0.0.1", port: 8081 }) }
11
9
  it { should have_configuration_option(:webhooks).with_default([]) }
10
+
11
+ it "should have configuration option :socket_options" do
12
+ expect(subject.socket_options).to be_a(Hash)
13
+ expect(subject.socket_options[:host]).to eq("127.0.0.1")
14
+ expect(subject.socket_options[:port]).to be_a(Integer)
15
+ end
16
+
17
+ it "should have configuration option :web_options" do
18
+ expect(subject.web_options).to be_a(Hash)
19
+ expect(subject.web_options[:host]).to eq("127.0.0.1")
20
+ expect(subject.web_options[:port]).to be_a(Integer)
21
+ end
22
+
23
+ it "defaults socket and web ports to different values" do
24
+ expect(subject.socket_options[:port]).to_not eq(subject.web_options[:port])
25
+ end
12
26
  end
13
27
 
14
28
  describe PusherFake::Configuration, "#to_options" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-fake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 1.3.15
103
+ version: 1.3.16
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 1.3.15
110
+ version: 1.3.16
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pusher
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.14.0
117
+ version: 0.14.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.14.0
124
+ version: 0.14.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement