mbbx6spp-twitter4r 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,3 +40,20 @@ describe Time, "#to_s" do
40
40
  nilize(@time, @expected_string)
41
41
  end
42
42
  end
43
+
44
+ # TODO: figure out how to stub the gem method to do what we want rather than this monstrousity. It is dependent on the system installation, which is always a bad thing. For now it will do so we can ship with 100% C0 coverage.
45
+ describe Kernel, "#gem_present?" do
46
+ before(:each) do
47
+ @present_gem = "rake"
48
+ @uninstalled_gem = "uninstalled-gem-crap"
49
+ end
50
+
51
+ it "should return true when a gem isn't present on system" do
52
+ gem_present?(@present_gem).should eql(true)
53
+ end
54
+
55
+ it "should return false when a gem isn't present on system" do
56
+ gem_present?(@uninstalled_gem).should eql(false)
57
+ end
58
+ end
59
+
@@ -433,9 +433,53 @@ describe Twitter::User, "#defriend" do
433
433
  end
434
434
  end
435
435
 
436
+ describe Twitter::Status, "#reply?" do
437
+ before(:each) do
438
+ @status = Twitter::Status.new(
439
+ :id => 123456789,
440
+ :text => "Wazzup?",
441
+ :user => mock(Twitter::User)
442
+ )
443
+ @reply = Twitter::Status.new(
444
+ :text => "No much bro. You?",
445
+ :user => mock(Twitter::User),
446
+ :in_reply_to_status_id => @status.id
447
+ )
448
+ end
449
+
450
+ it "should return false for the original status" do
451
+ @status.reply?.should be(false)
452
+ end
453
+
454
+ it "should return true for the reply to the original status" do
455
+ @reply.reply?.should be(true)
456
+ end
457
+ end
458
+
459
+ describe Twitter::Status, "#reply(status_text)" do
460
+ before(:each) do
461
+ @twitter = client_context
462
+ @status = Twitter::Status.new(
463
+ :id => 1234,
464
+ :text => "The status text",
465
+ :client => @twitter)
466
+ @reply_text = "Reply text goes here"
467
+ @reply_status = Twitter::Status.new()
468
+ end
469
+
470
+ it "should invoke #status(:reply, :status => ..., :in_reply_to_status_id => ...) on client context" do
471
+ @twitter.should_receive(:status).with(:reply, :status => @reply_text, :in_reply_to_status_id => @status.id).and_return(@reply_status)
472
+ @status.reply(@reply_text)
473
+ end
474
+
475
+ after(:each) do
476
+ nilize(@twitter, @status)
477
+ end
478
+ end
479
+
436
480
  describe Twitter::Status, "#to_s" do
437
481
  before(:each) do
438
- @text = 'Aloha'
482
+ @text = 'Aloha'
439
483
  @status = Twitter::Status.new(:text => @text)
440
484
  end
441
485
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbbx6spp-twitter4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Susan Potter
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-27 00:00:00 -07:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -23,8 +24,8 @@ dependencies:
23
24
  version:
24
25
  description:
25
26
  email: twitter4r-users@googlegroups.com
26
- executables: []
27
-
27
+ executables:
28
+ - t4rsh
28
29
  extensions: []
29
30
 
30
31
  extra_rdoc_files:
@@ -33,47 +34,52 @@ extra_rdoc_files:
33
34
  - TODO
34
35
  - MIT-LICENSE
35
36
  files:
36
- - lib/twitter/extras.rb
37
+ - lib/twitter.rb
37
38
  - lib/twitter/config.rb
38
- - lib/twitter/core.rb
39
+ - lib/twitter/model.rb
40
+ - lib/twitter/ext/stdlib.rb
41
+ - lib/twitter/ext.rb
42
+ - lib/twitter/meta.rb
43
+ - lib/twitter/client.rb
44
+ - lib/twitter/console.rb
45
+ - lib/twitter/client/graph.rb
39
46
  - lib/twitter/client/blocks.rb
40
- - lib/twitter/client/account.rb
47
+ - lib/twitter/client/profile.rb
48
+ - lib/twitter/client/status.rb
41
49
  - lib/twitter/client/timeline.rb
42
- - lib/twitter/client/messaging.rb
43
- - lib/twitter/client/base.rb
44
50
  - lib/twitter/client/favorites.rb
45
- - lib/twitter/client/status.rb
51
+ - lib/twitter/client/account.rb
52
+ - lib/twitter/client/base.rb
53
+ - lib/twitter/client/messaging.rb
46
54
  - lib/twitter/client/friendship.rb
47
- - lib/twitter/client/auth.rb
55
+ - lib/twitter/client/search.rb
48
56
  - lib/twitter/client/user.rb
49
- - lib/twitter/rails.rb
50
- - lib/twitter/client.rb
51
- - lib/twitter/console.rb
57
+ - lib/twitter/client/auth.rb
52
58
  - lib/twitter/version.rb
53
- - lib/twitter/model.rb
54
- - lib/twitter/meta.rb
55
- - lib/twitter/ext.rb
56
- - lib/twitter/ext/stdlib.rb
57
- - lib/twitter.rb
58
- - spec/twitter/config_spec.rb
59
- - spec/twitter/core_spec.rb
59
+ - lib/twitter/extras.rb
60
+ - lib/twitter/core.rb
61
+ - spec/twitter/client_spec.rb
62
+ - spec/twitter/ext/stdlib_spec.rb
63
+ - spec/twitter/console_spec.rb
64
+ - spec/twitter/version_spec.rb
60
65
  - spec/twitter/model_spec.rb
61
- - spec/twitter/client/status_spec.rb
62
- - spec/twitter/client/timeline_spec.rb
63
- - spec/twitter/client/auth_spec.rb
64
- - spec/twitter/client/user_spec.rb
66
+ - spec/twitter/config_spec.rb
65
67
  - spec/twitter/client/messaging_spec.rb
68
+ - spec/twitter/client/friendship_spec.rb
69
+ - spec/twitter/client/graph_spec.rb
66
70
  - spec/twitter/client/base_spec.rb
67
71
  - spec/twitter/client/favorites_spec.rb
68
- - spec/twitter/client/friendship_spec.rb
72
+ - spec/twitter/client/account_spec.rb
73
+ - spec/twitter/client/status_spec.rb
74
+ - spec/twitter/client/search_spec.rb
69
75
  - spec/twitter/client/blocks_spec.rb
70
- - spec/twitter/version_spec.rb
71
- - spec/twitter/rails_spec.rb
72
- - spec/twitter/client_spec.rb
73
- - spec/twitter/meta_spec.rb
74
- - spec/twitter/console_spec.rb
76
+ - spec/twitter/client/timeline_spec.rb
77
+ - spec/twitter/client/auth_spec.rb
78
+ - spec/twitter/client/user_spec.rb
79
+ - spec/twitter/client/profile_spec.rb
75
80
  - spec/twitter/extras_spec.rb
76
- - spec/twitter/ext/stdlib_spec.rb
81
+ - spec/twitter/meta_spec.rb
82
+ - spec/twitter/core_spec.rb
77
83
  - README
78
84
  - CHANGES
79
85
  - TODO
data/lib/twitter/rails.rb DELETED
@@ -1,92 +0,0 @@
1
- # File that contains extensions to the Twitter4R library directly related to providing
2
- # seamless Rails integration.
3
-
4
- if gem_present?('rails', '<= 1.2.6')
5
-
6
- require('active_record/xml_serialization')
7
- require('active_support')
8
-
9
- # Extend +String+ with +#xmlize+ method for convenience.
10
- class String
11
- def xmlize
12
- # Forget module/namespace for now as this is totally broken in Rails 1.2.x
13
- # (search for namespaced models on the Rails Trac site)
14
- cls = self.split('::').pop
15
- cls.dasherize.downcase
16
- end
17
- end
18
-
19
- # Parent mixin module that defines +InstanceMethods+ for Twitter4R model classes.
20
- #
21
- # Defines/overrides the following methods for:
22
- # * Twitter::RailsPatch::InstanceMethods#to_param
23
- # * Twitter::RailsPatch::InstanceMethods#to_xml
24
- # * Twitter::RailsPatch::InstanceMethods#to_json
25
- module Twitter::RailsPatch
26
- class << self
27
- def included(base)
28
- base.send(:include, InstanceMethods)
29
- base.extend ClassMethods
30
- end
31
-
32
- module ClassMethods
33
- # Dummy method to satisfy ActiveRecord's XmlSerializer.
34
- def inheritance_column
35
- nil
36
- end
37
-
38
- # Returns Hash of name-column pairs
39
- def columns_hash
40
- {}
41
- end
42
- end
43
-
44
- module InstanceMethods
45
- # Returns an Array of attribute names of the model
46
- def attribute_names
47
- self.class.class_eval("@@ATTRIBUTES").collect {|att| att.to_s }
48
- end
49
-
50
- # Override default +#to_param+ implementation.
51
- def to_param
52
- self.id.to_s
53
- end
54
-
55
- # Returns XML representation of model.
56
- def to_xml(options = {})
57
- ActiveRecord::XmlSerializer.new(self, options.merge(:root => self.class.name.xmlize)).to_s
58
- end
59
-
60
- # Returns JSON representation of model.
61
- #
62
- # The current implementation basically ignoring +options+, so reopen and override
63
- # this implementation or live with it for the moment:)
64
- def to_json(options = {})
65
- JSON.unparse(self.to_hash)
66
- end
67
- end
68
- end
69
- end
70
-
71
- class Twitter::User
72
- include Twitter::RailsPatch
73
- end
74
-
75
- class Twitter::Status
76
- include Twitter::RailsPatch
77
- end
78
-
79
- class Twitter::Message
80
- include Twitter::RailsPatch
81
- end
82
-
83
- class Twitter::RESTError
84
- include Twitter::RailsPatch
85
- alias :id :code
86
- def to_hash
87
- { :code => @code, :message => @message, :uri => @uri }
88
- end
89
- end
90
- else
91
- warn("WARNING: Twiter4R patch for ActiveRecord defects only supported for Rails 1.2.x currently")
92
- end
@@ -1,110 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
-
3
- describe String, "representing a class name" do
4
-
5
- before(:each) do
6
- @class_name = Twitter::User.class.name
7
- @xmlized_name = @class_name.downcase # simple case for the moment...since Rails' support for namespaced models sucks!
8
- end
9
-
10
- it "should be downcased (minus module namespaces) when xmlized" do
11
- @class_name.xmlize.should eql(@xmlized_name)
12
- end
13
-
14
- after(:each) do
15
- nilize(@class_name, @xmlized_name)
16
- end
17
- end
18
-
19
- describe "Rails model extensions for model classes", :shared => true do
20
-
21
- before(:each) do
22
- @id = 3242334
23
- @id_s = @id.to_s
24
- @model = model(@id)
25
- @model_hash = @model.to_hash
26
- @json = JSON.unparse(@model_hash)
27
- @serializer = ActiveRecord::XmlSerializer.new(@model, {:root => @model.class.name.downcase})
28
- @xml = @serializer.to_s
29
- end
30
-
31
- it "should invoke #to_param as expected" do
32
- @model.should_receive(:id).and_return(@id)
33
- @model.to_param
34
- end
35
-
36
- it "should return string representation for id for #to_param" do
37
- @model.to_param.class.should eql(String)
38
- end
39
-
40
- it "should return output from JSON.unparse for #to_json" do
41
- @model.should_receive(:to_hash).and_return(@model_hash)
42
- JSON.should_receive(:unparse).and_return(@json)
43
- @model.to_json
44
- end
45
-
46
- it "should return XmlSerializer string output for #to_xml" do
47
- ActiveRecord::XmlSerializer.should_receive(:new).and_return(@serializer)
48
- @serializer.should_receive(:to_s).and_return(@xml)
49
- @model.to_xml
50
- end
51
-
52
- after(:each) do
53
- nilize(@id, @model)
54
- end
55
- end
56
-
57
- describe Twitter::User, "Rails extensions" do
58
-
59
- def model(id)
60
- Twitter::User.new(:id => id)
61
- end
62
-
63
- it_should_behave_like "Rails model extensions for model classes"
64
- end
65
-
66
- describe Twitter::Status, "Rails extensions" do
67
-
68
- def model(id)
69
- Twitter::Status.new(:id => id)
70
- end
71
-
72
- it_should_behave_like "Rails model extensions for model classes"
73
- end
74
-
75
- describe Twitter::Message, "Rails extensions" do
76
-
77
- def model(id)
78
- Twitter::Message.new(:id => id)
79
- end
80
-
81
- it_should_behave_like "Rails model extensions for model classes"
82
- end
83
-
84
- describe Twitter::RESTError, "Rails extensions" do
85
-
86
- before(:each) do
87
- @attributes = { :code => 200, :message => 'Success', :uri => 'http://twitter.com/statuses' }
88
- @model = Twitter::RESTError.new(@attributes)
89
- @json = "JSON" # doesn't really matter what the value is
90
- end
91
-
92
- it "should return a Hash of attribute name-value pairs for #to_hash" do
93
- @model.to_hash.should === @attributes
94
- end
95
-
96
- it "should invoke XmlSerializer for #to_xml" do
97
-
98
- @model.to_xml
99
- end
100
-
101
- it "should return expected JSON for #to_json" do
102
- @model.to_hash
103
- JSON.should_receive(:unparse).and_return(@json)
104
- @model.to_json
105
- end
106
-
107
- after(:each) do
108
- nilize(@attributes, @model)
109
- end
110
- end