forked from svenfuchs/gem-release
/
bootstrap_command_test.rb
52 lines (42 loc) · 1.49 KB
/
bootstrap_command_test.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
require File.expand_path('../test_helper', __FILE__)
require 'rubygems/commands/bootstrap_command'
require 'gem_release/gemspec'
require 'fileutils'
class BootstrapCommandTest < MiniTest::Unit::TestCase
def setup
build_sandbox
stub_command(GemspecCommand, :execute)
stub_command(BootstrapCommand, :say)
end
def teardown
teardown_sandbox
end
test "write_scaffold" do
BootstrapCommand.new.send(:write_scaffold)
assert File.file?('lib/foo_bar/version.rb')
assert File.file?('README')
assert File.directory?('test')
eval(File.read('lib/foo_bar/version.rb'))
assert_equal '0.0.1', FooBar::VERSION
end
test "write_gemspec" do
GemspecCommand.new.expects(:execute)
BootstrapCommand.new.send(:write_gemspec)
end
test "create_repo" do
command = BootstrapCommand.new
command.stubs(:say)
command.stubs(:github_user).returns('svenfuchs')
command.stubs(:github_token).returns('token')
command.expects(:`).with("git init")
command.expects(:`).with("git add .")
command.expects(:`).with("git commit -m 'initial commit'")
command.expects(:`).with("git remote add origin git@github.com:svenfuchs/foo-bar.git")
command.expects(:`).with("git push origin master")
command.expects(:`).with do |cmd|
tokens = %w(curl login=svenfuchs name=foo-bar token=token http://github.com/api/v2/yaml/repos/create)
tokens.inject(true) { |result, token| result && cmd =~ /#{token}/ }
end
command.send(:create_repo)
end
end