Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions spec/mongo/server/app_metadata_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,40 @@
document[:client][:driver][:version].should == Mongo::VERSION
end

it 'includes operating system information' do
document[:client][:os][:type].should == 'linux'
if BSON::Environment.jruby? || RUBY_VERSION >= '3.0'
document[:client][:os][:name].should == 'linux'
else
document[:client][:os][:name].should == 'linux-gnu'
context 'linux' do
before(:all) do
unless SpecConfig.instance.linux?
skip "Linux required, we have #{RbConfig::CONFIG['host_os']}"
end
end

it 'includes operating system information' do
document[:client][:os][:type].should == 'linux'
if BSON::Environment.jruby? || RUBY_VERSION >= '3.0'
document[:client][:os][:name].should == 'linux'
else
document[:client][:os][:name].should == 'linux-gnu'
end
document[:client][:os][:architecture].should == 'x86_64'
end
end

context 'macos' do
before(:all) do
unless SpecConfig.instance.macos?
skip "MacOS required, we have #{RbConfig::CONFIG['host_os']}"
end
end

it 'includes operating system information' do
document[:client][:os][:type].should == 'darwin'
if BSON::Environment.jruby?
document[:client][:os][:name].should == 'darwin'
else
document[:client][:os][:name].should =~ /darwin\d+/
end
document[:client][:os][:architecture].should == 'x86_64'
end
document[:client][:os][:architecture].should == 'x86_64'
end

context 'mri' do
Expand Down
8 changes: 8 additions & 0 deletions spec/support/spec_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def jruby?
!!(RUBY_PLATFORM =~ /\bjava\b/)
end

def linux?
!!(RbConfig::CONFIG['host_os'].downcase =~ /\blinux/)
end

def macos?
!!(RbConfig::CONFIG['host_os'].downcase =~ /\bdarwin/)
end

def platform
RUBY_PLATFORM
end
Expand Down