rvm-completion 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,14 +4,25 @@ Provides you with bash completion for the Ruby Version Manager by Wayne Seguin,
4
4
  including completion of installed Rubies and available gemsets for currently active
5
5
  Ruby.
6
6
 
7
- == Install
7
+ The ruby and gemset name completion also accepts parts of the name via regular
8
+ expression matching, so typing 'rvm use 299' will match to 'rvm use ruby-1.8.7-p299'
9
+
10
+ == Install via gems
8
11
 
9
12
  $ gem install rvm-completion
10
13
  $ install-rvm-completion
11
14
 
12
15
  Then add the following line to your bash profile (~/.profile or ~/.bashrc):
16
+
13
17
  complete -C $rvm_scripts_path/rvm-completion.rb -o default rvm
18
+
19
+ == Manual install
20
+
21
+ You can also install manually by grabbing the rvm-completion.rb file inside the lib
22
+ directory, placing it somewhere on your local machine, making it executable with
23
+ chmod +x and adding the following to your bash profile:
14
24
 
25
+ complete -C THE/PATH/TO/rvm-completion.rb -o default rvm
15
26
 
16
27
  == Note on Patches/Pull Requests
17
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm-completion}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christoph Olszowka"]
@@ -29,11 +29,13 @@ Gem::Specification.new do |s|
29
29
  "lib/rvm-completion.rb",
30
30
  "rvm-completion.gemspec",
31
31
  "test/helper.rb",
32
+ "test/rvm_mock_environment.rb",
33
+ "test/test_installer.rb",
32
34
  "test/test_rvm-completion.rb"
33
35
  ]
34
36
  s.homepage = %q{http://github.com/colszowka/rvm-completion}
35
37
  s.post_install_message = %q{
36
- To install rvm completion v0.2.0, please run 'install-rvm-completion' in your terminal now!
38
+ To install rvm completion v0.2.1, please run 'install-rvm-completion' in your terminal now!
37
39
 
38
40
  }
39
41
  s.rdoc_options = ["--charset=UTF-8"]
@@ -42,6 +44,8 @@ To install rvm completion v0.2.0, please run 'install-rvm-completion' in your te
42
44
  s.summary = %q{bash completion for Ruby Version Manager}
43
45
  s.test_files = [
44
46
  "test/helper.rb",
47
+ "test/rvm_mock_environment.rb",
48
+ "test/test_installer.rb",
45
49
  "test/test_rvm-completion.rb"
46
50
  ]
47
51
 
@@ -6,41 +6,13 @@ require 'fileutils'
6
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
8
  require 'rvm-completion'
9
-
10
- # Define path to tmp directory
11
- tmp_root = File.expand_path(File.join(File.dirname(__FILE__), '../tmp'))
12
-
13
- # Set environment vars used in completion to test-specific ones
14
- ENV['rvm_rubies_path'] = File.join(tmp_root, 'rubies')
15
- ENV['rvm_gems_path'] = File.join(tmp_root, 'gems')
16
- ENV['rvm_gemset_separator'] = '@'
17
-
18
- # Clean up and prepare test folders
19
- FileUtils.rm_rf(tmp_root) if File.exist?(tmp_root)
20
-
21
- def mock_gemset(ruby_name, gemset_name=nil)
22
- if gemset_name.nil?
23
- FileUtils.mkdir_p(File.join(ENV['rvm_gems_path'], "#{ruby_name}"))
24
- else
25
- FileUtils.mkdir_p(File.join(ENV['rvm_gems_path'], "#{ruby_name}#{ENV['rvm_gemset_separator']}#{gemset_name}"))
26
- end
27
- end
28
-
29
- FileUtils.mkdir_p(File.join(ENV['rvm_rubies_path'], 'default'))
30
-
31
- ["macruby-0.6", "rbx-1.0.1-20100603", "ree-1.8.7-2010.02", "ruby-1.8.7-p174",
32
- "ruby-1.8.7-p299", "ruby-1.9.1-p378", "ruby-1.9.2-rc2"].each do |ruby_name|
33
- FileUtils.mkdir_p(File.join(ENV['rvm_rubies_path'], ruby_name))
34
- mock_gemset(ruby_name)
35
- mock_gemset(ruby_name, 'global')
36
- end
37
-
38
- class RVMCompletion
39
- # Required for mocking gemsets based upon selected ruby
40
- attr_writer :current_ruby_path
41
- end
9
+ require 'rvm_mock_environment'
42
10
 
43
11
  class Test::Unit::TestCase
12
+ # Fake the path to a ruby install used in rvm. This is required since
13
+ # normally, the completion resorts to the shell command 'which ruby' to
14
+ # determine this, which obviously is not reproducible in unit tests across
15
+ # environmente. Will create all mocked gemsets specified in options[:gemsets] array
44
16
  def self.using_ruby(ruby_name, options={})
45
17
  options = {:gemsets => []}.merge(options)
46
18
  options[:gemsets].each do |gemset|
@@ -54,6 +26,9 @@ class Test::Unit::TestCase
54
26
  end
55
27
  end
56
28
 
29
+ # Processes the completion for the given comp line(s) and yields the
30
+ # shoulda context. If used after using_ruby will use that ruby with a mocked
31
+ # bin path
57
32
  def self.completion_for(*comp_lines)
58
33
  comp_lines.each do |comp_line|
59
34
  context "Completion for '#{comp_line}'" do
@@ -77,6 +52,7 @@ class Test::Unit::TestCase
77
52
  end
78
53
  end
79
54
 
55
+ # Asserts the completion stored in subject includes the given values (and only those)
80
56
  def self.should_include(*values)
81
57
  should "return #{values.length} completions" do
82
58
  assert_equal values.length, subject.length
@@ -89,9 +65,45 @@ class Test::Unit::TestCase
89
65
  end
90
66
  end
91
67
 
68
+ # Asserts that no completions are returned in subject
92
69
  def self.should_include_nothing
93
70
  should "include nothing in completion" do
94
71
  assert_equal 0, subject.length
95
72
  end
96
73
  end
74
+
75
+ def self.with_rvm_scripts_path(path)
76
+ context "with rvm scripts path set to #{path}" do
77
+ setup { ENV['rvm_scripts_path'] = path }
78
+ yield
79
+ end
80
+ end
81
+
82
+ def self.running_install_script
83
+ context "running the install script" do
84
+ setup do
85
+ @output = `#{File.join(File.dirname(__FILE__), '../bin/install-rvm-completion')}`
86
+ end
87
+ subject { @output }
88
+ yield
89
+ end
90
+ end
91
+
92
+ def self.should_print(message)
93
+ should "print '#{message}'" do
94
+ assert_match(/#{message}/, subject)
95
+ end
96
+ end
97
+
98
+ def self.should_not_have_copied_the_script
99
+ should "not have copied the completion script" do
100
+ assert !File.exist?(File.join(ENV['rvm_scripts_path'], 'rvm-completion.rb'))
101
+ end
102
+ end
103
+
104
+ def self.should_have_copied_the_script
105
+ should "have copied the completion script" do
106
+ assert File.exist?(File.join(ENV['rvm_scripts_path'], 'rvm-completion.rb'))
107
+ end
108
+ end
97
109
  end
@@ -0,0 +1,34 @@
1
+ # Set up a faked rvm environment for tests
2
+
3
+ # Define path to tmp directory
4
+ tmp_root = File.expand_path(File.join(File.dirname(__FILE__), '../tmp'))
5
+
6
+ # Set environment vars used in completion to test-specific ones
7
+ ENV['rvm_rubies_path'] = File.join(tmp_root, 'rubies')
8
+ ENV['rvm_gems_path'] = File.join(tmp_root, 'gems')
9
+ ENV['rvm_gemset_separator'] = '@'
10
+
11
+ # Clean up and prepare test folders
12
+ FileUtils.rm_rf(tmp_root) if File.exist?(tmp_root)
13
+
14
+ def mock_gemset(ruby_name, gemset_name=nil)
15
+ if gemset_name.nil?
16
+ FileUtils.mkdir_p(File.join(ENV['rvm_gems_path'], "#{ruby_name}"))
17
+ else
18
+ FileUtils.mkdir_p(File.join(ENV['rvm_gems_path'], "#{ruby_name}#{ENV['rvm_gemset_separator']}#{gemset_name}"))
19
+ end
20
+ end
21
+
22
+ FileUtils.mkdir_p(File.join(ENV['rvm_rubies_path'], 'default'))
23
+
24
+ ["macruby-0.6", "rbx-1.0.1-20100603", "ree-1.8.7-2010.02", "ruby-1.8.7-p174",
25
+ "ruby-1.8.7-p299", "ruby-1.9.1-p378", "ruby-1.9.2-rc2"].each do |ruby_name|
26
+ FileUtils.mkdir_p(File.join(ENV['rvm_rubies_path'], ruby_name))
27
+ mock_gemset(ruby_name)
28
+ mock_gemset(ruby_name, 'global')
29
+ end
30
+
31
+ class RVMCompletion
32
+ # Required for mocking gemsets based upon selected ruby
33
+ attr_writer :current_ruby_path
34
+ end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestInstaller < Test::Unit::TestCase
4
+ with_rvm_scripts_path '' do
5
+ running_install_script do
6
+ should_print 'Failed to find rvm scripts path - is rvm installed correctly?'
7
+ should_not_have_copied_the_script
8
+ end
9
+ end
10
+
11
+ with_rvm_scripts_path File.expand_path(File.join(File.dirname(__FILE__), '../tmp')) do
12
+ running_install_script do
13
+ should_print "Success! rvm completion"
14
+ should_print "If you didn't do so before, please add the following line at the end of your"
15
+ should_have_copied_the_script
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvm-completion
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Olszowka
@@ -52,6 +52,8 @@ files:
52
52
  - lib/rvm-completion.rb
53
53
  - rvm-completion.gemspec
54
54
  - test/helper.rb
55
+ - test/rvm_mock_environment.rb
56
+ - test/test_installer.rb
55
57
  - test/test_rvm-completion.rb
56
58
  has_rdoc: true
57
59
  homepage: http://github.com/colszowka/rvm-completion
@@ -59,7 +61,7 @@ licenses: []
59
61
 
60
62
  post_install_message: |+
61
63
 
62
- To install rvm completion v0.2.0, please run 'install-rvm-completion' in your terminal now!
64
+ To install rvm completion v0.2.1, please run 'install-rvm-completion' in your terminal now!
63
65
 
64
66
  rdoc_options:
65
67
  - --charset=UTF-8
@@ -92,4 +94,6 @@ specification_version: 3
92
94
  summary: bash completion for Ruby Version Manager
93
95
  test_files:
94
96
  - test/helper.rb
97
+ - test/rvm_mock_environment.rb
98
+ - test/test_installer.rb
95
99
  - test/test_rvm-completion.rb