stocktwits 1.0.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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README +0 -0
- data/README.rdoc +17 -0
- data/Rakefile +63 -0
- data/VERSION +1 -0
- data/app/controllers/sessions_controller.rb +68 -0
- data/app/models/stocktwits/basic_user.rb +64 -0
- data/app/models/stocktwits/generic_user.rb +123 -0
- data/app/models/stocktwits/oauth_user.rb +46 -0
- data/app/models/stocktwits/plain_user.rb +53 -0
- data/app/views/sessions/_login.html.erb +18 -0
- data/app/views/sessions/new.html.erb +5 -0
- data/config/routes.rb +6 -0
- data/generators/stocktwits/USAGE +12 -0
- data/generators/stocktwits/stocktwits_generator.rb +42 -0
- data/generators/stocktwits/templates/migration.rb +20 -0
- data/generators/stocktwits/templates/stocktwits.yml +66 -0
- data/generators/stocktwits/templates/user.rb +5 -0
- data/lib/stocktwits.rb +103 -0
- data/lib/stocktwits/controller_extensions.rb +72 -0
- data/lib/stocktwits/cryptify.rb +30 -0
- data/lib/stocktwits/dispatcher/basic.rb +46 -0
- data/lib/stocktwits/dispatcher/oauth.rb +26 -0
- data/lib/stocktwits/dispatcher/plain.rb +44 -0
- data/lib/stocktwits/dispatcher/shared.rb +42 -0
- data/rails/init.rb +6 -0
- data/spec/application.rb +1 -0
- data/spec/controllers/controller_extensions_spec.rb +162 -0
- data/spec/controllers/sessions_controller_spec.rb +221 -0
- data/spec/debug.log +397 -0
- data/spec/fixtures/config/twitter_auth.yml +17 -0
- data/spec/fixtures/factories.rb +28 -0
- data/spec/fixtures/fakeweb.rb +18 -0
- data/spec/fixtures/stocktwits.rb +5 -0
- data/spec/models/stocktwits/basic_user_spec.rb +138 -0
- data/spec/models/stocktwits/generic_user_spec.rb +146 -0
- data/spec/models/stocktwits/oauth_user_spec.rb +100 -0
- data/spec/schema.rb +25 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +107 -0
- data/spec/stocktwits/cryptify_spec.rb +51 -0
- data/spec/stocktwits/dispatcher/basic_spec.rb +83 -0
- data/spec/stocktwits/dispatcher/oauth_spec.rb +72 -0
- data/spec/stocktwits/dispatcher/shared_spec.rb +26 -0
- data/spec/stocktwits_spec.rb +173 -0
- data/stocktwits.gemspec +116 -0
- metadata +158 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Cryptify do
|
4
|
+
before do
|
5
|
+
stub_basic!
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have encrypt and decrypt methods' do
|
9
|
+
TwitterAuth::Cryptify.should respond_to(:encrypt)
|
10
|
+
TwitterAuth::Cryptify.should respond_to(:decrypt)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.encrypt' do
|
14
|
+
it 'should return a hash with :encrypted_data and :salt keys' do
|
15
|
+
result = TwitterAuth::Cryptify.encrypt('some string')
|
16
|
+
result.should be_a(Hash)
|
17
|
+
result.key?(:encrypted_data).should be_true
|
18
|
+
result.key?(:salt).should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should make a call to EzCrypto::Key.encrypt_with_password' do
|
22
|
+
EzCrypto::Key.should_receive(:encrypt_with_password).once.and_return('gobbledygook')
|
23
|
+
TwitterAuth::Cryptify.encrypt('some string')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not have the same encrypted as plaintext data' do
|
27
|
+
TwitterAuth::Cryptify.encrypt('some string')[:encrypted_data].should_not == 'some string'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.decrypt' do
|
32
|
+
before do
|
33
|
+
@salt = TwitterAuth::Cryptify.generate_salt
|
34
|
+
TwitterAuth::Cryptify.stub!(:generate_salt).and_return(@salt)
|
35
|
+
@string = 'decrypted string'
|
36
|
+
@encrypted = TwitterAuth::Cryptify.encrypt(@string)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return the original string' do
|
40
|
+
TwitterAuth::Cryptify.decrypt(@encrypted).should == @string
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should raise an argument error if encrypted data is provided without a salt' do
|
44
|
+
lambda{TwitterAuth::Cryptify.decrypt('asodiaoie2')}.should raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should raise an argument error if a string or hash are not provided' do
|
48
|
+
lambda{TwitterAuth::Cryptify.decrypt(23)}.should raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Basic do
|
4
|
+
before do
|
5
|
+
stub_basic!
|
6
|
+
@user = Factory.create(:twitter_basic_user, :login => 'twitterman', :password => 'test')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should require a user as the initialization argument' do
|
10
|
+
lambda{TwitterAuth::Dispatcher::Basic.new(nil)}.should raise_error(TwitterAuth::Error, 'Dispatcher must be initialized with a User.')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should store the user in an attr_accessor' do
|
14
|
+
TwitterAuth::Dispatcher::Basic.new(@user).user.should == @user
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#request' do
|
18
|
+
before do
|
19
|
+
@dispatcher = TwitterAuth::Dispatcher::Basic.new(@user)
|
20
|
+
FakeWeb.register_uri('https://twitter.com:443/fake.json', :string => {'fake' => true}.to_json)
|
21
|
+
FakeWeb.register_uri('https://twitter.com:443/fake.xml', :string => '<fake>true</fake>')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should automatically parse JSON if valid' do
|
25
|
+
@dispatcher.request(:get, '/fake.json').should == {'fake' => true}
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return XML as a string' do
|
29
|
+
@dispatcher.request(:get, '/fake.xml').should == "<fake>true</fake>"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should append .json to the path if no extension is provided' do
|
33
|
+
@dispatcher.request(:get, '/fake.json').should == @dispatcher.request(:get, '/fake')
|
34
|
+
end
|
35
|
+
|
36
|
+
%w(get post put delete).each do |method|
|
37
|
+
it "should build a #{method} class based on a :#{method} http_method" do
|
38
|
+
@req = "Net::HTTP::#{method.capitalize}".constantize.new('/fake.json')
|
39
|
+
"Net::HTTP::#{method.capitalize}".constantize.should_receive(:new).and_return(@req)
|
40
|
+
@dispatcher.request(method.to_sym, '/fake')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should start the HTTP session' do
|
45
|
+
@net = TwitterAuth.net
|
46
|
+
TwitterAuth.stub!(:net).and_return(@net)
|
47
|
+
@net.should_receive(:start)
|
48
|
+
lambda{@dispatcher.request(:get, '/fake')}.should raise_error(NoMethodError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should raise a TwitterAuth::Dispatcher::Error if response code isn't 200" do
|
52
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
|
53
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should set the error message to the JSON message' do
|
57
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
|
58
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
|
62
|
+
FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "<hash>\n<request>/unauthenticated_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['401', 'Unauthorized'])
|
63
|
+
lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should set the error message to the XML message' do
|
67
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "<hash>\n<request>/bad_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['403', 'Forbidden'])
|
68
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
%w(get post delete put).each do |method|
|
73
|
+
it "should have a ##{method} method that calls request(:#{method})" do
|
74
|
+
dispatcher = TwitterAuth::Dispatcher::Basic.new(@user)
|
75
|
+
if %w(get delete).include?(method)
|
76
|
+
dispatcher.should_receive(:request).with(method.to_sym, '/fake.json')
|
77
|
+
else
|
78
|
+
dispatcher.should_receive(:request).with(method.to_sym, '/fake.json', '')
|
79
|
+
end
|
80
|
+
dispatcher.send(method, '/fake.json')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Oauth do
|
4
|
+
before do
|
5
|
+
stub_oauth!
|
6
|
+
@user = Factory.create(:twitter_oauth_user, :access_token => 'token', :access_secret => 'secret')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be a child class of OAuth::AccessToken' do
|
10
|
+
TwitterAuth::Dispatcher::Oauth.new(@user).should be_a(OAuth::AccessToken)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should require initialization of an OauthUser' do
|
14
|
+
lambda{TwitterAuth::Dispatcher::Oauth.new(nil)}.should raise_error(TwitterAuth::Error, 'Dispatcher must be initialized with a User.')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should store the user in an attr_accessor' do
|
18
|
+
TwitterAuth::Dispatcher::Oauth.new(@user).user.should == @user
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should initialize with the user's token and secret" do
|
22
|
+
d = TwitterAuth::Dispatcher::Oauth.new(@user)
|
23
|
+
d.token.should == 'token'
|
24
|
+
d.secret.should == 'secret'
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#request' do
|
28
|
+
before do
|
29
|
+
@dispatcher = TwitterAuth::Dispatcher::Oauth.new(@user)
|
30
|
+
FakeWeb.register_uri(:get, 'https://twitter.com:443/fake.json', :string => {'fake' => true}.to_json)
|
31
|
+
FakeWeb.register_uri(:get, 'https://twitter.com:443/fake.xml', :string => "<fake>true</fake>")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should automatically parse json' do
|
35
|
+
result = @dispatcher.request(:get, '/fake.json')
|
36
|
+
result.should be_a(Hash)
|
37
|
+
result['fake'].should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return xml as a string' do
|
41
|
+
@dispatcher.request(:get, '/fake.xml').should == '<fake>true</fake>'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should append .json to the path if no extension is provided' do
|
45
|
+
@dispatcher.request(:get, '/fake').should == @dispatcher.request(:get, '/fake.json')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should raise a TwitterAuth::Dispatcher::Error if response code isn't 200" do
|
49
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
|
50
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should set the error message to the JSON message' do
|
54
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
|
55
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should set the error message to the XML message' do
|
59
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "<hash>\n<request>/bad_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['403', 'Forbidden'])
|
60
|
+
lambda{@dispatcher.request(:get, '/bad_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
|
64
|
+
FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "<hash>\n<request>/unauthenticated_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['401', 'Unauthorized'])
|
65
|
+
lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should work with verb methods' do
|
69
|
+
@dispatcher.get('/fake').should == @dispatcher.request(:get, '/fake')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Shared do
|
4
|
+
include TwitterAuth::Dispatcher::Shared
|
5
|
+
|
6
|
+
describe '#append_extension_to' do
|
7
|
+
it 'should leave extensions alone if they exist' do
|
8
|
+
append_extension_to('/fake.json').should == '/fake.json'
|
9
|
+
append_extension_to('/fake.xml').should == '/fake.xml'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should append .json if no extension is provided' do
|
13
|
+
append_extension_to('/fake').should == '/fake.json'
|
14
|
+
append_extension_to('/verify/fake').should == '/verify/fake.json'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should leave extensions alone even with query strings' do
|
18
|
+
append_extension_to('/fake.json?since_id=123').should == '/fake.json?since_id=123'
|
19
|
+
append_extension_to('/fake.xml?since_id=123').should == '/fake.xml?since_id=123'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should add an extension even with query strings' do
|
23
|
+
append_extension_to('/fake?since_id=123').should == '/fake.json?since_id=123'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Stocktwits do
|
4
|
+
describe '.base_url' do
|
5
|
+
it 'should have default to http://api.stocktwits.com' do
|
6
|
+
Stocktwits.stub!(:config).and_return({})
|
7
|
+
Stocktwits.base_url.should == 'http://api.stocktwits.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should otherwise load from the config[base_url]' do
|
11
|
+
Stocktwits.stub!(:config).and_return({'base_url' => 'https://example.com'})
|
12
|
+
Stocktwits.base_url.should == 'https://example.com'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should utilize oauth consumer settings' do
|
16
|
+
@config = Stocktwits.config
|
17
|
+
Stocktwits.stub!(:config).and_return(@config.merge('authorize_path' => '/somewhere_else'))
|
18
|
+
Stocktwits.consumer.authorize_path.should == '/somewhere_else'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".path_prefix" do
|
23
|
+
it 'should be blank if the base url does not have a path' do
|
24
|
+
Stocktwits.stub!(:base_url).and_return("https://api.stocktwits.com:443")
|
25
|
+
Stocktwits.path_prefix.should == ""
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return the path prefix if one exists' do
|
29
|
+
Stocktwits.stub!(:base_url).and_return("http://api.stocktwits.com/api/twitter")
|
30
|
+
Stocktwits.path_prefix.should == "/api/twitter"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.api_timeout' do
|
35
|
+
it 'should default to 10' do
|
36
|
+
Stocktwits.stub!(:config).and_return({})
|
37
|
+
Stocktwits.api_timeout.should == 10
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be settable via config' do
|
41
|
+
Stocktwits.stub!(:config).and_return({'api_timeout' => 15})
|
42
|
+
Stocktwits.api_timeout.should == 15
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.remember_for' do
|
47
|
+
it 'should default to 14' do
|
48
|
+
Stocktwits.stub!(:config).and_return({})
|
49
|
+
Stocktwits.remember_for.should == 14
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should be settable via config' do
|
53
|
+
Stocktwits.stub!(:config).and_return({'remember_for' => '7'})
|
54
|
+
Stocktwits.remember_for.should == 7
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.net' do
|
59
|
+
before do
|
60
|
+
stub_basic!
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should return a Net::HTTP object' do
|
64
|
+
Stocktwits.net.should be_a(Net::HTTP)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should be SSL if the base_url is' do
|
68
|
+
Stocktwits.stub!(:config).and_return({'base_url' => 'http://api.stocktwits.com'})
|
69
|
+
Stocktwits.net.use_ssl?.should be_false
|
70
|
+
Stocktwits.stub!(:config).and_return({'base_url' => 'https://api.stocktwits.com'})
|
71
|
+
Stocktwits.net.use_ssl?.should be_true
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should work from the base_url' do
|
75
|
+
@net = Net::HTTP.new('example.com',80)
|
76
|
+
Net::HTTP.should_receive(:new).with('example.com',80).and_return(@net)
|
77
|
+
Stocktwits.stub!(:config).and_return({'base_url' => 'http://example.com'})
|
78
|
+
Stocktwits.net
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#config' do
|
83
|
+
before do
|
84
|
+
Stocktwits.send(:instance_variable_set, :@config, nil)
|
85
|
+
@config_file = File.open(File.dirname(__FILE__) + '/fixtures/config/stocktwits.yml')
|
86
|
+
File.should_receive(:open).any_number_of_times.and_return(@config_file)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should load a hash from RAILS_ROOT/config/stocktwits.yml' do
|
90
|
+
Stocktwits.config.should be_a(Hash)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should be able to override the RAILS_ENV' do
|
94
|
+
Stocktwits.config('development')['oauth_consumer_key'].should == 'devkey'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#consumer' do
|
99
|
+
before do
|
100
|
+
stub_oauth!
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should be an OAuth Consumer' do
|
104
|
+
Stocktwits.consumer.should be_a(OAuth::Consumer)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should use the credentials from #config' do
|
108
|
+
Stocktwits.consumer.key.should == 'testkey'
|
109
|
+
Stocktwits.consumer.secret.should == 'testsecret'
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should use the Stocktwits base_url' do
|
113
|
+
Stocktwits.stub!(:base_url).and_return('https://example.com')
|
114
|
+
Stocktwits.consumer.site.should == Stocktwits.base_url
|
115
|
+
Stocktwits.consumer.site.should == 'https://example.com'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#strategy' do
|
120
|
+
it 'should pull and symbolize from the config' do
|
121
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'oauth'})
|
122
|
+
Stocktwits.strategy.should == Stocktwits.config['strategy'].to_sym
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should raise an argument error if not oauth or basic' do
|
126
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'oauth'})
|
127
|
+
lambda{Stocktwits.strategy}.should_not raise_error(ArgumentError)
|
128
|
+
|
129
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'basic'})
|
130
|
+
lambda{Stocktwits.strategy}.should_not raise_error(ArgumentError)
|
131
|
+
|
132
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'plain'})
|
133
|
+
lambda{Stocktwits.strategy}.should_not raise_error(ArgumentError)
|
134
|
+
|
135
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'invalid_strategy'})
|
136
|
+
lambda{Stocktwits.strategy}.should raise_error(ArgumentError)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it '#oauth? should be true if strategy is :oauth' do
|
141
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'oauth'})
|
142
|
+
Stocktwits.oauth?.should be_true
|
143
|
+
Stocktwits.basic?.should be_false
|
144
|
+
Stocktwits.plain?.should be_false
|
145
|
+
end
|
146
|
+
|
147
|
+
it '#basic? should be true if strategy is :basic' do
|
148
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'basic'})
|
149
|
+
Stocktwits.basic?.should be_true
|
150
|
+
Stocktwits.oauth?.should be_false
|
151
|
+
Stocktwits.plain?.should be_false
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
it '#plain? should be true if strategy is :basic' do
|
156
|
+
Stocktwits.stub!(:config).and_return({'strategy' => 'plain'})
|
157
|
+
Stocktwits.plain?.should be_true
|
158
|
+
Stocktwits.oauth?.should be_false
|
159
|
+
Stocktwits.basic?.should be_false
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#encryption_key' do
|
163
|
+
it 'should raise a Cryptify error if none is found' do
|
164
|
+
Stocktwits.stub!(:config).and_return({})
|
165
|
+
lambda{Stocktwits.encryption_key}.should raise_error(Stocktwits::Cryptify::Error, "You must specify an encryption_key in config/stocktwits.yml")
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should return the config[encryption_key] value' do
|
169
|
+
Stocktwits.stub!(:config).and_return({'encryption_key' => 'mickeymouse'})
|
170
|
+
Stocktwits.encryption_key.should == 'mickeymouse'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
data/stocktwits.gemspec
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{stocktwits}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Elad Meidar"]
|
12
|
+
s.date = %q{2010-03-20}
|
13
|
+
s.description = %q{ Provide an OAuth, Basic HTTP authentication and plain interfaces to the StockTwits API.}
|
14
|
+
s.email = %q{elad@eizesus.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".gitignore",
|
23
|
+
"LICENSE",
|
24
|
+
"README",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"app/controllers/sessions_controller.rb",
|
29
|
+
"app/models/stocktwits/basic_user.rb",
|
30
|
+
"app/models/stocktwits/generic_user.rb",
|
31
|
+
"app/models/stocktwits/oauth_user.rb",
|
32
|
+
"app/models/stocktwits/plain_user.rb",
|
33
|
+
"app/views/sessions/_login.html.erb",
|
34
|
+
"app/views/sessions/new.html.erb",
|
35
|
+
"config/routes.rb",
|
36
|
+
"generators/stocktwits/USAGE",
|
37
|
+
"generators/stocktwits/stocktwits_generator.rb",
|
38
|
+
"generators/stocktwits/templates/migration.rb",
|
39
|
+
"generators/stocktwits/templates/stocktwits.yml",
|
40
|
+
"generators/stocktwits/templates/user.rb",
|
41
|
+
"lib/stocktwits.rb",
|
42
|
+
"lib/stocktwits/controller_extensions.rb",
|
43
|
+
"lib/stocktwits/cryptify.rb",
|
44
|
+
"lib/stocktwits/dispatcher/basic.rb",
|
45
|
+
"lib/stocktwits/dispatcher/oauth.rb",
|
46
|
+
"lib/stocktwits/dispatcher/plain.rb",
|
47
|
+
"lib/stocktwits/dispatcher/shared.rb",
|
48
|
+
"rails/init.rb",
|
49
|
+
"spec/application.rb",
|
50
|
+
"spec/controllers/controller_extensions_spec.rb",
|
51
|
+
"spec/controllers/sessions_controller_spec.rb",
|
52
|
+
"spec/debug.log",
|
53
|
+
"spec/fixtures/config/twitter_auth.yml",
|
54
|
+
"spec/fixtures/factories.rb",
|
55
|
+
"spec/fixtures/fakeweb.rb",
|
56
|
+
"spec/fixtures/stocktwits.rb",
|
57
|
+
"spec/models/stocktwits/basic_user_spec.rb",
|
58
|
+
"spec/models/stocktwits/generic_user_spec.rb",
|
59
|
+
"spec/models/stocktwits/oauth_user_spec.rb",
|
60
|
+
"spec/schema.rb",
|
61
|
+
"spec/spec.opts",
|
62
|
+
"spec/spec_helper.rb",
|
63
|
+
"spec/stocktwits/cryptify_spec.rb",
|
64
|
+
"spec/stocktwits/dispatcher/basic_spec.rb",
|
65
|
+
"spec/stocktwits/dispatcher/oauth_spec.rb",
|
66
|
+
"spec/stocktwits/dispatcher/shared_spec.rb",
|
67
|
+
"spec/stocktwits_spec.rb",
|
68
|
+
"stocktwits.gemspec"
|
69
|
+
]
|
70
|
+
s.homepage = %q{http://github.com/eladmeidar/stocktwits}
|
71
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
72
|
+
s.require_paths = ["lib"]
|
73
|
+
s.rubygems_version = %q{1.3.5}
|
74
|
+
s.summary = %q{Stocktwits.com API wrapper}
|
75
|
+
s.test_files = [
|
76
|
+
"spec/application.rb",
|
77
|
+
"spec/controllers/controller_extensions_spec.rb",
|
78
|
+
"spec/controllers/sessions_controller_spec.rb",
|
79
|
+
"spec/fixtures/factories.rb",
|
80
|
+
"spec/fixtures/fakeweb.rb",
|
81
|
+
"spec/fixtures/stocktwits.rb",
|
82
|
+
"spec/models/stocktwits/basic_user_spec.rb",
|
83
|
+
"spec/models/stocktwits/generic_user_spec.rb",
|
84
|
+
"spec/models/stocktwits/oauth_user_spec.rb",
|
85
|
+
"spec/schema.rb",
|
86
|
+
"spec/spec_helper.rb",
|
87
|
+
"spec/stocktwits/cryptify_spec.rb",
|
88
|
+
"spec/stocktwits/dispatcher/basic_spec.rb",
|
89
|
+
"spec/stocktwits/dispatcher/oauth_spec.rb",
|
90
|
+
"spec/stocktwits/dispatcher/shared_spec.rb",
|
91
|
+
"spec/stocktwits_spec.rb"
|
92
|
+
]
|
93
|
+
|
94
|
+
if s.respond_to? :specification_version then
|
95
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
96
|
+
s.specification_version = 3
|
97
|
+
|
98
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
99
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
100
|
+
s.add_runtime_dependency(%q<ezcrypto>, [">= 0"])
|
101
|
+
s.add_runtime_dependency(%q<oauth>, [">= 0"])
|
102
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
103
|
+
else
|
104
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
105
|
+
s.add_dependency(%q<ezcrypto>, [">= 0"])
|
106
|
+
s.add_dependency(%q<oauth>, [">= 0"])
|
107
|
+
s.add_dependency(%q<json>, [">= 0"])
|
108
|
+
end
|
109
|
+
else
|
110
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
111
|
+
s.add_dependency(%q<ezcrypto>, [">= 0"])
|
112
|
+
s.add_dependency(%q<oauth>, [">= 0"])
|
113
|
+
s.add_dependency(%q<json>, [">= 0"])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|