Permalink
Browse files

Remove interactive setup.

  • Loading branch information...
1 parent 928c26b commit ced028ddf172ae940fb8e3e9fa65d0f2bdfcf81a @stephencelis committed Jan 9, 2012
Showing with 12 additions and 43 deletions.
  1. +12 −14 lib/ghi.rb
  2. +0 −29 spec/ghi_spec.rb
View
@@ -10,13 +10,10 @@ def login
return @login if defined? @login
@login = `git config --get github.user`.chomp
if @login.empty?
- begin
- print "Please enter your GitHub username: "
- @login = gets.chomp
- valid = user? @login
- warn "invalid username" unless valid
- end until valid
- `git config --global github.user #@login`
+ warn "Please configure your GitHub username."
+ puts
+ puts "E.g., git config --global github.user [your username]"
+ abort
end
@login
end
@@ -25,13 +22,14 @@ def token
return @token if defined? @token
@token = `git config --get github.token`.chomp
if @token.empty?
- begin
- print "GitHub token (https://github.com/account): "
- @token = gets.chomp
- valid = token? @token
- warn "invalid token for #{login}" unless valid
- end until valid
- `git config --global github.token #@token`
+ warn "Please configure your GitHub token."
+ puts
+ puts "E.g., git config --global github.user [your token]"
+ puts
+ puts "Find your token here: https://github.com/account/admin"
+ abort
+ elsif @token.sub!(/^!/, '')
+ @token = `#@token`
end
@token
end
View
@@ -59,33 +59,4 @@
GHI.should_receive(:`).once.and_return "da39a3ee5e6b4b0d3255bfef95601890\n"
GHI.token.should == "da39a3ee5e6b4b0d3255bfef95601890"
end
-
- it "should approve login input" do
- GHI.instance_eval { instance_variable_defined?(:@login).should == false }
- GHI.should_receive(:`).with("git config --get github.user").
- and_return "\n"
- GHI.should_receive(:print).twice
- GHI.should_receive(:gets).twice.and_return "defunct\n", "defunkt\n"
- Net::HTTP.should_receive(:get).and_return "500: invalid: response",
- LOGGED_OUT_YAML
- GHI.should_receive(:warn).once
- GHI.should_receive(:`).with("git config --global github.user defunkt").
- and_return "\n"
- GHI.login.should == "defunkt"
- end
-
- it "should approve token input" do
- GHI.instance_eval { instance_variable_defined?(:@token).should == false }
- GHI.stub!(:login).and_return "defunkt"
- GHI.should_receive(:`).with("git config --get github.token").
- and_return "\n"
- GHI.should_receive(:print).twice
- token = "da39a3ee5e6b4b0d3255bfef95601890"
- GHI.should_receive(:gets).and_return "invalid\n", "#{token}\n"
- Net::HTTP.should_receive(:get).and_return LOGGED_OUT_YAML, LOGGED_IN_YAML
- GHI.should_receive(:warn).once
- GHI.should_receive(:`).with("git config --global github.token #{token}").
- and_return "\n"
- GHI.token.should == token
- end
end

0 comments on commit ced028d

Please sign in to comment.