mbbx6spp-twurl 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.join(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.join(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,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mbbx6spp-twurl
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 1
9
+ version: 0.6.1
10
+ platform: ruby
11
+ authors:
12
+ - Marcel Molina
13
+ - Raffi Krikorian
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-02 00:00:00 -05: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
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Curl for the Twitter API
35
+ email:
36
+ - marcel@twitter.com
37
+ - raffi@twitter.com
38
+ executables:
39
+ - twurl
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - README
44
+ - COPYING
45
+ - INSTALL
46
+ files:
47
+ - Rakefile
48
+ - lib/twurl.rb
49
+ - lib/twurl/version.rb
50
+ - lib/twurl/cli.rb
51
+ - lib/twurl/account_information_controller.rb
52
+ - lib/twurl/rcfile.rb
53
+ - lib/twurl/authorization_controller.rb
54
+ - lib/twurl/configuration_controller.rb
55
+ - lib/twurl/oauth_client.rb
56
+ - lib/twurl/request_controller.rb
57
+ - lib/twurl/abstract_command_controller.rb
58
+ - lib/twurl/aliases_controller.rb
59
+ - bin/twurl
60
+ - test/test_helper.rb
61
+ - test/cli_options_test.rb
62
+ - test/request_controller_test.rb
63
+ - test/authorization_controller_test.rb
64
+ - test/configuration_controller_test.rb
65
+ - test/oauth_client_test.rb
66
+ - test/alias_controller_test.rb
67
+ - test/rcfile_test.rb
68
+ - test/cli_test.rb
69
+ - test/account_information_controller_test.rb
70
+ - README
71
+ - COPYING
72
+ - INSTALL
73
+ has_rdoc: true
74
+ homepage: http://github.com/marcel/twurl
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --title
80
+ - twurl -- OAuth-enabled curl for the Twitter API
81
+ - --main
82
+ - README
83
+ - --line-numbers
84
+ - --inline-source
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project: twurl
106
+ rubygems_version: 1.3.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Curl for the Twitter API
110
+ test_files:
111
+ - test/test_helper.rb
112
+ - test/cli_options_test.rb
113
+ - test/request_controller_test.rb
114
+ - test/authorization_controller_test.rb
115
+ - test/configuration_controller_test.rb
116
+ - test/oauth_client_test.rb
117
+ - test/alias_controller_test.rb
118
+ - test/rcfile_test.rb
119
+ - test/cli_test.rb
120
+ - test/account_information_controller_test.rb