twurl 0.6.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,58 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class Twurl::RequestController::AbstractTestCase < Test::Unit::TestCase
4
+ attr_reader :options, :client, :controller
5
+ def setup
6
+ Twurl::CLI.output = StringIO.new
7
+ @options = Twurl::Options.test_exemplar
8
+ @client = Twurl::OAuthClient.test_exemplar
9
+ @controller = Twurl::RequestController.new(client, options)
10
+ end
11
+
12
+ def teardown
13
+ super
14
+ Twurl::CLI.output = STDOUT
15
+ end
16
+
17
+ def test_nothing
18
+ # Appeasing test/unit
19
+ end
20
+ end
21
+
22
+ class Twurl::RequestController::DispatchTest < Twurl::RequestController::AbstractTestCase
23
+ def test_request_will_be_made_if_client_is_authorized
24
+ mock(client).needs_to_authorize? { false }.times(1)
25
+ mock(controller).perform_request.times(1)
26
+
27
+ controller.dispatch
28
+ end
29
+
30
+ def test_request_will_not_be_made_if_client_is_not_authorized
31
+ mock(client).needs_to_authorize? { true }.times(1)
32
+ mock(controller).perform_request.never
33
+
34
+ assert_raises Twurl::Exception do
35
+ controller.dispatch
36
+ end
37
+ end
38
+ end
39
+
40
+ class Twurl::RequestController::RequestTest < Twurl::RequestController::AbstractTestCase
41
+ def test_request_response_is_written_to_output
42
+ expected_body = 'this is a fake response body'
43
+ response = Object.new
44
+ mock(response).body.times(1) { expected_body }
45
+ mock(client).perform_request_from_options(options).times(1) { response }
46
+
47
+ controller.perform_request
48
+
49
+ assert_equal expected_body, Twurl::CLI.output.string.chomp
50
+ end
51
+
52
+ def test_invalid_or_unspecified_urls_report_error
53
+ mock(Twurl::CLI).puts(Twurl::RequestController::NO_URI_MESSAGE).times(1)
54
+ mock(client).perform_request_from_options(options).times(1) { raise URI::InvalidURIError }
55
+
56
+ controller.perform_request
57
+ end
58
+ end
@@ -0,0 +1,40 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../lib'
2
+ require 'twurl'
3
+ require 'test/unit'
4
+ require 'rr'
5
+
6
+ class Test::Unit::TestCase
7
+ include RR::Adapters::TestUnit
8
+ end
9
+
10
+ Twurl::RCFile.directory = ENV['TMPDIR']
11
+
12
+ module Twurl
13
+ class Options
14
+ class << self
15
+ def test_exemplar
16
+ options = new
17
+ options.username = 'exemplar_user_name'
18
+ options.password = 'secret'
19
+ options.consumer_key = '123456789'
20
+ options.consumer_secret = '987654321'
21
+ options.subcommands = []
22
+ options
23
+ end
24
+ end
25
+ end
26
+
27
+ class OAuthClient
28
+ class << self
29
+ def test_exemplar(overrides = {})
30
+ options = Twurl::Options.test_exemplar
31
+
32
+ overrides.each do |attribute, value|
33
+ options.send("#{attribute}=", value)
34
+ end
35
+
36
+ load_new_client_from_options(options)
37
+ end
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twurl
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
10
+ platform: ruby
11
+ authors:
12
+ - Marcel Molina
13
+ - Raffi Krikorian
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-04-20 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: oauth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Curl for the Twitter API
34
+ email:
35
+ - marcel@twitter.com
36
+ - raffi@twitter.com
37
+ executables:
38
+ - twurl
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ - COPYING
44
+ - INSTALL
45
+ files:
46
+ - Rakefile
47
+ - lib/twurl/abstract_command_controller.rb
48
+ - lib/twurl/account_information_controller.rb
49
+ - lib/twurl/aliases_controller.rb
50
+ - lib/twurl/authorization_controller.rb
51
+ - lib/twurl/cli.rb
52
+ - lib/twurl/configuration_controller.rb
53
+ - lib/twurl/oauth_client.rb
54
+ - lib/twurl/rcfile.rb
55
+ - lib/twurl/request_controller.rb
56
+ - lib/twurl/version.rb
57
+ - lib/twurl.rb
58
+ - bin/twurl
59
+ - README
60
+ - COPYING
61
+ - INSTALL
62
+ has_rdoc: true
63
+ homepage: http://github.com/marcel/twurl
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --title
69
+ - twurl -- OAuth-enabled curl for the Twitter API
70
+ - --main
71
+ - README
72
+ - --line-numbers
73
+ - --inline-source
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project: twurl
93
+ rubygems_version: 1.3.6
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Curl for the Twitter API
97
+ test_files:
98
+ - test/account_information_controller_test.rb
99
+ - test/alias_controller_test.rb
100
+ - test/authorization_controller_test.rb
101
+ - test/cli_options_test.rb
102
+ - test/cli_test.rb
103
+ - test/configuration_controller_test.rb
104
+ - test/oauth_client_test.rb
105
+ - test/rcfile_test.rb
106
+ - test/request_controller_test.rb
107
+ - test/test_helper.rb