em-pg-client-12 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,125 @@
1
+ $:.unshift "lib"
2
+ gem 'eventmachine', '~> 1.0.0'
3
+ gem 'pg', ENV['EM_PG_CLIENT_TEST_PG_VERSION']
4
+ require 'date'
5
+ require 'eventmachine'
6
+ require 'pg/em'
7
+
8
+ describe PG::EM::FeaturedDeferrable do
9
+ subject { PG::EM::FeaturedDeferrable }
10
+ let(:df) { subject.new }
11
+ let(:cb) { Proc.new {} }
12
+ let(:error) { RuntimeError.new }
13
+ let(:pg_error) {
14
+ PG::Error.new.tap do |err|
15
+ err.instance_variable_set :@connection, :connection
16
+ err.instance_variable_set :@result, :result
17
+ end
18
+ }
19
+
20
+ it "should set callback with a block " do
21
+ cb.should_receive(:call).with(:result)
22
+ df = subject.new(&cb)
23
+ df.succeed(:result)
24
+ end
25
+
26
+ it "should set errback with a block" do
27
+ cb.should_receive(:call).with(:err)
28
+ df = subject.new(&cb)
29
+ df.fail(:err)
30
+ end
31
+
32
+ it "should execute callbacks and errbacks in setup order" do
33
+ results = []
34
+ setup_callbacks = proc do |df|
35
+ df.callback { results << 1 }
36
+ df.callback { results << 2 }
37
+ df.callback { results << 3 }
38
+ df.errback { results << 4 }
39
+ df.errback { results << 5 }
40
+ df.errback { results << 6 }
41
+ end
42
+ df = subject.new
43
+ setup_callbacks.call df
44
+ df.succeed
45
+ df.fail
46
+ df = subject.new
47
+ setup_callbacks.call df
48
+ df.fail
49
+ df.succeed
50
+ results.should eq [1, 2, 3, 4, 5, 6]
51
+ end
52
+
53
+ it "should set completion with block" do
54
+ cb.should_receive(:call).with(:err)
55
+ df = subject.new
56
+ df.completion(&cb)
57
+ df.fail(:err)
58
+ df.succeed(:result)
59
+
60
+ cb.should_receive(:call).with(:result)
61
+ df = subject.new
62
+ df.completion(&cb)
63
+ df.succeed(:result)
64
+ df.fail(:err)
65
+ end
66
+
67
+ it "should bind status to another deferrable" do
68
+ cb.should_receive(:call).with(:result)
69
+ df = subject.new(&cb)
70
+ other_df = subject.new
71
+ df.bind_status(other_df)
72
+ other_df.succeed(:result)
73
+
74
+ cb.should_receive(:call).with(:err)
75
+ df = subject.new(&cb)
76
+ other_df = subject.new
77
+ df.bind_status(other_df)
78
+ other_df.fail(:err)
79
+ end
80
+
81
+ shared_context 'shared protect' do
82
+ it "should call df.fail and return nil" do
83
+ ::EM.stub(:next_tick) {|&cb| cb.call }
84
+ df.errback(&cb)
85
+ cb.should_receive(:call).with(error)
86
+ df.send(protect_method) do
87
+ raise error
88
+ end.should be_nil
89
+ end
90
+
91
+ it "should call df.fail and return custom fail value" do
92
+ ::EM.stub(:next_tick) {|&cb| cb.call }
93
+ df.errback(&cb)
94
+ cb.should_receive(:call).with(error)
95
+ df.send(protect_method, :fail) do
96
+ raise error
97
+ end.should eq :fail
98
+ end
99
+ end
100
+
101
+ context "#protect" do
102
+ let(:protect_method) { :protect }
103
+ it "should return value" do
104
+ df.protect do
105
+ :result
106
+ end.should eq :result
107
+ end
108
+
109
+ include_context 'shared protect'
110
+ end
111
+
112
+ context "#protect_and_succeed" do
113
+ let(:protect_method) { :protect_and_succeed }
114
+ it "should call deferrable.succeed and return value" do
115
+ ::EM.stub(:next_tick) {|&cb| cb.call }
116
+ df.callback(&cb)
117
+ cb.should_receive(:call).with(:result)
118
+ df.protect_and_succeed do
119
+ :result
120
+ end.should eq :result
121
+ end
122
+
123
+ include_context 'shared protect'
124
+ end
125
+ end
@@ -0,0 +1,9 @@
1
+ if ENV["COVERAGE"]
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+
5
+ SimpleCov.start do
6
+ add_filter "/spec/"
7
+ end
8
+ SimpleCov.command_name ENV['COVNAME'] || 'RSpec'
9
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: em-pg-client-12
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
5
+ platform: ruby
6
+ authors:
7
+ - Rafal Michalski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pg
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.17.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.17.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: eventmachine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: em-synchrony
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.2
97
+ description: PostgreSQL asynchronous EventMachine client, based on pg interface (PG::Connection)
98
+ email: rafal@yeondir.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files:
102
+ - benchmarks/em_pg.rb
103
+ - benchmarks/single_row_mode.rb
104
+ - README.md
105
+ - BENCHMARKS.md
106
+ - LICENSE
107
+ - HISTORY.md
108
+ files:
109
+ - ".rspec"
110
+ - ".travis.yml"
111
+ - ".yardopts"
112
+ - BENCHMARKS.md
113
+ - Gemfile
114
+ - HISTORY.md
115
+ - LICENSE
116
+ - README.md
117
+ - Rakefile
118
+ - benchmarks/em_pg.rb
119
+ - benchmarks/single_row_mode.rb
120
+ - em-pg-client.gemspec
121
+ - examples/single_row_mode.rb
122
+ - lib/em-pg-client.rb
123
+ - lib/em-synchrony/pg.rb
124
+ - lib/pg/em-version.rb
125
+ - lib/pg/em.rb
126
+ - lib/pg/em/client/connect_watcher.rb
127
+ - lib/pg/em/client/watcher.rb
128
+ - lib/pg/em/connection_pool.rb
129
+ - lib/pg/em/featured_deferrable.rb
130
+ - spec/connection_pool_helpers.rb
131
+ - spec/em_client.rb
132
+ - spec/em_client_autoreconnect.rb
133
+ - spec/em_client_common.rb
134
+ - spec/em_client_on_connect.rb
135
+ - spec/em_connection_pool.rb
136
+ - spec/em_synchrony_client.rb
137
+ - spec/em_synchrony_client_autoreconnect.rb
138
+ - spec/pg_em_client_connect_finish.rb
139
+ - spec/pg_em_client_connect_timeout.rb
140
+ - spec/pg_em_client_options.rb
141
+ - spec/pg_em_connection_pool.rb
142
+ - spec/pg_em_featured_deferrable.rb
143
+ - spec/spec_helper.rb
144
+ homepage: http://github.com/royaltm/ruby-em-pg-client
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options:
150
+ - "--title"
151
+ - em-pg-client
152
+ - "--main"
153
+ - README.md
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 1.9.2
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements:
167
+ - PostgreSQL server
168
+ rubyforge_project:
169
+ rubygems_version: 2.5.1
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: EventMachine PostgreSQL client
173
+ test_files:
174
+ - spec/connection_pool_helpers.rb
175
+ - spec/em_client.rb
176
+ - spec/em_client_autoreconnect.rb
177
+ - spec/em_client_common.rb
178
+ - spec/em_client_on_connect.rb
179
+ - spec/em_connection_pool.rb
180
+ - spec/em_synchrony_client.rb
181
+ - spec/em_synchrony_client_autoreconnect.rb
182
+ - spec/pg_em_client_connect_finish.rb
183
+ - spec/pg_em_client_connect_timeout.rb
184
+ - spec/pg_em_client_options.rb
185
+ - spec/pg_em_connection_pool.rb
186
+ - spec/pg_em_featured_deferrable.rb
187
+ - spec/spec_helper.rb