dbi-dbrc 1.4.1 → 1.5.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.md} +31 -25
- data/Gemfile +3 -0
- data/{MANIFEST → MANIFEST.md} +6 -6
- data/README.md +292 -0
- data/Rakefile +5 -21
- data/dbi-dbrc.gemspec +4 -7
- data/lib/dbi/dbrc.rb +5 -4
- data/spec/dbi_dbrc_spec.rb +236 -0
- data/spec/dbi_dbrc_xml_spec.rb +95 -0
- data/spec/dbi_dbrc_yml_spec.rb +89 -0
- data/spec/spec_helper.rb +5 -0
- metadata +45 -35
- metadata.gz.sig +0 -0
- data/README +0 -265
- data/test/test_dbi_dbrc.rb +0 -199
- data/test/test_dbi_dbrc_xml.rb +0 -159
- data/test/test_dbi_dbrc_yml.rb +0 -157
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/clean'
|
3
|
-
require '
|
3
|
+
require 'rspec/core/rake_task'
|
4
4
|
|
5
|
-
CLEAN.include("**/*.gem", "**/*.rbc")
|
5
|
+
CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
|
6
6
|
|
7
7
|
namespace :gem do
|
8
8
|
desc "Create the dbi-dbrc gem"
|
@@ -20,23 +20,7 @@ namespace :gem do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
t.warning = true
|
26
|
-
t.verbose = true
|
27
|
-
end
|
28
|
-
|
29
|
-
Rake::TestTask.new(:xml) do |t|
|
30
|
-
t.warning = true
|
31
|
-
t.verbose = true
|
32
|
-
t.test_files = FileList['test/test_dbi_dbrc_xml.rb']
|
33
|
-
end
|
34
|
-
|
35
|
-
Rake::TestTask.new(:yml) do |t|
|
36
|
-
t.warning = true
|
37
|
-
t.verbose = true
|
38
|
-
t.test_files = FileList['test/test_dbi_dbrc_yml.rb']
|
39
|
-
end
|
40
|
-
end
|
23
|
+
desc "Run the test suite"
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
41
25
|
|
42
|
-
task :default =>
|
26
|
+
task :default => :spec
|
data/dbi-dbrc.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'dbi-dbrc'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.5.0'
|
6
6
|
spec.author = 'Daniel Berger'
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
8
8
|
spec.license = 'Apache-2.0'
|
@@ -12,17 +12,14 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.test_files = Dir['test/test*.rb']
|
13
13
|
spec.cert_chain = Dir['certs/*']
|
14
14
|
|
15
|
-
spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
16
|
-
|
17
|
-
spec.required_ruby_version = ">= 1.9.3"
|
18
|
-
|
19
|
-
spec.add_development_dependency('test-unit')
|
20
15
|
spec.add_development_dependency('rake')
|
16
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
17
|
+
spec.add_development_dependency('fakefs', '~> 1.3')
|
21
18
|
|
22
19
|
spec.metadata = {
|
23
20
|
'homepage_uri' => 'https://github.com/djberg96/dbi-dbrc',
|
24
21
|
'bug_tracker_uri' => 'https://github.com/djberg96/dbi-dbrc/issues',
|
25
|
-
'changelog_uri' => 'https://github.com/djberg96/dbi-dbrc/blob/
|
22
|
+
'changelog_uri' => 'https://github.com/djberg96/dbi-dbrc/blob/main/CHANGES',
|
26
23
|
'documentation_uri' => 'https://github.com/djberg96/dbi-dbrc/wiki',
|
27
24
|
'source_code_uri' => 'https://github.com/djberg96/dbi-dbrc',
|
28
25
|
'wiki_uri' => 'https://github.com/djberg96/dbi-dbrc/wiki'
|
data/lib/dbi/dbrc.rb
CHANGED
@@ -18,7 +18,7 @@ module DBI
|
|
18
18
|
class Error < StandardError; end
|
19
19
|
|
20
20
|
# The version of the dbi-dbrc library
|
21
|
-
VERSION = '1.
|
21
|
+
VERSION = '1.5.0'.freeze
|
22
22
|
|
23
23
|
WINDOWS = File::ALT_SEPARATOR # :no-doc:
|
24
24
|
|
@@ -118,6 +118,7 @@ module DBI
|
|
118
118
|
end
|
119
119
|
|
120
120
|
@dbrc_file = File.join(home, '.dbrc')
|
121
|
+
dbrc_dir = home
|
121
122
|
else
|
122
123
|
raise Error, 'bad directory' unless File.directory?(dbrc_dir)
|
123
124
|
@dbrc_file = File.join(dbrc_dir, '.dbrc')
|
@@ -220,7 +221,7 @@ module DBI
|
|
220
221
|
# Parse the text out of the .dbrc file. This is the only method you
|
221
222
|
# need to redefine if writing your own config handler.
|
222
223
|
def parse_dbrc_config_file(file=@dbrc_file)
|
223
|
-
|
224
|
+
File.foreach(file){ |line|
|
224
225
|
next if line =~ /^#/ # Ignore comments
|
225
226
|
db, user, pwd, driver, timeout, max, interval = line.split
|
226
227
|
|
@@ -253,7 +254,7 @@ module DBI
|
|
253
254
|
|
254
255
|
# A subclass of DBRC designed to handle .dbrc files in XML format. The
|
255
256
|
# public methods of this class are identical to DBRC.
|
256
|
-
class XML < DBRC
|
257
|
+
class DBRC::XML < DBRC
|
257
258
|
require 'rexml/document' # Good enough for small files
|
258
259
|
include REXML
|
259
260
|
|
@@ -282,7 +283,7 @@ module DBI
|
|
282
283
|
|
283
284
|
# A subclass of DBRC designed to handle .dbrc files in YAML format. The
|
284
285
|
# public methods of this class are identical to DBRC.
|
285
|
-
class YML < DBRC
|
286
|
+
class DBRC::YML < DBRC
|
286
287
|
require 'yaml'
|
287
288
|
|
288
289
|
private
|
@@ -0,0 +1,236 @@
|
|
1
|
+
#########################################################################
|
2
|
+
# dbi_dbrc_spec.rb
|
3
|
+
#
|
4
|
+
# Specs for the base class of DBI::DBRC. This test case should be
|
5
|
+
# run via the 'rake spec' task.
|
6
|
+
#########################################################################
|
7
|
+
require 'dbi/dbrc'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'spec_helper'
|
10
|
+
require 'pp' # Requiring this ahead of fakefs to address a superclass issue.
|
11
|
+
require 'fakefs/spec_helpers'
|
12
|
+
|
13
|
+
RSpec.describe DBI::DBRC do
|
14
|
+
include FakeFS::SpecHelpers
|
15
|
+
|
16
|
+
let(:windows) { File::ALT_SEPARATOR }
|
17
|
+
let(:home) { File.join(Dir.pwd, 'home', 'someone') }
|
18
|
+
let(:dbrc) { File.join(home, '.dbrc') }
|
19
|
+
|
20
|
+
let(:plain) {
|
21
|
+
%q{
|
22
|
+
foo user1 pwd1 Oracle 40 3 60
|
23
|
+
foo user2 pwd2 OCI8 60 4 60
|
24
|
+
bar user1 pwd3 Oracle 30 2 30
|
25
|
+
baz user3 pwd4
|
26
|
+
}.lstrip
|
27
|
+
}
|
28
|
+
|
29
|
+
let(:db_foo){ 'foo' }
|
30
|
+
let(:db_bar){ 'bar' }
|
31
|
+
let(:db_baz){ 'baz' }
|
32
|
+
let(:user1) { 'user1' }
|
33
|
+
let(:user2) { 'user2' }
|
34
|
+
|
35
|
+
before do
|
36
|
+
allow(Dir).to receive(:home).and_return(home)
|
37
|
+
FileUtils.mkdir_p(home)
|
38
|
+
File.open(dbrc, 'w'){ |fh| fh.write(plain) }
|
39
|
+
File.chmod(0600, dbrc)
|
40
|
+
|
41
|
+
# FakeFS doesn't implement this yet
|
42
|
+
allow_any_instance_of(FakeFS::File::Stat).to receive(:owned?).and_return(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
example "version" do
|
46
|
+
expect(described_class::VERSION).to eq('1.5.0')
|
47
|
+
expect(described_class::VERSION).to be_frozen
|
48
|
+
end
|
49
|
+
|
50
|
+
context "windows", :windows => true do
|
51
|
+
example "constructor raises an error unless the .dbrc file is hidden" do
|
52
|
+
File.unset_attr(plain, File::HIDDEN)
|
53
|
+
expect{ described_class.new(db_foo, user1) }.to raise_error(described_class::Error)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "constructor" do
|
58
|
+
example "constructor raises an error if the permissions are invalid" do
|
59
|
+
File.chmod(0555, dbrc)
|
60
|
+
expect{ described_class.new(db_foo, user1) }.to raise_error(described_class::Error)
|
61
|
+
end
|
62
|
+
|
63
|
+
example "constructor raises an error if no database is provided" do
|
64
|
+
expect{ described_class.new }.to raise_error(ArgumentError)
|
65
|
+
end
|
66
|
+
|
67
|
+
example "constructor works as expected with or without user" do
|
68
|
+
expect{ described_class.new(db_foo, user1) }.not_to raise_error
|
69
|
+
expect{ described_class.new(db_foo, nil) }.not_to raise_error
|
70
|
+
end
|
71
|
+
|
72
|
+
example "constructor fails if the database entry doesn't exist" do
|
73
|
+
expect{ described_class.new('bogus', user1) }.to raise_error(DBI::DBRC::Error)
|
74
|
+
end
|
75
|
+
|
76
|
+
example "constructor fails if the user entry doesn't exist" do
|
77
|
+
expect{ described_class.new(db_foo, 'nobody') }.to raise_error(DBI::DBRC::Error)
|
78
|
+
end
|
79
|
+
|
80
|
+
example "constructor fails if the .dbrc file isn't found in the specified directory" do
|
81
|
+
expect{ described_class.new(db_foo, user1, '/bogusXX') }.to raise_error(DBI::DBRC::Error)
|
82
|
+
end
|
83
|
+
|
84
|
+
example "constructor returns expected values for the same database with different users" do
|
85
|
+
dbrc1 = described_class.new(db_foo, user1)
|
86
|
+
dbrc2 = described_class.new(db_foo, user2)
|
87
|
+
expect(dbrc1.database).to eq(dbrc2.database)
|
88
|
+
expect(dbrc1.user).to eq('user1')
|
89
|
+
expect(dbrc2.user).to eq('user2')
|
90
|
+
end
|
91
|
+
|
92
|
+
example "constructor returns expected values for the same user with different database" do
|
93
|
+
dbrc1 = described_class.new(db_foo, user1)
|
94
|
+
dbrc2 = described_class.new(db_bar, user1)
|
95
|
+
expect(dbrc1.user).to eq(dbrc2.user)
|
96
|
+
expect(dbrc1.database).to eq('foo')
|
97
|
+
expect(dbrc2.database).to eq('bar')
|
98
|
+
end
|
99
|
+
|
100
|
+
example "constructor works as expected if some optional fields are not defined" do
|
101
|
+
dbrc = described_class.new(db_baz)
|
102
|
+
expect(dbrc.user).to eq("user3")
|
103
|
+
expect(dbrc.passwd).to eq("pwd4")
|
104
|
+
expect(dbrc.driver).to be_nil
|
105
|
+
expect(dbrc.interval).to be_nil
|
106
|
+
expect(dbrc.timeout).to be_nil
|
107
|
+
expect(dbrc.max_reconn).to be_nil
|
108
|
+
expect(dbrc.dsn).to be_nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "instance methods" do
|
113
|
+
before do
|
114
|
+
@dbrc = DBI::DBRC.new(db_foo)
|
115
|
+
end
|
116
|
+
|
117
|
+
example "basic database getter method and aliases" do
|
118
|
+
expect(@dbrc).to respond_to(:database)
|
119
|
+
expect(@dbrc.method(:database)).to eq(@dbrc.method(:db))
|
120
|
+
expect(@dbrc.method(:database)).to eq(@dbrc.method(:host))
|
121
|
+
end
|
122
|
+
|
123
|
+
example "basic database setter method and alias" do
|
124
|
+
expect(@dbrc).to respond_to(:database=)
|
125
|
+
expect(@dbrc.method(:database=)).to eq(@dbrc.method(:db=))
|
126
|
+
end
|
127
|
+
|
128
|
+
example "database method returns expected value" do
|
129
|
+
expect(@dbrc.database).to eq('foo')
|
130
|
+
end
|
131
|
+
|
132
|
+
example "basic dbrc_dir check" do
|
133
|
+
expect(@dbrc).to respond_to(:dbrc_dir)
|
134
|
+
end
|
135
|
+
|
136
|
+
example "dbrc_dir returns the expected value" do
|
137
|
+
expect(@dbrc.dbrc_dir).to eq(home)
|
138
|
+
end
|
139
|
+
|
140
|
+
example "basic dbrc_file check" do
|
141
|
+
expect(@dbrc).to respond_to(:dbrc_file)
|
142
|
+
end
|
143
|
+
|
144
|
+
example "dbrc_file returns the expected value" do
|
145
|
+
expect(File.basename(@dbrc.dbrc_file)).to eq('.dbrc')
|
146
|
+
end
|
147
|
+
|
148
|
+
example "basic dsn getter check" do
|
149
|
+
expect(@dbrc).to respond_to(:dsn)
|
150
|
+
end
|
151
|
+
|
152
|
+
example "dsn method returns the expected value" do
|
153
|
+
expect(@dbrc.dsn).to eq('dbi:Oracle:foo')
|
154
|
+
end
|
155
|
+
|
156
|
+
example "basic dsn setter check" do
|
157
|
+
expect(@dbrc).to respond_to(:dsn=)
|
158
|
+
end
|
159
|
+
|
160
|
+
example "user getter basic check" do
|
161
|
+
expect(@dbrc).to respond_to(:user)
|
162
|
+
end
|
163
|
+
|
164
|
+
example "user method returns expected value" do
|
165
|
+
expect(@dbrc.user).to eq('user1')
|
166
|
+
end
|
167
|
+
|
168
|
+
example "user setter basic check" do
|
169
|
+
expect(@dbrc).to respond_to(:user=)
|
170
|
+
end
|
171
|
+
|
172
|
+
example "password getter basic check and alias" do
|
173
|
+
expect(@dbrc).to respond_to(:password)
|
174
|
+
expect(@dbrc.method(:password)).to eq(@dbrc.method(:passwd))
|
175
|
+
end
|
176
|
+
|
177
|
+
example "password method returns expected value" do
|
178
|
+
expect(@dbrc.password).to eq("pwd1")
|
179
|
+
end
|
180
|
+
|
181
|
+
example "password setter basic check and alias" do
|
182
|
+
expect(@dbrc).to respond_to(:password=)
|
183
|
+
expect(@dbrc.method(:password=)).to eq(@dbrc.method(:passwd=))
|
184
|
+
end
|
185
|
+
|
186
|
+
example "driver getter basic check" do
|
187
|
+
expect(@dbrc).to respond_to(:driver)
|
188
|
+
end
|
189
|
+
|
190
|
+
example "driver method returns expected value" do
|
191
|
+
expect(@dbrc.driver).to eq("Oracle")
|
192
|
+
end
|
193
|
+
|
194
|
+
example "driver setter basic check" do
|
195
|
+
expect(@dbrc).to respond_to(:driver=)
|
196
|
+
end
|
197
|
+
|
198
|
+
example "interval getter basic check" do
|
199
|
+
expect(@dbrc).to respond_to(:interval)
|
200
|
+
end
|
201
|
+
|
202
|
+
example "interval method returns expected value" do
|
203
|
+
expect(@dbrc.interval).to eq(60)
|
204
|
+
end
|
205
|
+
|
206
|
+
example "interval setter basic check" do
|
207
|
+
expect(@dbrc).to respond_to(:interval=)
|
208
|
+
end
|
209
|
+
|
210
|
+
example "timeout getter basic check" do
|
211
|
+
expect(@dbrc).to respond_to(:timeout)
|
212
|
+
expect(@dbrc.method(:timeout)).to eq(@dbrc.method(:time_out))
|
213
|
+
end
|
214
|
+
|
215
|
+
example "timeout method returns expected value" do
|
216
|
+
expect(@dbrc.timeout).to eq(40)
|
217
|
+
end
|
218
|
+
|
219
|
+
example "timeout setter basic check" do
|
220
|
+
expect(@dbrc).to respond_to(:timeout=)
|
221
|
+
end
|
222
|
+
|
223
|
+
example "max_reconn getter basic check" do
|
224
|
+
expect(@dbrc).to respond_to(:max_reconn)
|
225
|
+
expect(@dbrc.method(:max_reconn)).to eq(@dbrc.method(:maximum_reconnects))
|
226
|
+
end
|
227
|
+
|
228
|
+
example "max_reconn method returns expected value" do
|
229
|
+
expect(@dbrc.max_reconn).to eq(3)
|
230
|
+
end
|
231
|
+
|
232
|
+
example "max_reconn setter basic check" do
|
233
|
+
expect(@dbrc).to respond_to(:max_reconn=)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
########################################################################
|
2
|
+
# dbi_dbrc_xml_spec.rb
|
3
|
+
#
|
4
|
+
# Test suite for the XML specific version of DBI::DBRC. This test case
|
5
|
+
# should be run via the 'rake test' task.
|
6
|
+
########################################################################
|
7
|
+
require 'dbi/dbrc'
|
8
|
+
require 'rspec'
|
9
|
+
require 'pp' # Need this to avoid fakefs error
|
10
|
+
require 'fakefs/spec_helpers'
|
11
|
+
|
12
|
+
RSpec.describe DBI::DBRC::XML, :xml => true do
|
13
|
+
include FakeFS::SpecHelpers
|
14
|
+
|
15
|
+
let(:home) { File.join(Dir.pwd, 'home', 'someone') }
|
16
|
+
let(:dbrc) { File.join(home, '.dbrc') }
|
17
|
+
|
18
|
+
let(:db_foo){ 'foo' }
|
19
|
+
let(:user1) { 'user1' }
|
20
|
+
|
21
|
+
let(:xml){
|
22
|
+
%q{
|
23
|
+
<dbrc>
|
24
|
+
<database name="foo">
|
25
|
+
<user>user1</user>
|
26
|
+
<password>pwd1</password>
|
27
|
+
<driver>Oracle</driver>
|
28
|
+
<interval>60</interval>
|
29
|
+
<timeout>40</timeout>
|
30
|
+
<maximum_reconnects>3</maximum_reconnects>
|
31
|
+
</database>
|
32
|
+
<database name="foo">
|
33
|
+
<user>user2</user>
|
34
|
+
<password>pwd2</password>
|
35
|
+
<driver>OCI8</driver>
|
36
|
+
<interval>60</interval>
|
37
|
+
<timeout>60</timeout>
|
38
|
+
<maximum_reconnects>4</maximum_reconnects>
|
39
|
+
</database>
|
40
|
+
<database name="bar">
|
41
|
+
<user>user1</user>
|
42
|
+
<password>pwd3</password>
|
43
|
+
<driver>Oracle</driver>
|
44
|
+
<interval>30</interval>
|
45
|
+
<timeout>30</timeout>
|
46
|
+
<maximum_reconnects>2</maximum_reconnects>
|
47
|
+
</database>
|
48
|
+
<database name="baz">
|
49
|
+
<user>user3</user>
|
50
|
+
<password>pwd4</password>
|
51
|
+
</database>
|
52
|
+
</dbrc>
|
53
|
+
}.lstrip
|
54
|
+
}
|
55
|
+
|
56
|
+
before do
|
57
|
+
allow(Dir).to receive(:home).and_return(home)
|
58
|
+
FileUtils.mkdir_p(home)
|
59
|
+
File.open(dbrc, 'w'){ |fh| fh.write(xml) }
|
60
|
+
File.chmod(0600, dbrc)
|
61
|
+
|
62
|
+
# FakeFS doesn't implement this yet
|
63
|
+
allow_any_instance_of(FakeFS::File::Stat).to receive(:owned?).and_return(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
context "instance methods" do
|
67
|
+
before do
|
68
|
+
@dbrc = described_class.new(db_foo, user1)
|
69
|
+
end
|
70
|
+
|
71
|
+
example "database method returns expected value" do
|
72
|
+
expect(@dbrc.database).to eq('foo')
|
73
|
+
end
|
74
|
+
|
75
|
+
example "password method returns expected value" do
|
76
|
+
expect(@dbrc.password).to eq('pwd1')
|
77
|
+
end
|
78
|
+
|
79
|
+
example "driver method returns expected value" do
|
80
|
+
expect(@dbrc.driver).to eq('Oracle')
|
81
|
+
end
|
82
|
+
|
83
|
+
example "interval method returns expected value" do
|
84
|
+
expect(@dbrc.interval).to eq(60)
|
85
|
+
end
|
86
|
+
|
87
|
+
example "timeout method returns expected value" do
|
88
|
+
expect(@dbrc.timeout).to eq(40)
|
89
|
+
end
|
90
|
+
|
91
|
+
example "maximum_reconnects method returns expected value" do
|
92
|
+
expect(@dbrc.maximum_reconnects).to eq(3)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
########################################################################
|
2
|
+
# dbi_dbrc_yml_spec.rb
|
3
|
+
#
|
4
|
+
# Test suite for the YAML specific version of DBI::DBRC. This test case
|
5
|
+
# should be run via the 'rake test' task.
|
6
|
+
########################################################################
|
7
|
+
require 'dbi/dbrc'
|
8
|
+
require 'rspec'
|
9
|
+
require 'pp' # Need this to avoid fakefs error
|
10
|
+
require 'fakefs/spec_helpers'
|
11
|
+
|
12
|
+
RSpec.describe DBI::DBRC::YML, :yml => true do
|
13
|
+
include FakeFS::SpecHelpers
|
14
|
+
|
15
|
+
let(:home) { File.join(Dir.pwd, 'home', 'someone') }
|
16
|
+
let(:dbrc) { File.join(home, '.dbrc') }
|
17
|
+
|
18
|
+
let(:db_foo){ 'foo' }
|
19
|
+
let(:user1) { 'user1' }
|
20
|
+
|
21
|
+
let(:yml){
|
22
|
+
%q{
|
23
|
+
- foo:
|
24
|
+
user: user1
|
25
|
+
password: pwd1
|
26
|
+
driver: Oracle
|
27
|
+
interval: 60
|
28
|
+
timeout: 40
|
29
|
+
maximum_reconnects: 3
|
30
|
+
- foo:
|
31
|
+
user: user2
|
32
|
+
password: pwd2
|
33
|
+
driver: OCI8
|
34
|
+
interval: 60
|
35
|
+
timeout: 60
|
36
|
+
maximum_reconnects: 4
|
37
|
+
- bar:
|
38
|
+
user: user1
|
39
|
+
password: pwd3
|
40
|
+
driver: Oracle
|
41
|
+
interval: 30
|
42
|
+
timeout: 30
|
43
|
+
maximum_reconnects: 2
|
44
|
+
- baz:
|
45
|
+
user: user3
|
46
|
+
password: pwd4
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
before do
|
51
|
+
allow(Dir).to receive(:home).and_return(home)
|
52
|
+
FileUtils.mkdir_p(home)
|
53
|
+
File.open(dbrc, 'w'){ |fh| fh.write(yml) }
|
54
|
+
File.chmod(0600, dbrc)
|
55
|
+
|
56
|
+
# FakeFS doesn't implement this yet
|
57
|
+
allow_any_instance_of(FakeFS::File::Stat).to receive(:owned?).and_return(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
context "instance methods" do
|
61
|
+
before do
|
62
|
+
@dbrc = described_class.new(db_foo, user1)
|
63
|
+
end
|
64
|
+
|
65
|
+
example "database method returns expected value" do
|
66
|
+
expect(@dbrc.database).to eq('foo')
|
67
|
+
end
|
68
|
+
|
69
|
+
example "password method returns expected value" do
|
70
|
+
expect(@dbrc.password).to eq('pwd1')
|
71
|
+
end
|
72
|
+
|
73
|
+
example "driver method returns expected value" do
|
74
|
+
expect(@dbrc.driver).to eq('Oracle')
|
75
|
+
end
|
76
|
+
|
77
|
+
example "interval method returns expected value" do
|
78
|
+
expect(@dbrc.interval).to eq(60)
|
79
|
+
end
|
80
|
+
|
81
|
+
example "timeout method returns expected value" do
|
82
|
+
expect(@dbrc.timeout).to eq(40)
|
83
|
+
end
|
84
|
+
|
85
|
+
example "maximum_reconnects method returns expected value" do
|
86
|
+
expect(@dbrc.maximum_reconnects).to eq(3)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|