redis_test 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +2 -1
- data/lib/redis_test.rb +17 -5
- data/lib/redis_test/version.rb +1 -1
- data/redis_test.gemspec +2 -0
- data/spec/redis_test_spec.rb +21 -0
- data/spec/spec_helper.rb +19 -0
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52cb243023a193b9d9db16eb99415aa932d50fd3
|
4
|
+
data.tar.gz: 55b9ca8ae4308ab19beaf7dd74f4a97a8f336074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a961e22060cd7e6023311a299657c4e77a4a9342f23adc5838f7fb0bd7e51987523edffa72f75f1d7cfa0f7220b3d9be8b3a546a3e569c79a684f104115b5ed7
|
7
|
+
data.tar.gz: 2007cb3b6437e67fa63b7ff710616b5602fd2eaae4ca54ae8d3a5b5260a8ad19faaecb0ca53a2327c26ed68c4942acf2c873b433ad6c9994a47674293b27d219
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,8 @@ You can use it with RSpec by putting this block under your spec/support:
|
|
37
37
|
```ruby
|
38
38
|
RSpec.configure do |config|
|
39
39
|
config.before(:suite) do
|
40
|
-
RedisTest.start
|
40
|
+
RedisTest.start(log_to_stdout: true)
|
41
|
+
# if log_to_stdout ommited it will logs to file
|
41
42
|
RedisTest.configure(:default, :sidekiq)
|
42
43
|
# RedisTest provide common configuration for :default (set
|
43
44
|
# Redis.current), :sidekiq, :ohm (set Ohm.redis) and :resque.
|
data/lib/redis_test.rb
CHANGED
@@ -39,7 +39,7 @@ module RedisTest
|
|
39
39
|
@loglevel = level
|
40
40
|
end
|
41
41
|
|
42
|
-
def start
|
42
|
+
def start(log_to_stdout: false)
|
43
43
|
FileUtils.mkdir_p cache_path
|
44
44
|
FileUtils.mkdir_p pids_path
|
45
45
|
FileUtils.mkdir_p logs_path
|
@@ -47,15 +47,22 @@ module RedisTest
|
|
47
47
|
redis_options = {
|
48
48
|
"daemonize" => 'yes',
|
49
49
|
"pidfile" => pidfile,
|
50
|
-
"logfile" => logfile,
|
51
50
|
"port" => port,
|
52
51
|
"timeout" => 300,
|
53
52
|
"dbfilename" => db_filename,
|
54
53
|
"dir" => cache_path,
|
55
54
|
"loglevel" => loglevel,
|
56
55
|
"databases" => 16
|
57
|
-
}
|
58
|
-
|
56
|
+
}
|
57
|
+
|
58
|
+
unless log_to_stdout
|
59
|
+
redis_options.merge!(
|
60
|
+
"logfile" => logfile,
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
redis_options_str = redis_options.map { |k, v| "#{k} #{v}" }.join('\n')
|
65
|
+
`echo '#{redis_options_str}' | redis-server -`
|
59
66
|
|
60
67
|
wait_time_remaining = 5
|
61
68
|
begin
|
@@ -77,7 +84,12 @@ module RedisTest
|
|
77
84
|
def stop
|
78
85
|
if File.file?(pidfile) && File.readable?(pidfile)
|
79
86
|
pid = File.read(pidfile).to_i
|
80
|
-
|
87
|
+
if pid > 0
|
88
|
+
Process.kill("QUIT", pid)
|
89
|
+
until (Process.getpgid(pid) rescue nil).nil? do
|
90
|
+
sleep 0.01
|
91
|
+
end
|
92
|
+
end
|
81
93
|
end
|
82
94
|
FileUtils.rm_f("#{cache_path}#{db_filename}")
|
83
95
|
end
|
data/lib/redis_test/version.rb
CHANGED
data/redis_test.gemspec
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RedisTest do
|
4
|
+
describe '#start' do
|
5
|
+
describe "log_to_stdout = false" do
|
6
|
+
it "starts fine" do
|
7
|
+
RedisTest.start
|
8
|
+
RedisTest.stop
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#start' do
|
14
|
+
describe "log_to_stdout = true" do
|
15
|
+
it "starts fine" do
|
16
|
+
RedisTest.start(log_to_stdout: false)
|
17
|
+
RedisTest.stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'redis_test'
|
3
|
+
|
4
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
5
|
+
# in spec/support/ and its subdirectories.
|
6
|
+
Dir[File.expand_path("./spec/support/**/*.rb")].each { |f| require f }
|
7
|
+
|
8
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
|
14
|
+
# Run specs in random order to surface order dependencies. If you find an
|
15
|
+
# order dependency and want to debug it, you can fix the order by providing
|
16
|
+
# the seed, which is printed after each run.
|
17
|
+
# --seed 1234
|
18
|
+
config.order = 'random'
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phuong Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
description: A helper to launch redis server during test
|
42
70
|
email:
|
43
71
|
- phuongnd08@gmail.com
|
@@ -53,6 +81,8 @@ files:
|
|
53
81
|
- lib/redis_test.rb
|
54
82
|
- lib/redis_test/version.rb
|
55
83
|
- redis_test.gemspec
|
84
|
+
- spec/redis_test_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
56
86
|
homepage: https://github.com/phuongnd08/redis_test
|
57
87
|
licenses:
|
58
88
|
- MIT
|
@@ -77,4 +107,6 @@ rubygems_version: 2.4.5.3
|
|
77
107
|
signing_key:
|
78
108
|
specification_version: 4
|
79
109
|
summary: A helper to launch redis server during test
|
80
|
-
test_files:
|
110
|
+
test_files:
|
111
|
+
- spec/redis_test_spec.rb
|
112
|
+
- spec/spec_helper.rb
|