Skip to content

Instantly share code, notes, and snippets.

@andreastt
Created March 10, 2011 15:12
Show Gist options
  • Save andreastt/864225 to your computer and use it in GitHub Desktop.
Save andreastt/864225 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rbconfig'
require 'rspec'
class PlatformDependentExample
def platform
case RbConfig::CONFIG['host_os']
when /windows/
:windows
when /linux/
:linux
when /darwin/
:macosx
when /solaris|bsd/
:unix
end
end
def test
platform
end
end
RSpec.configuration.filter_run :os => :linux
describe PlatformDependentExample do
describe '#test' do
before :all do
@e = PlatformDependentExample.new
end
it 'returns :windows if on Windows', :os => :windows do
@e.test.should == :windows
end
it 'returns :linux if on Linux', :os => :linux do
@e.test.should == :linux
end
it 'returns :macosx if on Mac OS X', :os => :macosx do
@e.test.should == :macosx
end
it 'returns :unix if on Unix', :os => :unix do
@e.test.should == :unix
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment