Skip to content

Commit

Permalink
Refactor unit test layout
Browse files Browse the repository at this point in the history
Set up spec tree like chef, to add room for other tests and make room
for support files.

Also include platform helpers from Chef to use as exclusions.
  • Loading branch information
btm committed Dec 6, 2012
1 parent 6e39063 commit 0aa6418
Show file tree
Hide file tree
Showing 64 changed files with 44 additions and 1 deletion.
14 changes: 13 additions & 1 deletion spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rspec'
require 'mixlib/config'

require 'spec/support/platform_helpers'

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'ohai'
Expand Down Expand Up @@ -54,3 +55,14 @@ def from_file(filename)
self.instance_eval(IO.read(filename), filename, 1)
end
end

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true

config.filter_run_excluding :windows_only => true unless windows?
config.filter_run_excluding :unix_only => true unless unix?
config.filter_run_excluding :ruby_18_only => true unless ruby_18?
config.filter_run_excluding :ruby_19_only => true unless ruby_19?
config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root'
config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
end
31 changes: 31 additions & 0 deletions spec/support/platform_helpers.rb
@@ -0,0 +1,31 @@
def ruby_19?
!!(RUBY_VERSION =~ /^1.9/)
end

def ruby_18?
!!(RUBY_VERSION =~ /^1.8/)
end

def windows?
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
end

# def jruby?

def unix?
!windows?
end

def os_x?
!!(RUBY_PLATFORM =~ /darwin/)
end

def solaris?
!!(RUBY_PLATFORM =~ /solaris/)
end

def freebsd?
!!(RUBY_PLATFORM =~ /freebsd/)
end

DEV_NULL = windows? ? 'NUL' : '/dev/null'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0aa6418

Please sign in to comment.