twtr 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ require 'test/unit'
2
+ require 'kconv'
3
+ require File.dirname(__FILE__) + '/../lib/twtr'
data/test/test_twtr.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTwtr < Test::Unit::TestCase
4
+ def test_util
5
+ assert_equal(false, Twtr.is_win?)
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTwtrClient < Test::Unit::TestCase
4
+ def test_initialize
5
+ client = Twtr::Client.new({"account" => {"user" => "bob", "password" => "secret"},
6
+ "proxy" => {"host" => "proxy.host", "port" => 8080} })
7
+
8
+ assert_equal("bob", client.account_user)
9
+ assert_equal("secret", client.account_password)
10
+ assert_equal("proxy.host", client.proxy_host)
11
+ assert_equal(8080, client.proxy_port)
12
+
13
+ end
14
+
15
+ def test_http_get
16
+ client = Twtr::Client.new()
17
+ assert_equal("<ok>true</ok>", client.test)
18
+ end
19
+
20
+ def test_http_post
21
+ client = Twtr::Client.new()
22
+ assert_equal("<ok>true</ok>", client.test({:method => :post}))
23
+ end
24
+
25
+
26
+ def test_attr
27
+ client = Twtr::Client.new()
28
+ assert_nil(client.account_user)
29
+ assert_nil(client.account_password)
30
+ assert_nil(client.proxy_host)
31
+ assert_nil(client.proxy_port)
32
+ end
33
+
34
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ TEST_CONFIG_FILE = File.dirname(__FILE__) + '/config.yml'
4
+ TEST_NOTHING_FILE = File.dirname(__FILE__) + '/nothing.yml'
5
+ TEST_NOT_FOUND_FILE = File.dirname(__FILE__) + '/notfound.yml'
6
+
7
+
8
+ class TestTwtrConfig < Test::Unit::TestCase
9
+
10
+ def teardown
11
+ [TEST_CONFIG_FILE, TEST_NOTHING_FILE, TEST_NOT_FOUND_FILE].each do |test_file|
12
+ File.delete(test_file) if File.exists? test_file
13
+ end
14
+ end
15
+
16
+ def test_save_and_load
17
+
18
+ Twtr::Config.save(TEST_CONFIG_FILE,{"account" => {"user" => "bob", "password" => "secret"},
19
+ "proxy" => {"host" => "proxy.domain", "port" => 8080} })
20
+
21
+ config = Twtr::Config.load(TEST_CONFIG_FILE)
22
+
23
+ assert_equal("proxy.domain", config["proxy"]["host"])
24
+ assert_equal(8080, config["proxy"]["port"])
25
+
26
+ assert_equal("bob", config["account"]["user"])
27
+ assert_equal("secret", config["account"]["password"])
28
+
29
+ end
30
+
31
+ def test_nothing
32
+
33
+ File.open(TEST_NOTHING_FILE,"w"){}
34
+
35
+ config = Twtr::Config.load(TEST_NOTHING_FILE)
36
+
37
+ assert_equal(false, config)
38
+
39
+ end
40
+
41
+ def test_not_found
42
+ assert_raise(Twtr::ConfigFileNotFoundException) {config = Twtr::Config.load(TEST_NOT_FOUND_FILE)}
43
+ end
44
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require "optparse"
3
+
4
+ class TestTwtrConsole < Test::Unit::TestCase
5
+
6
+ TWTR_PATH = File.expand_path("#{File.dirname(__FILE__)}/../bin/twtr")
7
+
8
+ def test_parse_subcommand
9
+ console = Twtr::Console.new()
10
+ assert_equal(:public_timeline, console.parse_subcommand("public_timeline"))
11
+ assert_equal(:public_timeline, console.parse_subcommand("pt"))
12
+ assert_equal(:friends_timeline, console.parse_subcommand("friends_timeline"))
13
+ assert_equal(:friends_timeline, console.parse_subcommand("ft"))
14
+ assert_equal(:user_timeline, console.parse_subcommand("user_timeline"))
15
+ assert_equal(:user_timeline, console.parse_subcommand("ut"))
16
+ assert_equal(:replies, console.parse_subcommand("replies"))
17
+ assert_equal(:replies, console.parse_subcommand("rp"))
18
+ assert_equal(:update, console.parse_subcommand("update"))
19
+ assert_equal(:update, console.parse_subcommand("up"))
20
+ assert_equal(:setting, console.parse_subcommand("setting"))
21
+ assert_equal(:setting, console.parse_subcommand("reset"))
22
+ end
23
+ # -v, --version Show the version number and quit
24
+ # -h, --help Show this help message and quit.
25
+ # -c, --count=number Display number statuses.
26
+ # -i, --id=userid The ID or screen name of the user.
27
+ # -m, --message=message Post message.
28
+ # -p, --page=number Gets the 20 next statuses.
29
+ # -C, --config=path/to/configfile Use another config. (default: /Users/maruko
30
+
31
+ def test_args()
32
+ test_args = ["pt", "-c", "99", "-p", "88", "-m", "test", "-C", "/hoge/fuga/piyo", "-i", "bob"]
33
+ test_args.extend OptionParser::Arguable
34
+ console = Twtr::Console.new()
35
+ console.parse(test_args)
36
+
37
+ assert_equal(99, console.instance_variable_get("@display_count"))
38
+ assert_equal(88, console.instance_variable_get("@params")[:page])
39
+ assert_equal("bob", console.instance_variable_get("@params")[:id])
40
+ assert_equal("test", console.instance_variable_get("@params")[:status])
41
+ assert_equal(:public_timeline, console.instance_variable_get("@subcommand"))
42
+
43
+ end
44
+
45
+ def test_run()
46
+ ret = `#{TWTR_PATH} x`
47
+ assert_equal("Unkown Subcommand [x]. Please type 'twtr -h'.\n", ret)
48
+
49
+ end
50
+
51
+
52
+ def test_help()
53
+ ret = `#{TWTR_PATH} -h`
54
+ assert_equal(true, ret.include?(Twtr::DESCRIPTION))
55
+ end
56
+
57
+ def test_version()
58
+ ret = `#{TWTR_PATH} -v`
59
+ assert_equal("twtr 0.1.0\n", ret)
60
+ end
61
+
62
+ def test_unkown_subcommand
63
+ test_args = ["x"]
64
+ test_args.extend OptionParser::Arguable
65
+ console = Twtr::Console.new()
66
+
67
+ assert_raise(Twtr::UnknownSubcommandException) { console.parse(test_args) }
68
+ end
69
+
70
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twtr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryota Maruko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-10 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: twtr is a twitter client for Linux, OSX and Windows Console.
17
+ email:
18
+ - ""
19
+ executables:
20
+ - twtr
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - History.txt
25
+ - License.txt
26
+ - README.txt
27
+ files:
28
+ - History.txt
29
+ - License.txt
30
+ - README.txt
31
+ - bin/twtr
32
+ - config/hoe.rb
33
+ - config/requirements.rb
34
+ - lib/twtr.rb
35
+ - lib/twtr/client.rb
36
+ - lib/twtr/config.rb
37
+ - lib/twtr/console.rb
38
+ - lib/twtr/errors.rb
39
+ - lib/twtr/version.rb
40
+ - setup.rb
41
+ - test/test_helper.rb
42
+ - test/test_twtr.rb
43
+ - test/test_twtr_client.rb
44
+ - test/test_twtr_config.rb
45
+ - test/test_twtr_console.rb
46
+ has_rdoc: true
47
+ homepage: http://twtr.rubyforge.org
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --main
51
+ - README.txt
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: twtr
69
+ rubygems_version: 1.0.1
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: twtr is a twitter client for Linux, OSX and Windows Console.
73
+ test_files:
74
+ - test/test_helper.rb
75
+ - test/test_twtr.rb
76
+ - test/test_twtr_client.rb
77
+ - test/test_twtr_config.rb
78
+ - test/test_twtr_console.rb