Skip to content

Commit

Permalink
Test gem installation
Browse files Browse the repository at this point in the history
Added a test to check that the built gem can install cleanly.
  • Loading branch information
enkessler committed Jan 30, 2019
1 parent 9ca62d3 commit d4615ff
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions spec/childprocess_spec.rb
Expand Up @@ -8,15 +8,37 @@

here = File.dirname(__FILE__)

let(:gemspec) { eval(File.read "#{here}/../childprocess.gemspec") }
describe 'the gem' do

it 'validates cleanly' do
mock_ui = Gem::MockGemUi.new
Gem::DefaultUserInteraction.use_ui(mock_ui) { gemspec.validate }
let(:gemspec) { eval(File.read "#{here}/../childprocess.gemspec") }

expect(mock_ui.error).to_not match(/warn/i)
end
it 'validates cleanly' do
mock_ui = Gem::MockGemUi.new
Gem::DefaultUserInteraction.use_ui(mock_ui) { gemspec.validate }

expect(mock_ui.error).to_not match(/warn/i)
end

it 'successfully installs' do
test_version = '0.0.0.test'
test_version_file = "module ChildProcess
VERSION = '#{test_version}'
end"

begin
File.write("#{here}/../lib/childprocess/version.rb", test_version_file)

system 'gem build childprocess.gemspec'
success = system "gem install childprocess-#{test_version}.gem"

expect(success).to be true
ensure
`git checkout lib/childprocess/version.rb`
system "gem uninstall childprocess -v #{test_version}"
end
end

end

it "returns self when started" do
process = sleeping_ruby
Expand Down

0 comments on commit d4615ff

Please sign in to comment.