forked from vertiginous/pik
-
Notifications
You must be signed in to change notification settings - Fork 1
/
switch_command_spec.rb
56 lines (47 loc) · 1.69 KB
/
switch_command_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'pathname'
describe Pik::Switch do
it "should have a summary" do
Pik::Switch.summary.should eql("Switches ruby versions based on patterns.")
end
it "should have an alias of sw" do
Pik::Switch.names.should include(:sw)
end
it "should have an alias of use" do
Pik::Switch.names.should include(:use)
end
it "should have a global option" #do
# sw = Pik::Switch.new(['-g'])
# sw.global.should be_true
# end
it "should have a gem_home option" # do
# sw = Pik::Switch.new(['-m', 'test'])
# sw.gem_home.should eql("test")
# end
it "should use a batch file to switch paths" do
conf = {
'spec ' => {:path => Pathname('C:/ruby/bin')},
'real ' => {:path => Pathname.new(::RbConfig::CONFIG['bindir'] )}
}
cmd = Pik::Switch.new(['spec'], conf)
cmd.execute
batch = cmd.instance_variable_get('@batch').file_data
batch.should include("SET GEM_PATH=")
batch.should include("SET GEM_HOME=")
set_path = batch.grep(/set/i).first
set_path.should match(/SET PATH=.+C\:\\ruby\\bin.+/i)
end
it "should switch gem_home and gem_path if the config has a :gem_home" do
conf = {
'spec ' => {
:path => Pathname('C:/ruby/bin'),
:gem_home => Pathname('C:/Users/martin_blanke/.gems')
},
'real ' => {:path => Pathname.new(::RbConfig::CONFIG['bindir'] )}
}
cmd = Pik::Switch.new(['spec'], conf)
cmd.execute
batch = cmd.instance_variable_get('@batch').file_data
batch.should include("SET GEM_PATH=C:\\Users\\martin_blanke\\.gems")
batch.should include("SET GEM_HOME=C:\\Users\\martin_blanke\\.gems")
end
end