Skip to content

Commit 23c8208

Browse files
RUBY-2296: Fix app metadata spec (#2208) (#2209)
RUBY-2296: Fix app metadata spec This commit fixes an assumption that the spec is always executed on a Linux machine.
1 parent ca36414 commit 23c8208

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

spec/mongo/server/app_metadata_shared.rb

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,40 @@
88
document[:client][:driver][:version].should == Mongo::VERSION
99
end
1010

11-
it 'includes operating system information' do
12-
document[:client][:os][:type].should == 'linux'
13-
if BSON::Environment.jruby? || RUBY_VERSION >= '3.0'
14-
document[:client][:os][:name].should == 'linux'
15-
else
16-
document[:client][:os][:name].should == 'linux-gnu'
11+
context 'linux' do
12+
before(:all) do
13+
unless SpecConfig.instance.linux?
14+
skip "Linux required, we have #{RbConfig::CONFIG['host_os']}"
15+
end
16+
end
17+
18+
it 'includes operating system information' do
19+
document[:client][:os][:type].should == 'linux'
20+
if BSON::Environment.jruby? || RUBY_VERSION >= '3.0'
21+
document[:client][:os][:name].should == 'linux'
22+
else
23+
document[:client][:os][:name].should == 'linux-gnu'
24+
end
25+
document[:client][:os][:architecture].should == 'x86_64'
26+
end
27+
end
28+
29+
context 'macos' do
30+
before(:all) do
31+
unless SpecConfig.instance.macos?
32+
skip "MacOS required, we have #{RbConfig::CONFIG['host_os']}"
33+
end
34+
end
35+
36+
it 'includes operating system information' do
37+
document[:client][:os][:type].should == 'darwin'
38+
if BSON::Environment.jruby?
39+
document[:client][:os][:name].should == 'darwin'
40+
else
41+
document[:client][:os][:name].should =~ /darwin\d+/
42+
end
43+
document[:client][:os][:architecture].should == 'x86_64'
1744
end
18-
document[:client][:os][:architecture].should == 'x86_64'
1945
end
2046

2147
context 'mri' do

spec/support/spec_config.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ def jruby?
110110
!!(RUBY_PLATFORM =~ /\bjava\b/)
111111
end
112112

113+
def linux?
114+
!!(RbConfig::CONFIG['host_os'].downcase =~ /\blinux/)
115+
end
116+
117+
def macos?
118+
!!(RbConfig::CONFIG['host_os'].downcase =~ /\bdarwin/)
119+
end
120+
113121
def platform
114122
RUBY_PLATFORM
115123
end

0 commit comments

Comments
 (0)