ruby-virtualenv 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +32 -63
- data/Rakefile +8 -0
- data/lib/sandbox/cli.rb +9 -13
- data/lib/sandbox/errors.rb +2 -2
- data/lib/sandbox/installer.rb +46 -72
- data/lib/sandbox/templates/activate.erb +2 -16
- data/lib/sandbox/version.rb +1 -1
- data/ruby-virtualenv.gemspec +1 -1
- data/spec/sandbox/cli_spec.rb +114 -116
- data/spec/sandbox/errors_spec.rb +5 -9
- data/spec/sandbox/installer_spec.rb +131 -133
- data/spec/sandbox/output_spec.rb +39 -39
- data/spec/sandbox_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +6 -12
- data/features/development.feature +0 -13
- data/features/steps/common.rb +0 -174
- data/features/steps/env.rb +0 -10
data/spec/sandbox/output_spec.rb
CHANGED
@@ -5,139 +5,139 @@ describe 'including', Sandbox::Output do
|
|
5
5
|
include Sandbox::Output
|
6
6
|
end
|
7
7
|
|
8
|
-
before(
|
8
|
+
before(:each) do
|
9
9
|
Sandbox.instance_eval { instance_variables.each { |v| remove_instance_variable v } }
|
10
10
|
@tester = Tester.new
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should have tell method" do
|
14
|
-
@tester.should respond_to(
|
14
|
+
@tester.should respond_to(:tell)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should have tell_when_verbose method" do
|
18
|
-
@tester.should respond_to(
|
18
|
+
@tester.should respond_to(:tell_when_verbose)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should have tell_when_really_verbose method" do
|
22
|
-
@tester.should respond_to(
|
22
|
+
@tester.should respond_to(:tell_when_really_verbose)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should have tell_unless_quiet method" do
|
26
|
-
@tester.should respond_to(
|
26
|
+
@tester.should respond_to(:tell_unless_quiet)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should have tell_unless_really_quiet method" do
|
30
|
-
@tester.should respond_to(
|
30
|
+
@tester.should respond_to(:tell_unless_really_quiet)
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "calling tell" do
|
34
34
|
it "should require message" do
|
35
|
-
lambda { @tester.tell }.should raise_error(
|
35
|
+
lambda { @tester.tell }.should raise_error(ArgumentError)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should call puts when normal" do
|
39
|
-
@tester.expects(
|
40
|
-
@tester.tell(
|
39
|
+
@tester.expects(:puts)
|
40
|
+
@tester.tell("message")
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should not call puts when below normal verbosity" do
|
44
44
|
Sandbox.decrease_verbosity
|
45
|
-
@tester.expects(
|
46
|
-
@tester.tell(
|
45
|
+
@tester.expects(:puts).never
|
46
|
+
@tester.tell("message")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should call puts when above normal verbosity" do
|
50
50
|
Sandbox.increase_verbosity
|
51
|
-
@tester.expects(
|
52
|
-
@tester.tell(
|
51
|
+
@tester.expects(:puts)
|
52
|
+
@tester.tell("message")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "calling tell_when_verbose" do
|
57
57
|
it "should require message" do
|
58
|
-
lambda { @tester.tell_when_verbose }.should raise_error(
|
58
|
+
lambda { @tester.tell_when_verbose }.should raise_error(ArgumentError)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should not call puts when normal verbosity" do
|
62
|
-
@tester.expects(
|
63
|
-
@tester.tell_when_verbose(
|
62
|
+
@tester.expects(:puts).never
|
63
|
+
@tester.tell_when_verbose("message")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should call puts when above normal verbosity" do
|
67
67
|
Sandbox.increase_verbosity
|
68
|
-
@tester.expects(
|
69
|
-
@tester.tell_when_verbose(
|
68
|
+
@tester.expects(:puts)
|
69
|
+
@tester.tell_when_verbose("message")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
describe "calling tell_when_really_verbose" do
|
74
74
|
it "should require message" do
|
75
|
-
lambda { @tester.tell_when_really_verbose }.should raise_error(
|
75
|
+
lambda { @tester.tell_when_really_verbose }.should raise_error(ArgumentError)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should not call puts when normal verbosity" do
|
79
|
-
@tester.expects(
|
80
|
-
@tester.tell_when_really_verbose(
|
79
|
+
@tester.expects(:puts).never
|
80
|
+
@tester.tell_when_really_verbose("message")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should call puts when above normal verbosity" do
|
84
84
|
Sandbox.increase_verbosity
|
85
|
-
@tester.expects(
|
86
|
-
@tester.tell_when_really_verbose(
|
85
|
+
@tester.expects(:puts).never
|
86
|
+
@tester.tell_when_really_verbose("message")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should call puts when really above normal verbosity" do
|
90
90
|
Sandbox.increase_verbosity
|
91
91
|
Sandbox.increase_verbosity
|
92
|
-
@tester.expects(
|
93
|
-
@tester.tell_when_really_verbose(
|
92
|
+
@tester.expects(:puts)
|
93
|
+
@tester.tell_when_really_verbose("message")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
describe "calling tell_unless_quiet" do
|
98
98
|
it "should require message" do
|
99
|
-
lambda { @tester.tell_unless_quiet }.should raise_error(
|
99
|
+
lambda { @tester.tell_unless_quiet }.should raise_error(ArgumentError)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should call puts when normal" do
|
103
|
-
@tester.expects(
|
104
|
-
@tester.tell_unless_quiet(
|
103
|
+
@tester.expects(:puts)
|
104
|
+
@tester.tell_unless_quiet("message")
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should not call puts when below normal verbosity" do
|
108
108
|
Sandbox.decrease_verbosity
|
109
|
-
@tester.expects(
|
110
|
-
@tester.tell_unless_quiet(
|
109
|
+
@tester.expects(:puts).never
|
110
|
+
@tester.tell_unless_quiet("message")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should call puts when above normal verbosity" do
|
114
114
|
Sandbox.increase_verbosity
|
115
|
-
@tester.expects(
|
116
|
-
@tester.tell_unless_quiet(
|
115
|
+
@tester.expects(:puts)
|
116
|
+
@tester.tell_unless_quiet("message")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "calling tell_unless_really_quiet" do
|
121
121
|
it "should require message" do
|
122
|
-
lambda { @tester.tell_unless_really_quiet }.should raise_error(
|
122
|
+
lambda { @tester.tell_unless_really_quiet }.should raise_error(ArgumentError)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should call puts when normal" do
|
126
|
-
@tester.expects(
|
127
|
-
@tester.tell_unless_really_quiet(
|
126
|
+
@tester.expects(:puts)
|
127
|
+
@tester.tell_unless_really_quiet("message")
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should call puts when below normal verbosity" do
|
131
131
|
Sandbox.decrease_verbosity
|
132
|
-
@tester.expects(
|
133
|
-
@tester.tell_unless_really_quiet(
|
132
|
+
@tester.expects(:puts)
|
133
|
+
@tester.tell_unless_really_quiet("message")
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should not call puts when really below normal verbosity" do
|
137
137
|
Sandbox.decrease_verbosity
|
138
138
|
Sandbox.decrease_verbosity
|
139
|
-
@tester.expects(
|
140
|
-
@tester.tell_unless_really_quiet(
|
139
|
+
@tester.expects(:puts).never
|
140
|
+
@tester.tell_unless_really_quiet("message")
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
data/spec/sandbox_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-virtualenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2011-10-02 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &70190793241640 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.6.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70190793241640
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: mocha
|
28
|
-
requirement: &
|
28
|
+
requirement: &70190793240980 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.10.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70190793240980
|
37
37
|
description: Create virtual ruby/rubygems environments.
|
38
38
|
email:
|
39
39
|
- nkryptic@gmail.com
|
@@ -52,9 +52,6 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- TODO
|
54
54
|
- bin/ruby-virtualenv
|
55
|
-
- features/development.feature
|
56
|
-
- features/steps/common.rb
|
57
|
-
- features/steps/env.rb
|
58
55
|
- lib/sandbox.rb
|
59
56
|
- lib/sandbox/cli.rb
|
60
57
|
- lib/sandbox/errors.rb
|
@@ -70,7 +67,7 @@ files:
|
|
70
67
|
- spec/sandbox/output_spec.rb
|
71
68
|
- spec/sandbox_spec.rb
|
72
69
|
- spec/spec_helper.rb
|
73
|
-
homepage:
|
70
|
+
homepage: https://github.com/fesplugas/ruby-virtualenv
|
74
71
|
licenses: []
|
75
72
|
post_install_message:
|
76
73
|
rdoc_options: []
|
@@ -95,9 +92,6 @@ signing_key:
|
|
95
92
|
specification_version: 3
|
96
93
|
summary: Create virtual ruby/rubygems environments.
|
97
94
|
test_files:
|
98
|
-
- features/development.feature
|
99
|
-
- features/steps/common.rb
|
100
|
-
- features/steps/env.rb
|
101
95
|
- spec/sandbox/cli_spec.rb
|
102
96
|
- spec/sandbox/errors_spec.rb
|
103
97
|
- spec/sandbox/installer_spec.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Feature: Development processes of newgem itself (rake tasks)
|
2
|
-
|
3
|
-
As a Newgem maintainer or contributor
|
4
|
-
I want rake tasks to maintain and release the gem
|
5
|
-
So that I can spend time on the tests and code, and not excessive time on maintenance processes
|
6
|
-
|
7
|
-
Scenario: Generate RubyGem
|
8
|
-
Given this project is active project folder
|
9
|
-
And 'pkg' folder is deleted
|
10
|
-
When task 'rake gem' is invoked
|
11
|
-
Then folder 'pkg' is created
|
12
|
-
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
|
13
|
-
And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
|
data/features/steps/common.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
def in_project_folder(&block)
|
2
|
-
project_folder = @active_project_folder || @tmp_root
|
3
|
-
FileUtils.chdir(project_folder, &block)
|
4
|
-
end
|
5
|
-
|
6
|
-
def in_home_folder(&block)
|
7
|
-
FileUtils.chdir(@home_path, &block)
|
8
|
-
end
|
9
|
-
|
10
|
-
Given %r{^a safe folder} do
|
11
|
-
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
12
|
-
FileUtils.mkdir_p @tmp_root
|
13
|
-
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
14
|
-
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
15
|
-
Given "env variable $HOME set to '#{@home_path}'"
|
16
|
-
end
|
17
|
-
|
18
|
-
Given %r{^this project is active project folder} do
|
19
|
-
Given "a safe folder"
|
20
|
-
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
21
|
-
end
|
22
|
-
|
23
|
-
Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
|
24
|
-
ENV[env_var] = value
|
25
|
-
end
|
26
|
-
|
27
|
-
def force_local_lib_override(project_name = @project_name)
|
28
|
-
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
29
|
-
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
30
|
-
f << "$:.unshift('#{@lib_path}')\n"
|
31
|
-
f << rakefile
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def setup_active_project_folder project_name
|
36
|
-
@active_project_folder = File.join(@tmp_root, project_name)
|
37
|
-
@project_name = project_name
|
38
|
-
end
|
39
|
-
|
40
|
-
Given %r{'(.*)' folder is deleted} do |folder|
|
41
|
-
in_project_folder do
|
42
|
-
FileUtils.rm_rf folder
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
|
47
|
-
FileUtils.chdir(@active_project_folder) do
|
48
|
-
if Object.const_defined?("APP_ROOT")
|
49
|
-
APP_ROOT.replace(FileUtils.pwd)
|
50
|
-
else
|
51
|
-
APP_ROOT = FileUtils.pwd
|
52
|
-
end
|
53
|
-
run_generator(generator, arguments.split(' '), SOURCES)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
58
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
59
|
-
FileUtils.chdir(@active_project_folder) do
|
60
|
-
system "ruby #{executable} #{arguments} > #{@stdout}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
When %r{^task 'rake (.*)' is invoked$} do |task|
|
65
|
-
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
66
|
-
FileUtils.chdir(@active_project_folder) do
|
67
|
-
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
Then %r{^folder '(.*)' is created} do |folder|
|
72
|
-
in_project_folder do
|
73
|
-
File.exists?(folder).should be_true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
Then %r{^file '(.*)' (is|is not) created} do |file, is|
|
78
|
-
in_project_folder do
|
79
|
-
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
Then %r{^file with name matching '(.*)' is created} do |pattern|
|
84
|
-
in_project_folder do
|
85
|
-
Dir[pattern].should_not be_empty
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
|
90
|
-
File.exists?(gem_file).should be_true
|
91
|
-
File.exists?(project_file).should be_true
|
92
|
-
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
93
|
-
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
94
|
-
project_file_contents.should == gem_file_contents
|
95
|
-
end
|
96
|
-
|
97
|
-
Then %r{^output same as contents of '(.*)'$} do |file|
|
98
|
-
expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
|
99
|
-
actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
|
100
|
-
actual_output.should == expected_output
|
101
|
-
end
|
102
|
-
|
103
|
-
Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
|
104
|
-
actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
|
105
|
-
does_invoke == "does" ?
|
106
|
-
actual_output.should(match(/dependency\s+#{generator}/)) :
|
107
|
-
actual_output.should_not(match(/dependency\s+#{generator}/))
|
108
|
-
end
|
109
|
-
|
110
|
-
Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
|
111
|
-
actual_output = File.read(@stdout)
|
112
|
-
actual_output.should match(/#{opt1}/)
|
113
|
-
actual_output.should match(/#{opt2}/)
|
114
|
-
end
|
115
|
-
|
116
|
-
Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
|
117
|
-
actual_output = File.read(@stdout)
|
118
|
-
(does == 'does') ?
|
119
|
-
actual_output.should(match(/#{regex}/)) :
|
120
|
-
actual_output.should_not(match(/#{regex}/))
|
121
|
-
end
|
122
|
-
|
123
|
-
Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
124
|
-
in_project_folder do
|
125
|
-
actual_output = File.read(file)
|
126
|
-
(does == 'does') ?
|
127
|
-
actual_output.should(match(/#{regex}/)) :
|
128
|
-
actual_output.should_not(match(/#{regex}/))
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
Then %r{^all (\d+) tests pass} do |expected_test_count|
|
133
|
-
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
134
|
-
actual_output = File.read(@stdout)
|
135
|
-
actual_output.should match(expected)
|
136
|
-
end
|
137
|
-
|
138
|
-
Then %r{^all (\d+) examples pass} do |expected_test_count|
|
139
|
-
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
140
|
-
actual_output = File.read(@stdout)
|
141
|
-
actual_output.should match(expected)
|
142
|
-
end
|
143
|
-
|
144
|
-
Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
|
145
|
-
in_project_folder do
|
146
|
-
yaml = eval yaml
|
147
|
-
YAML.load(File.read(file)).should == yaml
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
Then %r{^Rakefile can display tasks successfully} do
|
152
|
-
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
153
|
-
FileUtils.chdir(@active_project_folder) do
|
154
|
-
system "rake -T > #{@stdout} 2> #{@stdout}"
|
155
|
-
end
|
156
|
-
actual_output = File.read(@stdout)
|
157
|
-
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
158
|
-
end
|
159
|
-
|
160
|
-
Then %r{^task 'rake (.*)' is executed successfully} do |task|
|
161
|
-
@stdout.should_not be_nil
|
162
|
-
actual_output = File.read(@stdout)
|
163
|
-
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
164
|
-
actual_output.should_not match(/Error/i)
|
165
|
-
end
|
166
|
-
|
167
|
-
Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
|
168
|
-
in_project_folder do
|
169
|
-
gem_file = Dir["pkg/*.gem"].first
|
170
|
-
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
171
|
-
spec_value = gem_spec.send(key.to_sym)
|
172
|
-
spec_value.to_s.should match(/#{regex}/)
|
173
|
-
end
|
174
|
-
end
|