rspec-background-process 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,102 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'rspec-background-process'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ require 'rspec/core/shared_context'
11
+
12
+ module Process
13
+ extend RSpec::Core::SharedContext
14
+
15
+ subject do
16
+ background_process('spec/support/test_process', group: "fresh[#{rand}]", load: true)
17
+ end
18
+ end
19
+
20
+ module ProcessWithLoggedVariables
21
+ extend RSpec::Core::SharedContext
22
+
23
+ subject do
24
+ background_process('spec/support/test_process', group: "fresh[#{rand}]", load: true).with do |process|
25
+ process.ready_when_log_includes 'hello world'
26
+ end
27
+ end
28
+ end
29
+
30
+ module Instance
31
+ extend RSpec::Core::SharedContext
32
+
33
+ subject do
34
+ background_process('spec/support/test_process', group: "fresh[#{rand}]", load: true).instance
35
+ end
36
+ end
37
+
38
+ module HTTPProcessWithLoggedVariables
39
+ extend RSpec::Core::SharedContext
40
+
41
+ subject do
42
+ background_process('spec/support/test_http_server', group: "http_fresh[#{rand}]", load: true).with do |process|
43
+ process.ready_when_log_includes 'listening'
44
+ end
45
+ end
46
+ end
47
+
48
+ module HTTPProcess
49
+ extend RSpec::Core::SharedContext
50
+
51
+ subject do
52
+ background_process('spec/support/test_http_server', group: "http_fresh[#{rand}]", load: true)
53
+ end
54
+ end
55
+
56
+ module DyingProcess
57
+ extend RSpec::Core::SharedContext
58
+
59
+ subject do
60
+ background_process('spec/support/test_die', group: "die[#{rand}]", load: true)
61
+ end
62
+ end
63
+
64
+ module SlowlyDyingProcess
65
+ extend RSpec::Core::SharedContext
66
+
67
+ subject do
68
+ background_process('spec/support/test_slow_die', group: "slow_die[#{rand}]", load: true)
69
+ end
70
+ end
71
+
72
+ RSpec::Matchers.define_negated_matcher :different_than, :be
73
+
74
+ RSpec.configure do |config|
75
+ config.include Process, subject: :process
76
+ config.include BackgroundProcessHelpers, subject: :process
77
+
78
+ config.include ProcessWithLoggedVariables, subject: :process_ready_variables
79
+ config.include BackgroundProcessHelpers, subject: :process_ready_variables
80
+
81
+ config.include Instance, subject: :instance
82
+ config.include BackgroundProcessHelpers, subject: :instance
83
+
84
+ config.include HTTPProcess, subject: :http_process
85
+ config.include BackgroundProcessHelpers, subject: :http_process
86
+
87
+ config.include HTTPProcessWithLoggedVariables, subject: :http_process_ready_variables
88
+ config.include BackgroundProcessHelpers, subject: :http_process_ready_variables
89
+
90
+ config.include DyingProcess, subject: :dying_process
91
+ config.include BackgroundProcessHelpers, subject: :dying_process
92
+
93
+ config.include SlowlyDyingProcess, subject: :slowly_dying_process
94
+ config.include BackgroundProcessHelpers, subject: :slowly_dying_process
95
+
96
+ config.alias_example_group_to :feature
97
+ config.alias_example_to :scenario
98
+
99
+ config.before :all do
100
+ #process_pool(logging: true)
101
+ end
102
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts 'bye'
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "webrick"
4
+
5
+ puts "ARGV: #{ARGV.inspect}"
6
+
7
+ port = ARGV.grep(/localhost:/).first.split(':', 2).last rescue 1234
8
+ puts "listening on port: #{port}"
9
+
10
+ server = WEBrick::HTTPServer.new(:Port => port)
11
+
12
+ server.mount_proc '/health_check' do |req, res|
13
+ puts 'got health_check request'
14
+ res.body = "OK\n\r"
15
+ end
16
+
17
+ trap("INT") {
18
+ server.shutdown
19
+ }
20
+
21
+ trap("TERM") {
22
+ server.shutdown
23
+ }
24
+
25
+ puts "starting"
26
+
27
+ server.start
28
+
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "ARGV: #{ARGV.inspect}"
4
+ puts "$0: #{$0}"
5
+ puts "$*: #{$*.inspect}"
6
+ puts "ENV['PROCESS_SPAWN_TYPE']: #{ENV['PROCESS_SPAWN_TYPE']}"
7
+ puts "cwd: '#{Dir.pwd}'"
8
+
9
+ puts 'hello world'
10
+
11
+ STDOUT.flush
12
+ sleep 2
13
+ puts 'started'
14
+ STDOUT.flush
15
+ sleep 20
16
+ puts 'died'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts 'hi'
4
+
5
+ sleep 0.5
6
+
7
+ puts 'bye'
metadata ADDED
@@ -0,0 +1,232 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-background-process
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jakub Pastuszek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-09-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.1'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: daemon
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.2'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.2'
94
+ - !ruby/object:Gem::Dependency
95
+ name: micromachine
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '1.1'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.1'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rufus-lru
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: file-tail
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: retries
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.0.5
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.0.5
158
+ description: RSpec and Cucumber DSL that allows definition of processes with their
159
+ arguments, working directory, time outs, port numbers etc. and start/stop them during
160
+ test runs. Processes with same definitions can pooled and reused between example
161
+ runs to save time on startup/shutdown. Pooling supports process number limiting
162
+ with LRU to limit memory used.
163
+ email: jpastuszek@gmail.com
164
+ executables: []
165
+ extensions: []
166
+ extra_rdoc_files:
167
+ - LICENSE.txt
168
+ - README.rdoc
169
+ files:
170
+ - .document
171
+ - .rspec
172
+ - Gemfile
173
+ - Gemfile.lock
174
+ - LICENSE.txt
175
+ - README.rdoc
176
+ - Rakefile
177
+ - VERSION
178
+ - lib/rspec-background-process.rb
179
+ - lib/rspec-background-process/background_process.rb
180
+ - lib/rspec-background-process/background_process_helpers.rb
181
+ - lib/rspec-background-process/process_pool.rb
182
+ - lib/rspec-background-process/readiness_checks.rb
183
+ - lib/rspec-background-process/refresh_actions.rb
184
+ - lib/rspec-background-process/server.rb
185
+ - rspec-background-process.gemspec
186
+ - spec/background_process_helpers_spec.rb
187
+ - spec/background_process_spec.rb
188
+ - spec/features/cwd_spec.rb
189
+ - spec/features/dead_detection_spec.rb
190
+ - spec/features/exec_and_loading_spec.rb
191
+ - spec/features/pool_lru_spec.rb
192
+ - spec/features/ready_test_spec.rb
193
+ - spec/features/refresh_spec.rb
194
+ - spec/features/reuse_spec.rb
195
+ - spec/features/server_spec.rb
196
+ - spec/features/variables_replacement_spec.rb
197
+ - spec/process_definition_spec.rb
198
+ - spec/spec_helper.rb
199
+ - spec/support/test_die
200
+ - spec/support/test_http_server
201
+ - spec/support/test_process
202
+ - spec/support/test_slow_die
203
+ homepage: http://github.com/jpastuszek/rspec-background-process
204
+ licenses:
205
+ - MIT
206
+ post_install_message:
207
+ rdoc_options: []
208
+ require_paths:
209
+ - lib
210
+ required_ruby_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -1403335557927163219
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
220
+ none: false
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ requirements: []
226
+ rubyforge_project:
227
+ rubygems_version: 1.8.23
228
+ signing_key:
229
+ specification_version: 3
230
+ summary: RSpec and Cucumber DSL library that helps managing background processes during
231
+ test runs
232
+ test_files: []