tweetwine 0.4.2 → 0.4.3
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/CHANGELOG.rdoc +5 -0
 - data/Gemfile +1 -1
 - data/README.md +2 -2
 - data/Rakefile +5 -0
 - data/benchmark/home_bm.rb +36 -0
 - data/lib/tweetwine/character_encoding.rb +1 -1
 - data/lib/tweetwine/http.rb +1 -1
 - data/lib/tweetwine/support.rb +28 -26
 - data/lib/tweetwine/twitter.rb +8 -5
 - data/lib/tweetwine/version.rb +1 -1
 - data/lib/tweetwine.rb +0 -2
 - data/man/tweetwine.7 +3 -3
 - data/man/tweetwine.7.ronn +2 -2
 - data/project.rb +2 -0
 - data/test/fixture/config_integration.yaml +1 -1
 - data/test/integration/authorization_test.rb +1 -1
 - data/test/integration/global_options_test.rb +1 -1
 - data/test/integration/invalid_config_file_test.rb +1 -1
 - data/test/integration/search_statuses_test.rb +1 -1
 - data/test/integration/show_followers_test.rb +1 -1
 - data/test/integration/show_friends_test.rb +1 -1
 - data/test/integration/show_home_test.rb +1 -1
 - data/test/integration/show_mentions_test.rb +1 -1
 - data/test/integration/show_user_test.rb +1 -1
 - data/test/integration/update_status_test.rb +42 -21
 - data/test/integration/use_http_proxy_test.rb +6 -6
 - data/test/integration/user_help_test.rb +2 -2
 - data/test/support/assertions.rb +58 -0
 - data/test/support/common.rb +10 -0
 - data/test/support/common_helpers.rb +43 -0
 - data/test/support/doubles.rb +35 -0
 - data/test/{integration/helper.rb → support/integration_test_case.rb} +12 -7
 - data/test/support/mocha_integration.rb +16 -0
 - data/test/support/tweets.rb +95 -0
 - data/test/support/unit_test_case.rb +28 -0
 - data/test/support/webmock_integration.rb +16 -0
 - data/test/unit/character_encoding_test.rb +1 -1
 - data/test/unit/cli_test.rb +4 -4
 - data/test/unit/config_test.rb +1 -1
 - data/test/unit/http_test.rb +1 -1
 - data/test/unit/oauth_test.rb +1 -1
 - data/test/unit/obfuscate_test.rb +1 -1
 - data/test/unit/option_parser_test.rb +1 -1
 - data/test/unit/promise_test.rb +1 -1
 - data/test/unit/support_test.rb +1 -1
 - data/test/unit/tweet_test.rb +3 -3
 - data/test/unit/twitter_test.rb +29 -27
 - data/test/unit/ui_test.rb +3 -3
 - data/test/unit/uri_test.rb +1 -1
 - data/test/unit/url_shortener_test.rb +1 -1
 - data/tweetwine.gemspec +5 -4
 - metadata +122 -97
 - data/test/helper.rb +0 -60
 - data/test/unit/helper.rb +0 -108
 - data/test/unit/tweet_helper.rb +0 -95
 
    
        metadata
    CHANGED
    
    | 
         @@ -1,129 +1,140 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification 
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: tweetwine
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version 
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.3
         
     | 
| 
       4 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: 0.4.2
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
     | 
    
         
            -
            authors: 
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Tuomas Kareinen
         
     | 
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2011-10-31 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
15 
     | 
    
         
             
              name: oauth
         
     | 
| 
       17 
     | 
    
         
            -
               
     | 
| 
       18 
     | 
    
         
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &2152362380 !ruby/object:Gem::Requirement
         
     | 
| 
       19 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       20 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
       21 
19 
     | 
    
         
             
                - - ~>
         
     | 
| 
       22 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       23 
21 
     | 
    
         
             
                    version: 0.4.4
         
     | 
| 
       24 
22 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       25 
     | 
    
         
            -
              version_requirements: *id001
         
     | 
| 
       26 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       27 
     | 
    
         
            -
              name: gem-man
         
     | 
| 
       28 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       29 
     | 
    
         
            -
               
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *2152362380
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: gem-man
         
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &2152361800 !ruby/object:Gem::Requirement
         
     | 
| 
       30 
28 
     | 
    
         
             
                none: false
         
     | 
| 
       31 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 29 
     | 
    
         
            +
                requirements:
         
     | 
| 
       32 
30 
     | 
    
         
             
                - - ~>
         
     | 
| 
       33 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
       34 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.3.0
         
     | 
| 
       35 
33 
     | 
    
         
             
              type: :development
         
     | 
| 
       36 
     | 
    
         
            -
              version_requirements: *id002
         
     | 
| 
       37 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       38 
     | 
    
         
            -
              name: minitest
         
     | 
| 
       39 
34 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       40 
     | 
    
         
            -
               
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *2152361800
         
     | 
| 
      
 36 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 37 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &2152361280 !ruby/object:Gem::Requirement
         
     | 
| 
       41 
39 
     | 
    
         
             
                none: false
         
     | 
| 
       42 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 40 
     | 
    
         
            +
                requirements:
         
     | 
| 
       43 
41 
     | 
    
         
             
                - - ~>
         
     | 
| 
       44 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
       45 
     | 
    
         
            -
                    version: 2. 
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: 2.4.0
         
     | 
| 
       46 
44 
     | 
    
         
             
              type: :development
         
     | 
| 
       47 
     | 
    
         
            -
              version_requirements: *id003
         
     | 
| 
       48 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       49 
     | 
    
         
            -
              name: mocha
         
     | 
| 
       50 
45 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       51 
     | 
    
         
            -
               
     | 
| 
      
 46 
     | 
    
         
            +
              version_requirements: *2152361280
         
     | 
| 
      
 47 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 48 
     | 
    
         
            +
              name: mocha
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirement: &2152360780 !ruby/object:Gem::Requirement
         
     | 
| 
       52 
50 
     | 
    
         
             
                none: false
         
     | 
| 
       53 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
       54 
52 
     | 
    
         
             
                - - ~>
         
     | 
| 
       55 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       56 
54 
     | 
    
         
             
                    version: 0.9.12
         
     | 
| 
       57 
55 
     | 
    
         
             
              type: :development
         
     | 
| 
       58 
     | 
    
         
            -
              version_requirements: *id004
         
     | 
| 
       59 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       60 
     | 
    
         
            -
              name: open4
         
     | 
| 
       61 
56 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       62 
     | 
    
         
            -
               
     | 
| 
      
 57 
     | 
    
         
            +
              version_requirements: *2152360780
         
     | 
| 
      
 58 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 59 
     | 
    
         
            +
              name: open4
         
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: &2152360220 !ruby/object:Gem::Requirement
         
     | 
| 
       63 
61 
     | 
    
         
             
                none: false
         
     | 
| 
       64 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 62 
     | 
    
         
            +
                requirements:
         
     | 
| 
       65 
63 
     | 
    
         
             
                - - ~>
         
     | 
| 
       66 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 64 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       67 
65 
     | 
    
         
             
                    version: 1.0.1
         
     | 
| 
       68 
66 
     | 
    
         
             
              type: :development
         
     | 
| 
       69 
     | 
    
         
            -
              version_requirements: *id005
         
     | 
| 
       70 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       71 
     | 
    
         
            -
              name: rake
         
     | 
| 
       72 
67 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       73 
     | 
    
         
            -
               
     | 
| 
      
 68 
     | 
    
         
            +
              version_requirements: *2152360220
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: perftools.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: &2152350500 !ruby/object:Gem::Requirement
         
     | 
| 
       74 
72 
     | 
    
         
             
                none: false
         
     | 
| 
       75 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 73 
     | 
    
         
            +
                requirements:
         
     | 
| 
       76 
74 
     | 
    
         
             
                - - ~>
         
     | 
| 
       77 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 75 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 76 
     | 
    
         
            +
                    version: 0.5.6
         
     | 
| 
      
 77 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 78 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 79 
     | 
    
         
            +
              version_requirements: *2152350500
         
     | 
| 
      
 80 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 81 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 82 
     | 
    
         
            +
              requirement: &2152349660 !ruby/object:Gem::Requirement
         
     | 
| 
      
 83 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 84 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 85 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 86 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       78 
87 
     | 
    
         
             
                    version: 0.8.7
         
     | 
| 
       79 
88 
     | 
    
         
             
              type: :development
         
     | 
| 
       80 
     | 
    
         
            -
              version_requirements: *id006
         
     | 
| 
       81 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       82 
     | 
    
         
            -
              name: ronn
         
     | 
| 
       83 
89 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       84 
     | 
    
         
            -
               
     | 
| 
      
 90 
     | 
    
         
            +
              version_requirements: *2152349660
         
     | 
| 
      
 91 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 92 
     | 
    
         
            +
              name: ronn
         
     | 
| 
      
 93 
     | 
    
         
            +
              requirement: &2152348480 !ruby/object:Gem::Requirement
         
     | 
| 
       85 
94 
     | 
    
         
             
                none: false
         
     | 
| 
       86 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 95 
     | 
    
         
            +
                requirements:
         
     | 
| 
       87 
96 
     | 
    
         
             
                - - ~>
         
     | 
| 
       88 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 97 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       89 
98 
     | 
    
         
             
                    version: 0.7.3
         
     | 
| 
       90 
99 
     | 
    
         
             
              type: :development
         
     | 
| 
       91 
     | 
    
         
            -
              version_requirements: *id007
         
     | 
| 
       92 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       93 
     | 
    
         
            -
              name: timecop
         
     | 
| 
       94 
100 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       95 
     | 
    
         
            -
               
     | 
| 
      
 101 
     | 
    
         
            +
              version_requirements: *2152348480
         
     | 
| 
      
 102 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 103 
     | 
    
         
            +
              name: timecop
         
     | 
| 
      
 104 
     | 
    
         
            +
              requirement: &2152347240 !ruby/object:Gem::Requirement
         
     | 
| 
       96 
105 
     | 
    
         
             
                none: false
         
     | 
| 
       97 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 106 
     | 
    
         
            +
                requirements:
         
     | 
| 
       98 
107 
     | 
    
         
             
                - - ~>
         
     | 
| 
       99 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
      
 108 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
       100 
109 
     | 
    
         
             
                    version: 0.3.5
         
     | 
| 
       101 
110 
     | 
    
         
             
              type: :development
         
     | 
| 
       102 
     | 
    
         
            -
              version_requirements: *id008
         
     | 
| 
       103 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       104 
     | 
    
         
            -
              name: webmock
         
     | 
| 
       105 
111 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       106 
     | 
    
         
            -
               
     | 
| 
      
 112 
     | 
    
         
            +
              version_requirements: *2152347240
         
     | 
| 
      
 113 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 114 
     | 
    
         
            +
              name: webmock
         
     | 
| 
      
 115 
     | 
    
         
            +
              requirement: &2152346240 !ruby/object:Gem::Requirement
         
     | 
| 
       107 
116 
     | 
    
         
             
                none: false
         
     | 
| 
       108 
     | 
    
         
            -
                requirements: 
     | 
| 
      
 117 
     | 
    
         
            +
                requirements:
         
     | 
| 
       109 
118 
     | 
    
         
             
                - - ~>
         
     | 
| 
       110 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
       111 
     | 
    
         
            -
                    version: 1. 
     | 
| 
      
 119 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 120 
     | 
    
         
            +
                    version: 1.7.7
         
     | 
| 
       112 
121 
     | 
    
         
             
              type: :development
         
     | 
| 
       113 
     | 
    
         
            -
               
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 122 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 123 
     | 
    
         
            +
              version_requirements: *2152346240
         
     | 
| 
      
 124 
     | 
    
         
            +
            description: ! 'A simple but tasty Twitter agent for command line use, designed for
         
     | 
| 
      
 125 
     | 
    
         
            +
              quickly
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
       116 
127 
     | 
    
         
             
              showing the latest tweets.
         
     | 
| 
       117 
128 
     | 
    
         | 
| 
      
 129 
     | 
    
         
            +
            '
         
     | 
| 
       118 
130 
     | 
    
         
             
            email: tkareine@gmail.com
         
     | 
| 
       119 
     | 
    
         
            -
            executables: 
     | 
| 
      
 131 
     | 
    
         
            +
            executables:
         
     | 
| 
       120 
132 
     | 
    
         
             
            - tweetwine
         
     | 
| 
       121 
133 
     | 
    
         
             
            extensions: []
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
            extra_rdoc_files: 
         
     | 
| 
      
 134 
     | 
    
         
            +
            extra_rdoc_files:
         
     | 
| 
       124 
135 
     | 
    
         
             
            - CHANGELOG.rdoc
         
     | 
| 
       125 
136 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       126 
     | 
    
         
            -
            files: 
     | 
| 
      
 137 
     | 
    
         
            +
            files:
         
     | 
| 
       127 
138 
     | 
    
         
             
            - .gitignore
         
     | 
| 
       128 
139 
     | 
    
         
             
            - CHANGELOG.rdoc
         
     | 
| 
       129 
140 
     | 
    
         
             
            - Gemfile
         
     | 
| 
         @@ -131,6 +142,7 @@ files: 
     | 
|
| 
       131 
142 
     | 
    
         
             
            - README.md
         
     | 
| 
       132 
143 
     | 
    
         
             
            - RELEASING.txt
         
     | 
| 
       133 
144 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 145 
     | 
    
         
            +
            - benchmark/home_bm.rb
         
     | 
| 
       134 
146 
     | 
    
         
             
            - bin/tweetwine
         
     | 
| 
       135 
147 
     | 
    
         
             
            - contrib/tweetwine-completion.bash
         
     | 
| 
       136 
148 
     | 
    
         
             
            - lib/tweetwine.rb
         
     | 
| 
         @@ -166,10 +178,8 @@ files: 
     | 
|
| 
       166 
178 
     | 
    
         
             
            - test/fixture/update_without_urls.json
         
     | 
| 
       167 
179 
     | 
    
         
             
            - test/fixture/user.json
         
     | 
| 
       168 
180 
     | 
    
         
             
            - test/fixture/users.json
         
     | 
| 
       169 
     | 
    
         
            -
            - test/helper.rb
         
     | 
| 
       170 
181 
     | 
    
         
             
            - test/integration/authorization_test.rb
         
     | 
| 
       171 
182 
     | 
    
         
             
            - test/integration/global_options_test.rb
         
     | 
| 
       172 
     | 
    
         
            -
            - test/integration/helper.rb
         
     | 
| 
       173 
183 
     | 
    
         
             
            - test/integration/invalid_config_file_test.rb
         
     | 
| 
       174 
184 
     | 
    
         
             
            - test/integration/search_statuses_test.rb
         
     | 
| 
       175 
185 
     | 
    
         
             
            - test/integration/show_followers_test.rb
         
     | 
| 
         @@ -180,17 +190,24 @@ files: 
     | 
|
| 
       180 
190 
     | 
    
         
             
            - test/integration/update_status_test.rb
         
     | 
| 
       181 
191 
     | 
    
         
             
            - test/integration/use_http_proxy_test.rb
         
     | 
| 
       182 
192 
     | 
    
         
             
            - test/integration/user_help_test.rb
         
     | 
| 
      
 193 
     | 
    
         
            +
            - test/support/assertions.rb
         
     | 
| 
      
 194 
     | 
    
         
            +
            - test/support/common.rb
         
     | 
| 
      
 195 
     | 
    
         
            +
            - test/support/common_helpers.rb
         
     | 
| 
      
 196 
     | 
    
         
            +
            - test/support/doubles.rb
         
     | 
| 
      
 197 
     | 
    
         
            +
            - test/support/integration_test_case.rb
         
     | 
| 
      
 198 
     | 
    
         
            +
            - test/support/mocha_integration.rb
         
     | 
| 
      
 199 
     | 
    
         
            +
            - test/support/tweets.rb
         
     | 
| 
      
 200 
     | 
    
         
            +
            - test/support/unit_test_case.rb
         
     | 
| 
      
 201 
     | 
    
         
            +
            - test/support/webmock_integration.rb
         
     | 
| 
       183 
202 
     | 
    
         
             
            - test/unit/character_encoding_test.rb
         
     | 
| 
       184 
203 
     | 
    
         
             
            - test/unit/cli_test.rb
         
     | 
| 
       185 
204 
     | 
    
         
             
            - test/unit/config_test.rb
         
     | 
| 
       186 
     | 
    
         
            -
            - test/unit/helper.rb
         
     | 
| 
       187 
205 
     | 
    
         
             
            - test/unit/http_test.rb
         
     | 
| 
       188 
206 
     | 
    
         
             
            - test/unit/oauth_test.rb
         
     | 
| 
       189 
207 
     | 
    
         
             
            - test/unit/obfuscate_test.rb
         
     | 
| 
       190 
208 
     | 
    
         
             
            - test/unit/option_parser_test.rb
         
     | 
| 
       191 
209 
     | 
    
         
             
            - test/unit/promise_test.rb
         
     | 
| 
       192 
210 
     | 
    
         
             
            - test/unit/support_test.rb
         
     | 
| 
       193 
     | 
    
         
            -
            - test/unit/tweet_helper.rb
         
     | 
| 
       194 
211 
     | 
    
         
             
            - test/unit/tweet_test.rb
         
     | 
| 
       195 
212 
     | 
    
         
             
            - test/unit/twitter_test.rb
         
     | 
| 
       196 
213 
     | 
    
         
             
            - test/unit/ui_test.rb
         
     | 
| 
         @@ -200,37 +217,40 @@ files: 
     | 
|
| 
       200 
217 
     | 
    
         
             
            - man/tweetwine.7
         
     | 
| 
       201 
218 
     | 
    
         
             
            homepage: https://github.com/tkareine/tweetwine
         
     | 
| 
       202 
219 
     | 
    
         
             
            licenses: []
         
     | 
| 
      
 220 
     | 
    
         
            +
            post_install_message: ! '
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
              Tweetwine requires a JSON parser library. Ruby 1.9 comes bundled with one by
         
     | 
| 
       203 
223 
     | 
    
         | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
      
 224 
     | 
    
         
            +
              default. For Ruby 1.8, you can install ''json'' gem, for example.
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
            '
         
     | 
| 
      
 228 
     | 
    
         
            +
            rdoc_options:
         
     | 
| 
       208 
229 
     | 
    
         
             
            - --title
         
     | 
| 
       209 
     | 
    
         
            -
            - tweetwine 0.4. 
     | 
| 
      
 230 
     | 
    
         
            +
            - tweetwine 0.4.3
         
     | 
| 
       210 
231 
     | 
    
         
             
            - --exclude
         
     | 
| 
       211 
232 
     | 
    
         
             
            - test
         
     | 
| 
       212 
     | 
    
         
            -
            require_paths: 
     | 
| 
      
 233 
     | 
    
         
            +
            require_paths:
         
     | 
| 
       213 
234 
     | 
    
         
             
            - lib
         
     | 
| 
       214 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement 
     | 
| 
      
 235 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       215 
236 
     | 
    
         
             
              none: false
         
     | 
| 
       216 
     | 
    
         
            -
              requirements: 
     | 
| 
       217 
     | 
    
         
            -
              - -  
     | 
| 
       218 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       219 
     | 
    
         
            -
                  version:  
     | 
| 
       220 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
| 
      
 237 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 238 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 239 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 240 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 241 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       221 
242 
     | 
    
         
             
              none: false
         
     | 
| 
       222 
     | 
    
         
            -
              requirements: 
     | 
| 
       223 
     | 
    
         
            -
              - -  
     | 
| 
       224 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       225 
     | 
    
         
            -
                  version:  
     | 
| 
      
 243 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 244 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 245 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 246 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       226 
247 
     | 
    
         
             
            requirements: []
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
248 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       229 
     | 
    
         
            -
            rubygems_version: 1.8. 
     | 
| 
      
 249 
     | 
    
         
            +
            rubygems_version: 1.8.10
         
     | 
| 
       230 
250 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       231 
251 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       232 
252 
     | 
    
         
             
            summary: Tweetwine shows the latest tweets from the command line quickly.
         
     | 
| 
       233 
     | 
    
         
            -
            test_files: 
     | 
| 
      
 253 
     | 
    
         
            +
            test_files:
         
     | 
| 
       234 
254 
     | 
    
         
             
            - test/fixture/config_integration.yaml
         
     | 
| 
       235 
255 
     | 
    
         
             
            - test/fixture/config_unit.yaml
         
     | 
| 
       236 
256 
     | 
    
         
             
            - test/fixture/home.json
         
     | 
| 
         @@ -244,10 +264,8 @@ test_files: 
     | 
|
| 
       244 
264 
     | 
    
         
             
            - test/fixture/update_without_urls.json
         
     | 
| 
       245 
265 
     | 
    
         
             
            - test/fixture/user.json
         
     | 
| 
       246 
266 
     | 
    
         
             
            - test/fixture/users.json
         
     | 
| 
       247 
     | 
    
         
            -
            - test/helper.rb
         
     | 
| 
       248 
267 
     | 
    
         
             
            - test/integration/authorization_test.rb
         
     | 
| 
       249 
268 
     | 
    
         
             
            - test/integration/global_options_test.rb
         
     | 
| 
       250 
     | 
    
         
            -
            - test/integration/helper.rb
         
     | 
| 
       251 
269 
     | 
    
         
             
            - test/integration/invalid_config_file_test.rb
         
     | 
| 
       252 
270 
     | 
    
         
             
            - test/integration/search_statuses_test.rb
         
     | 
| 
       253 
271 
     | 
    
         
             
            - test/integration/show_followers_test.rb
         
     | 
| 
         @@ -258,17 +276,24 @@ test_files: 
     | 
|
| 
       258 
276 
     | 
    
         
             
            - test/integration/update_status_test.rb
         
     | 
| 
       259 
277 
     | 
    
         
             
            - test/integration/use_http_proxy_test.rb
         
     | 
| 
       260 
278 
     | 
    
         
             
            - test/integration/user_help_test.rb
         
     | 
| 
      
 279 
     | 
    
         
            +
            - test/support/assertions.rb
         
     | 
| 
      
 280 
     | 
    
         
            +
            - test/support/common.rb
         
     | 
| 
      
 281 
     | 
    
         
            +
            - test/support/common_helpers.rb
         
     | 
| 
      
 282 
     | 
    
         
            +
            - test/support/doubles.rb
         
     | 
| 
      
 283 
     | 
    
         
            +
            - test/support/integration_test_case.rb
         
     | 
| 
      
 284 
     | 
    
         
            +
            - test/support/mocha_integration.rb
         
     | 
| 
      
 285 
     | 
    
         
            +
            - test/support/tweets.rb
         
     | 
| 
      
 286 
     | 
    
         
            +
            - test/support/unit_test_case.rb
         
     | 
| 
      
 287 
     | 
    
         
            +
            - test/support/webmock_integration.rb
         
     | 
| 
       261 
288 
     | 
    
         
             
            - test/unit/character_encoding_test.rb
         
     | 
| 
       262 
289 
     | 
    
         
             
            - test/unit/cli_test.rb
         
     | 
| 
       263 
290 
     | 
    
         
             
            - test/unit/config_test.rb
         
     | 
| 
       264 
     | 
    
         
            -
            - test/unit/helper.rb
         
     | 
| 
       265 
291 
     | 
    
         
             
            - test/unit/http_test.rb
         
     | 
| 
       266 
292 
     | 
    
         
             
            - test/unit/oauth_test.rb
         
     | 
| 
       267 
293 
     | 
    
         
             
            - test/unit/obfuscate_test.rb
         
     | 
| 
       268 
294 
     | 
    
         
             
            - test/unit/option_parser_test.rb
         
     | 
| 
       269 
295 
     | 
    
         
             
            - test/unit/promise_test.rb
         
     | 
| 
       270 
296 
     | 
    
         
             
            - test/unit/support_test.rb
         
     | 
| 
       271 
     | 
    
         
            -
            - test/unit/tweet_helper.rb
         
     | 
| 
       272 
297 
     | 
    
         
             
            - test/unit/tweet_test.rb
         
     | 
| 
       273 
298 
     | 
    
         
             
            - test/unit/twitter_test.rb
         
     | 
| 
       274 
299 
     | 
    
         
             
            - test/unit/ui_test.rb
         
     | 
    
        data/test/helper.rb
    DELETED
    
    | 
         @@ -1,60 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # coding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            %w{
         
     | 
| 
       4 
     | 
    
         
            -
              minitest/spec
         
     | 
| 
       5 
     | 
    
         
            -
              tweetwine
         
     | 
| 
       6 
     | 
    
         
            -
              webmock
         
     | 
| 
       7 
     | 
    
         
            -
            }.each { |lib| require lib }
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            MiniTest::Unit.autorun
         
     | 
| 
       10 
     | 
    
         
            -
            WebMock.disable_net_connect!
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            module Tweetwine
         
     | 
| 
       13 
     | 
    
         
            -
              module Test
         
     | 
| 
       14 
     | 
    
         
            -
                module CommonHelper
         
     | 
| 
       15 
     | 
    
         
            -
                  def file_mode(file)
         
     | 
| 
       16 
     | 
    
         
            -
                    File.stat(file).mode & 0777
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  def fixture_path(filename)
         
     | 
| 
       20 
     | 
    
         
            -
                    File.join(File.dirname(__FILE__), 'fixture', filename)
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  def fixture_file(filename)
         
     | 
| 
       24 
     | 
    
         
            -
                    File.open(fixture_path(filename)) do |f|
         
     | 
| 
       25 
     | 
    
         
            -
                      f.readlines.join("\n")
         
     | 
| 
       26 
     | 
    
         
            -
                    end
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  def tmp_env(vars = {})
         
     | 
| 
       30 
     | 
    
         
            -
                    originals = {}
         
     | 
| 
       31 
     | 
    
         
            -
                    vars.each_pair do |key, value|
         
     | 
| 
       32 
     | 
    
         
            -
                      key = key.to_s
         
     | 
| 
       33 
     | 
    
         
            -
                      originals[key] = ENV[key]
         
     | 
| 
       34 
     | 
    
         
            -
                      ENV[key] = value
         
     | 
| 
       35 
     | 
    
         
            -
                    end
         
     | 
| 
       36 
     | 
    
         
            -
                    yield
         
     | 
| 
       37 
     | 
    
         
            -
                  ensure
         
     | 
| 
       38 
     | 
    
         
            -
                    originals.each_pair do |key, value|
         
     | 
| 
       39 
     | 
    
         
            -
                      ENV[key] = value
         
     | 
| 
       40 
     | 
    
         
            -
                    end
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                  def tmp_kcode(val)
         
     | 
| 
       44 
     | 
    
         
            -
                    original = $KCODE
         
     | 
| 
       45 
     | 
    
         
            -
                    $KCODE = val
         
     | 
| 
       46 
     | 
    
         
            -
                    yield
         
     | 
| 
       47 
     | 
    
         
            -
                  ensure
         
     | 
| 
       48 
     | 
    
         
            -
                    $KCODE = original
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                module WebMockIntegration
         
     | 
| 
       53 
     | 
    
         
            -
                  include WebMock::API
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                  def teardown
         
     | 
| 
       56 
     | 
    
         
            -
                    WebMock.reset!
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
            end
         
     | 
    
        data/test/unit/helper.rb
    DELETED
    
    | 
         @@ -1,108 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # coding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'helper'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'mocha'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Mocha::Configuration.prevent(:stubbing_non_existent_method)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            module Tweetwine::Test
         
     | 
| 
       9 
     | 
    
         
            -
              module Unit
         
     | 
| 
       10 
     | 
    
         
            -
                module Assertions
         
     | 
| 
       11 
     | 
    
         
            -
                  # Asserts whether an Enumeration-like object contains all the elements.
         
     | 
| 
       12 
     | 
    
         
            -
                  # Fails unless +actual+ contains the same elements as +expected+,
         
     | 
| 
       13 
     | 
    
         
            -
                  # ignoring the order of the elements.
         
     | 
| 
       14 
     | 
    
         
            -
                  def assert_contains_exactly(expected, actual, msg_diff_size = nil, msg_diff_elems = nil)
         
     | 
| 
       15 
     | 
    
         
            -
                    assert_equal(expected.size, actual.size, message(msg_diff_size) {
         
     | 
| 
       16 
     | 
    
         
            -
                      'Expected %s to be of same size as %s' % [actual.inspect, expected.inspect]
         
     | 
| 
       17 
     | 
    
         
            -
                    })
         
     | 
| 
       18 
     | 
    
         
            -
                    assert(enumerable_minus_each_element(actual, expected).empty?, message(msg_diff_elems) {
         
     | 
| 
       19 
     | 
    
         
            -
                      'Expected %s to contain all the elements of %s' % [actual.inspect, expected.inspect]
         
     | 
| 
       20 
     | 
    
         
            -
                    })
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  # Fails unless +str+ is a full match to +regex+.
         
     | 
| 
       24 
     | 
    
         
            -
                  def assert_full_match(regex, str, msg = nil)
         
     | 
| 
       25 
     | 
    
         
            -
                    match_data = regex.match(str)
         
     | 
| 
       26 
     | 
    
         
            -
                    assert(str == match_data.to_s, message(msg) {
         
     | 
| 
       27 
     | 
    
         
            -
                      'Expected %s to be a full match to %s' % [str, regex.inspect]
         
     | 
| 
       28 
     | 
    
         
            -
                    })
         
     | 
| 
       29 
     | 
    
         
            -
                  end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  # Fails if +str+ is a full match to +regex+.
         
     | 
| 
       32 
     | 
    
         
            -
                  def assert_no_full_match(regex, str, msg = nil)
         
     | 
| 
       33 
     | 
    
         
            -
                    match_data = regex.match(str)
         
     | 
| 
       34 
     | 
    
         
            -
                    assert(str != match_data.to_s, message(msg) {
         
     | 
| 
       35 
     | 
    
         
            -
                      'Expected %s not to be a full match to %s' % [str, regex.inspect]
         
     | 
| 
       36 
     | 
    
         
            -
                    })
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                  # Fails unless +fun.call(*args)+ is equal to +expected+ and
         
     | 
| 
       40 
     | 
    
         
            -
                  # +fun.call(*args)+ is equal to +fun.call(*args.reverse)+.
         
     | 
| 
       41 
     | 
    
         
            -
                  def assert_commutative(expected, args, msg_not_expected = nil, msg_not_commutative = nil, &fun)
         
     | 
| 
       42 
     | 
    
         
            -
                    left_args = args
         
     | 
| 
       43 
     | 
    
         
            -
                    left_actual = fun.call(left_args)
         
     | 
| 
       44 
     | 
    
         
            -
                    assert_equal(expected, left_actual, message(msg_not_expected) {
         
     | 
| 
       45 
     | 
    
         
            -
                      'Expected %s, not %s' % [expected.inspect, left_actual.inspect]
         
     | 
| 
       46 
     | 
    
         
            -
                    })
         
     | 
| 
       47 
     | 
    
         
            -
                    right_args = args.reverse
         
     | 
| 
       48 
     | 
    
         
            -
                    right_actual = fun.call(*right_args)
         
     | 
| 
       49 
     | 
    
         
            -
                    assert_equal(left_actual, right_actual, message(msg_not_commutative) {
         
     | 
| 
       50 
     | 
    
         
            -
                      'Expected fun%s => %s to be commutative with fun%s => %s' %
         
     | 
| 
       51 
     | 
    
         
            -
                        [left_args.inspect, left_actual.inspect, right_args.inspect, right_actual.inspect]
         
     | 
| 
       52 
     | 
    
         
            -
                    })
         
     | 
| 
       53 
     | 
    
         
            -
                  end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                  private
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                  def enumerable_minus_each_element(enumerable, elements)
         
     | 
| 
       58 
     | 
    
         
            -
                    remaining = enumerable.dup.to_a
         
     | 
| 
       59 
     | 
    
         
            -
                    elements.each do |e|
         
     | 
| 
       60 
     | 
    
         
            -
                      index = remaining.index(e)
         
     | 
| 
       61 
     | 
    
         
            -
                      remaining.delete_at(index) if index
         
     | 
| 
       62 
     | 
    
         
            -
                    end
         
     | 
| 
       63 
     | 
    
         
            -
                    remaining
         
     | 
| 
       64 
     | 
    
         
            -
                  end
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                module Doubles
         
     | 
| 
       68 
     | 
    
         
            -
                  def mock_config
         
     | 
| 
       69 
     | 
    
         
            -
                    @config = mock('Config')
         
     | 
| 
       70 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:config).returns(@config)
         
     | 
| 
       71 
     | 
    
         
            -
                  end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  def mock_http
         
     | 
| 
       74 
     | 
    
         
            -
                    @http = mock('Http')
         
     | 
| 
       75 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:http).returns(@http)
         
     | 
| 
       76 
     | 
    
         
            -
                  end
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                  def mock_oauth
         
     | 
| 
       79 
     | 
    
         
            -
                    @oauth = mock('OAuth')
         
     | 
| 
       80 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:oauth).returns(@oauth)
         
     | 
| 
       81 
     | 
    
         
            -
                  end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                  def mock_ui
         
     | 
| 
       84 
     | 
    
         
            -
                    @ui = mock('UI')
         
     | 
| 
       85 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:ui).returns(@ui)
         
     | 
| 
       86 
     | 
    
         
            -
                  end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                  def mock_url_shortener
         
     | 
| 
       89 
     | 
    
         
            -
                    @url_shortener = mock('UrlShortener')
         
     | 
| 
       90 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:url_shortener).returns(@url_shortener)
         
     | 
| 
       91 
     | 
    
         
            -
                  end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
                  def stub_config(options = {})
         
     | 
| 
       94 
     | 
    
         
            -
                    @config = options
         
     | 
| 
       95 
     | 
    
         
            -
                    Tweetwine::CLI.stubs(:config).returns(@config)
         
     | 
| 
       96 
     | 
    
         
            -
                  end
         
     | 
| 
       97 
     | 
    
         
            -
                end
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                class TestCase < MiniTest::Spec
         
     | 
| 
       100 
     | 
    
         
            -
                  include WebMockIntegration
         
     | 
| 
       101 
     | 
    
         
            -
                  include Tweetwine
         
     | 
| 
       102 
     | 
    
         
            -
                  include Assertions
         
     | 
| 
       103 
     | 
    
         
            -
                  include Doubles
         
     | 
| 
       104 
     | 
    
         
            -
                  include Tweetwine::Test::CommonHelper
         
     | 
| 
       105 
     | 
    
         
            -
                  extend Tweetwine::Test::CommonHelper
         
     | 
| 
       106 
     | 
    
         
            -
                end
         
     | 
| 
       107 
     | 
    
         
            -
              end
         
     | 
| 
       108 
     | 
    
         
            -
            end
         
     | 
    
        data/test/unit/tweet_helper.rb
    DELETED
    
    | 
         @@ -1,95 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # coding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'timecop'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module Tweetwine::Test::Unit
         
     | 
| 
       6 
     | 
    
         
            -
              module TweetHelper
         
     | 
| 
       7 
     | 
    
         
            -
                FIELD_PATHS = {
         
     | 
| 
       8 
     | 
    
         
            -
                  :from_user  => %w{screen_name},
         
     | 
| 
       9 
     | 
    
         
            -
                  :to_user    => %w{status in_reply_to_screen_name},
         
     | 
| 
       10 
     | 
    
         
            -
                  :retweet    => %w{retweeted_status},
         
     | 
| 
       11 
     | 
    
         
            -
                  :created_at => %w{status created_at},
         
     | 
| 
       12 
     | 
    
         
            -
                  :status     => %w{status text}
         
     | 
| 
       13 
     | 
    
         
            -
                }.freeze
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                DEFAULT_TIMESTAMP = Time.utc(2011, 'feb', 17, 22, 28, 0)
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                DEFAULT_FIELD_VALUES = {
         
     | 
| 
       18 
     | 
    
         
            -
                  :from_user  => 'fred',
         
     | 
| 
       19 
     | 
    
         
            -
                  :to_user    => nil,
         
     | 
| 
       20 
     | 
    
         
            -
                  :retweet    => nil,
         
     | 
| 
       21 
     | 
    
         
            -
                  :created_at => DEFAULT_TIMESTAMP.iso8601,
         
     | 
| 
       22 
     | 
    
         
            -
                  :status     => nil
         
     | 
| 
       23 
     | 
    
         
            -
                }.freeze
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                RECORD_SKELETON = {
         
     | 
| 
       26 
     | 
    
         
            -
                  'screen_name'       => nil,
         
     | 
| 
       27 
     | 
    
         
            -
                  'retweeted_status'  => nil,
         
     | 
| 
       28 
     | 
    
         
            -
                  'status'            => {
         
     | 
| 
       29 
     | 
    
         
            -
                    'in_reply_to_screen_name' => nil,
         
     | 
| 
       30 
     | 
    
         
            -
                    'created_at'              => nil,
         
     | 
| 
       31 
     | 
    
         
            -
                    'text'                    => nil
         
     | 
| 
       32 
     | 
    
         
            -
                  }.freeze
         
     | 
| 
       33 
     | 
    
         
            -
                }.freeze
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                def create_record(fields = {})
         
     | 
| 
       36 
     | 
    
         
            -
                  record = create_nonrt_record(nonrt_fields(fields))
         
     | 
| 
       37 
     | 
    
         
            -
                  modify_to_rt_record(record, fields[:rt_user]) if fields[:rt_user]
         
     | 
| 
       38 
     | 
    
         
            -
                  record
         
     | 
| 
       39 
     | 
    
         
            -
                end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                def create_tweet(fields = {})
         
     | 
| 
       42 
     | 
    
         
            -
                  Tweetwine::Tweet.new(create_record(fields), FIELD_PATHS)
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                def at_default_time(&block)
         
     | 
| 
       46 
     | 
    
         
            -
                  Timecop.freeze(TweetHelper::DEFAULT_TIMESTAMP, &block)
         
     | 
| 
       47 
     | 
    
         
            -
                end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                def create_timestamp(minus_seconds)
         
     | 
| 
       50 
     | 
    
         
            -
                  (TweetHelper::DEFAULT_TIMESTAMP - minus_seconds).iso8601
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                private
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                def find_hash_of_field_path(hash, path)
         
     | 
| 
       56 
     | 
    
         
            -
                  path = [path] unless path.is_a? Array
         
     | 
| 
       57 
     | 
    
         
            -
                  if path.size > 1
         
     | 
| 
       58 
     | 
    
         
            -
                    hash_path, field = path[0..-2], path.last
         
     | 
| 
       59 
     | 
    
         
            -
                    [Tweetwine::Support.find_hash_path(hash, hash_path), field]
         
     | 
| 
       60 
     | 
    
         
            -
                  else
         
     | 
| 
       61 
     | 
    
         
            -
                    [hash, path.first]
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                def nonrt_fields(fields)
         
     | 
| 
       66 
     | 
    
         
            -
                  DEFAULT_FIELD_VALUES.merge(fields.reject { |(k, v)| k == :rt_user })
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                def create_nonrt_record(fields)
         
     | 
| 
       70 
     | 
    
         
            -
                  FIELD_PATHS.inject(deep_copy(RECORD_SKELETON)) do |result, (path_name, path_actual)|
         
     | 
| 
       71 
     | 
    
         
            -
                    hash, field = find_hash_of_field_path(result, path_actual)
         
     | 
| 
       72 
     | 
    
         
            -
                    hash[field] = fields[path_name]
         
     | 
| 
       73 
     | 
    
         
            -
                    result
         
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                def modify_to_rt_record(record, rt_user)
         
     | 
| 
       78 
     | 
    
         
            -
                  rt_hash, rt_field = find_hash_of_field_path(record, FIELD_PATHS[:retweet])
         
     | 
| 
       79 
     | 
    
         
            -
                  fr_hash, fr_field = find_hash_of_field_path(record, FIELD_PATHS[:from_user])
         
     | 
| 
       80 
     | 
    
         
            -
                  st_hash, st_field = find_hash_of_field_path(record, FIELD_PATHS[:status])
         
     | 
| 
       81 
     | 
    
         
            -
                  rt_hash[rt_field] = {
         
     | 
| 
       82 
     | 
    
         
            -
                    fr_field => fr_hash[fr_field].dup,
         
     | 
| 
       83 
     | 
    
         
            -
                    'status' => st_hash.dup
         
     | 
| 
       84 
     | 
    
         
            -
                  }
         
     | 
| 
       85 
     | 
    
         
            -
                  fr_hash[fr_field] = rt_user
         
     | 
| 
       86 
     | 
    
         
            -
                  st_hash[st_field] = 'retweeted status text. you should not see me.'
         
     | 
| 
       87 
     | 
    
         
            -
                  cr_hash, cr_field = find_hash_of_field_path(record, FIELD_PATHS[:created_at])
         
     | 
| 
       88 
     | 
    
         
            -
                  cr_hash[cr_field] = 'old created timestamp. you should not see me.'
         
     | 
| 
       89 
     | 
    
         
            -
                end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                def deep_copy(obj)
         
     | 
| 
       92 
     | 
    
         
            -
                  Marshal.load(Marshal.dump(obj))
         
     | 
| 
       93 
     | 
    
         
            -
                end
         
     | 
| 
       94 
     | 
    
         
            -
              end
         
     | 
| 
       95 
     | 
    
         
            -
            end
         
     |