Skip to content

Instantly share code, notes, and snippets.

@laribee
Created January 24, 2012 23:23
Show Gist options
  • Select an option

  • Save laribee/1673446 to your computer and use it in GitHub Desktop.

Select an option

Save laribee/1673446 to your computer and use it in GitHub Desktop.
using a wrapper to stub
class Wrapper
def self.some_windows_dependent_stuff
require "win32/registry"
# use windows stuff
end
end
class Subject
def where_i_need_it
Wrapper.some_windows_dependent_stuff
end
end
describe Subject do
it "puts the lotion on its skin" do
Wrapper.stub(:some_windows_dependent_stuff) { :foo }
Subject.new.where_i_need_it.should eql(:foo)
end
end
@stevenharman

Copy link
Copy Markdown

I ended up just hacking around it for now. It's ugly, but...

begin require 'win32ole'
rescue LoadError # FUCKING HACKY! Must be on UNIX, just fake it.
  module ::WIN32OLE; end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment