/
windoze_spec.rb
38 lines (32 loc) · 1.17 KB
/
windoze_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# this is an extremely hacky spec
# intended purely to test the Windoze-specific code
require 'rubygems'
require 'spec'
describe "github/command.rb" do
before(:all) do
@orig_platform = RUBY_PLATFORM
Object.send :remove_const, :RUBY_PLATFORM
Object.const_set :RUBY_PLATFORM, "mswin"
end
after(:all) do
Object.send :remove_const, :RUBY_PLATFORM
Object.const_set :RUBY_PLATFORM, @orig_platform
end
before(:each) do
@filename = File.dirname(__FILE__) + "/../lib/github/command.rb"
@data = File.read(@filename)
end
it "should require win32/open3 under Windows" do
mod = Module.new
mod.should_receive(:require).with("fileutils")
mod.should_receive(:require).with("win32/open3")
mod.class_eval @data, @filename
end
it "should blow up if win32/open3 isn't present under Windows" do
mod = Module.new
mod.should_receive(:require).with("fileutils")
mod.should_receive(:require).with("win32/open3").and_return { raise LoadError }
mod.should_receive(:warn).with("You must 'gem install win32-open3' to use the github command on Windows")
lambda { mod.class_eval @data, @filename }.should raise_error(SystemExit)
end
end