Skip to content

Commit

Permalink
added gemsync scenarios, caught a few gemsync bugs in the process
Browse files Browse the repository at this point in the history
  • Loading branch information
vertiginous committed Nov 6, 2009
1 parent 326675a commit bfed28f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
19 changes: 19 additions & 0 deletions features/gemsync_command.feature
@@ -0,0 +1,19 @@
Feature: gemsync command
In order to test code against specific ruby implementations
A developer
Wants an interface to the program
So that he can tag versions that pik is aware of

Scenario: sync to previous version
Given I only have the rake gem installed to version 1.9.1.
When I run "pik 191 mi" and "pik gemsync 186 mi -q -d",
Then I should see "** Syncing"
And I should find "Gem rake.+ already installed"
And I should see "Installing hoe"

Scenario: attempt to sync to different platform
When I run "pik Ir 91" and "pik gemsync 186 mi -q -d",
Then I should see "You appear to be attempting a gemsync from a different platform."


# Scenaorio: sync remotely
11 changes: 11 additions & 0 deletions features/step_definitions/pik_commands.rb
Expand Up @@ -7,6 +7,17 @@
@ver.size.should eql(1)
end

Given /^I only have the rake gem installed to version 1\.9\.1\.$/ do
x = `pik 191 & gem list`.split("\n").map{|gem_| gem_.split(' ') }
x.map! do |name, version|
unless name == 'rake'
`pik 191 & gem unin #{name} -x -I`
name
end
end
x.should_not include('rake')
end

Given /^I am currently using it\.$/ do
unless `ruby -v` =~ @version_reg
k,v = `pik switch #{@version} & path`.split('=')
Expand Down
8 changes: 5 additions & 3 deletions lib/pik/commands/gemsync_command.rb
Expand Up @@ -47,7 +47,8 @@ def install_gems(current, source)
puts "** Gem #{file.basename('.gem')} already installed"
else
puts "** Installing #{file.basename('.gem')}"
cmd = "#{Which::Gem.exe} install -q --no-rdoc --no-ri #{gem_file(file)}"
gem_opts = "install -q --no-rdoc --no-ri"
cmd = "#{Which::Gem.exe.basename} #{gem_opts} #{gem_file(file)}"
puts cmd if debug
system(cmd)
end
Expand All @@ -59,9 +60,10 @@ def gem_file(file)
if remote
gem_re = /(.+)\-(\d+\.\d+\.\d+).+/
file, gem_name, version = file.basename.to_s.match(gem_re).to_a
"#{gem_name} --version \"=#{version}\""
"#{gem_name} --version \"=#{version}\" --remote"
else
file
# deal with spaces in path
file.sub(/.*\s.*/m, '"\&"')
end
end

Expand Down

0 comments on commit bfed28f

Please sign in to comment.