streambot 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -4
- data/lib/retweet.rb +2 -2
- data/test/test_retweet.rb +40 -0
- metadata +18 -3
data/Rakefile
CHANGED
@@ -15,9 +15,9 @@ begin
|
|
15
15
|
|
16
16
|
# Dependency for dealing with twitter streaming API
|
17
17
|
gem.add_dependency "tweetstream",">= 1.0.4"
|
18
|
+
gem.add_development_dependency "webmock",">= 1.0.0"
|
18
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
20
|
end
|
20
|
-
Jeweler::GemcutterTasks.new
|
21
21
|
rescue LoadError
|
22
22
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
23
23
|
end
|
@@ -42,9 +42,8 @@ rescue LoadError
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
task :
|
46
|
-
|
47
|
-
task :default => :test
|
45
|
+
task :default => [:check_dependencies,:test]
|
46
|
+
task :build_gem => [:test,:build]
|
48
47
|
|
49
48
|
require 'rake/rdoctask'
|
50
49
|
Rake::RDocTask.new do |rdoc|
|
data/lib/retweet.rb
CHANGED
@@ -20,11 +20,11 @@ class Retweet
|
|
20
20
|
# connect
|
21
21
|
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
22
22
|
case res
|
23
|
-
#OK
|
24
23
|
when Net::HTTPSuccess, Net::HTTPRedirection
|
24
|
+
return res
|
25
25
|
else
|
26
26
|
# when connection wasn't successful print error message
|
27
|
-
res.error!
|
27
|
+
puts res.error!
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'webmock'
|
4
|
+
require 'retweet'
|
5
|
+
|
6
|
+
include WebMock
|
7
|
+
|
8
|
+
# the test for testing retweet functionality
|
9
|
+
class TestRetweet < Test::Unit::TestCase
|
10
|
+
|
11
|
+
# setup the test
|
12
|
+
def setup
|
13
|
+
# authentication to my test-account on twitter
|
14
|
+
auth = {:username=>'gr4ydev',:password=>'afe5fek3'}
|
15
|
+
# actually used one of my own tweets
|
16
|
+
@id = 12355936428
|
17
|
+
# initialize retweet
|
18
|
+
@retweet = Retweet.new(auth)
|
19
|
+
# stubbing (actually webmock does the magic here)
|
20
|
+
stub_request(:post, "http://#{auth[:username]}:#{auth[:password]}@api.twitter.com/1/statuses/retweet/#{@id}.json").to_return(:body => 'content')
|
21
|
+
end
|
22
|
+
|
23
|
+
# teardown the test
|
24
|
+
def teardown
|
25
|
+
# nil all recent variables
|
26
|
+
@id, @retweet = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
# retweet
|
30
|
+
def test_retweet
|
31
|
+
# no permission to access web!
|
32
|
+
WebMock.disable_net_connect!
|
33
|
+
# retweet the given id
|
34
|
+
response = @retweet.retweet(@id)
|
35
|
+
# assertion
|
36
|
+
assert_not_nil(response)
|
37
|
+
assert_equal('content',response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 4
|
9
|
+
version: 0.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sascha Wessel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-17 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -31,6 +31,20 @@ dependencies:
|
|
31
31
|
version: 1.0.4
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: webmock
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 1.0.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
34
48
|
description: a simple gem that tracks several keywords via twitter streaming api and re-publish it on twitter
|
35
49
|
email: swessel@gr4yweb.de
|
36
50
|
executables: []
|
@@ -78,3 +92,4 @@ specification_version: 3
|
|
78
92
|
summary: retweeting tweets with specified keywords on twitter
|
79
93
|
test_files:
|
80
94
|
- test/test_streambot.rb
|
95
|
+
- test/test_retweet.rb
|