Sha256: e889aebe2122f15b96ed185518cb017e6e947bfa28ceee8cceb8632683fb0cd0

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require 'helper'

class TestClient < Test::Unit::TestCase

  def test_load_with_username
    mock(Stars::Client).system.with('clear').returns('')
    mock(Stars::Formatter).new.times(any_times).with_any_args
    mock(Stars::Client).puts.times(any_times).with_any_args
    mock(Stars::Client).print.times(any_times).with_any_args
    mock(Stars::Client).input.times(any_times).with_any_args.returns('q')
    Stars::Client.load!('holman')
  end
  
  def test_load_without_username
    mock(Stars::Client).system.with('clear').returns('')
    mock(Stars::Formatter).new.times(any_times).with_any_args
    mock(Stars::Client).puts.times(any_times).with_any_args
    mock(Stars::Client).print.times(any_times).with_any_args
    mock(Stars::Client).input.times(any_times).with_any_args.returns('q')
    Stars::Client.load!(nil)
  end
  
  def test_username_when_exists
    mock(File).exists?.with_any_args.returns(true)
    mock(File).read.with_any_args
    Stars::Client.username
  end
  
  def test_username_when_nonexistant
    mock(File).exists?.with_any_args.returns(false)
    mock(Stars::Client).prompt_for_username
    Stars::Client.username
  end
  
  def test_write_home_config
    assert_equal Stars::Client.remember_username('holman'), 'holman'
  end
  
  def test_config_path
    assert Stars::Client.config_path.index('.stars')
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stars-0.4.0 test/test_client.rb
stars-0.3.2 test/test_client.rb
stars-0.3.1 test/test_client.rb
stars-0.3.0 test/test_client.rb