twterm 1.3.0 → 2.0.0.beta1
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.
- checksums.yaml +4 -4
- data/README.md +14 -18
- data/bin/twterm +1 -1
- data/lib/twterm/app.rb +120 -30
- data/lib/twterm/client.rb +10 -13
- data/lib/twterm/completion_mamanger.rb +11 -6
- data/lib/twterm/direct_message.rb +6 -28
- data/lib/twterm/direct_message_composer.rb +10 -5
- data/lib/twterm/direct_message_manager.rb +5 -6
- data/lib/twterm/event/notification/abstract_notification.rb +27 -0
- data/lib/twterm/event/notification/error.rb +13 -0
- data/lib/twterm/event/notification/info.rb +13 -0
- data/lib/twterm/event/notification/success.rb +13 -0
- data/lib/twterm/event/notification/warning.rb +13 -0
- data/lib/twterm/event_dispatcher.rb +1 -1
- data/lib/twterm/extensions/array.rb +5 -0
- data/lib/twterm/extensions/enumerator/lazy.rb +3 -0
- data/lib/twterm/extensions/string.rb +0 -4
- data/lib/twterm/friendship.rb +1 -85
- data/lib/twterm/image/between.rb +31 -0
- data/lib/twterm/image/blank_line.rb +21 -0
- data/lib/twterm/image/bold.rb +31 -0
- data/lib/twterm/image/brackets.rb +21 -0
- data/lib/twterm/image/color.rb +45 -0
- data/lib/twterm/image/empty.rb +21 -0
- data/lib/twterm/image/horizontal_sequential_image.rb +48 -0
- data/lib/twterm/image/parens.rb +21 -0
- data/lib/twterm/image/string_image.rb +38 -0
- data/lib/twterm/image/vertical_sequential_image.rb +43 -0
- data/lib/twterm/image.rb +107 -0
- data/lib/twterm/key_mapper/abstract_key_mapper.rb +51 -0
- data/lib/twterm/key_mapper/app_key_mapper.rb +13 -0
- data/lib/twterm/key_mapper/cursor_key_mapper.rb +13 -0
- data/lib/twterm/key_mapper/general_key_mapper.rb +18 -0
- data/lib/twterm/key_mapper/no_such_command.rb +20 -0
- data/lib/twterm/key_mapper/no_such_key.rb +16 -0
- data/lib/twterm/key_mapper/status_key_mapper.rb +18 -0
- data/lib/twterm/key_mapper/tab_key_mapper.rb +31 -0
- data/lib/twterm/key_mapper.rb +127 -0
- data/lib/twterm/list.rb +0 -31
- data/lib/twterm/notifier.rb +7 -7
- data/lib/twterm/repository/abstract_entity_repository.rb +41 -0
- data/lib/twterm/repository/abstract_expirable_entity_repository.rb +35 -0
- data/lib/twterm/repository/abstract_repository.rb +64 -0
- data/lib/twterm/repository/direct_message_repository.rb +14 -0
- data/lib/twterm/repository/friendship_repository.rb +108 -0
- data/lib/twterm/repository/hashtag_repository.rb +39 -0
- data/lib/twterm/repository/list_repository.rb +14 -0
- data/lib/twterm/repository/status_repository.rb +36 -0
- data/lib/twterm/repository/user_repository.rb +22 -0
- data/lib/twterm/rest_client.rb +107 -63
- data/lib/twterm/screen.rb +21 -15
- data/lib/twterm/search_query_window.rb +139 -0
- data/lib/twterm/status.rb +14 -108
- data/lib/twterm/streaming_client.rb +13 -12
- data/lib/twterm/tab/base.rb +48 -8
- data/lib/twterm/tab/direct_message/conversation.rb +53 -52
- data/lib/twterm/tab/direct_message/conversation_list.rb +46 -45
- data/lib/twterm/tab/dumpable.rb +3 -3
- data/lib/twterm/tab/key_assignments_cheatsheet.rb +58 -57
- data/lib/twterm/tab/loadable.rb +20 -0
- data/lib/twterm/tab/new/list.rb +32 -43
- data/lib/twterm/tab/new/search.rb +31 -44
- data/lib/twterm/tab/new/start.rb +44 -55
- data/lib/twterm/tab/new/user.rb +15 -12
- data/lib/twterm/tab/rate_limit_status.rb +84 -0
- data/lib/twterm/tab/scrollable.rb +39 -19
- data/lib/twterm/tab/searchable.rb +133 -0
- data/lib/twterm/tab/statuses/base.rb +139 -129
- data/lib/twterm/tab/statuses/conversation.rb +26 -15
- data/lib/twterm/tab/statuses/favorites.rb +10 -8
- data/lib/twterm/tab/statuses/home.rb +10 -9
- data/lib/twterm/tab/statuses/list_timeline.rb +12 -8
- data/lib/twterm/tab/statuses/mentions.rb +17 -11
- data/lib/twterm/tab/statuses/search.rb +8 -5
- data/lib/twterm/tab/statuses/user_timeline.rb +11 -8
- data/lib/twterm/tab/user_list_management.rb +109 -0
- data/lib/twterm/tab/user_tab.rb +125 -126
- data/lib/twterm/tab/users/base.rb +39 -41
- data/lib/twterm/tab/users/followers.rb +9 -6
- data/lib/twterm/tab/users/friends.rb +9 -6
- data/lib/twterm/tab_manager.rb +64 -40
- data/lib/twterm/tweetbox.rb +18 -13
- data/lib/twterm/uri_opener.rb +2 -1
- data/lib/twterm/user.rb +2 -110
- data/lib/twterm/version.rb +1 -1
- data/lib/twterm/view.rb +30 -0
- data/lib/twterm.rb +3 -9
- data/spec/fixtures/status.json +107 -0
- data/spec/fixtures/user.json +102 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/supports/shared_examples/abstract_key_mapper.rb +17 -0
- data/spec/twterm/extension/enumerator/lazy_spec.rb +11 -0
- data/spec/twterm/friendship_spec.rb +0 -102
- data/spec/twterm/image/blank_line_spec.rb +11 -0
- data/spec/twterm/image/brackets_spec.rb +12 -0
- data/spec/twterm/image/color_spec.rb +22 -0
- data/spec/twterm/image/empry_spec.rb +11 -0
- data/spec/twterm/image/horizontal_sequential_image_spec.rb +15 -0
- data/spec/twterm/image/parens_spec.rb +12 -0
- data/spec/twterm/image/string_image_spec.rb +12 -0
- data/spec/twterm/image/vertical_sequential_image_spec.rb +14 -0
- data/spec/twterm/image_spec.rb +65 -0
- data/spec/twterm/key_mapper/abstract_key_mapper_spec.rb +21 -0
- data/spec/twterm/key_mapper/app_key_mapper_spec.rb +7 -0
- data/spec/twterm/key_mapper/status_key_mapper_spec.rb +7 -0
- data/spec/twterm/key_mapper/tab_key_mapper_spec.rb +7 -0
- data/spec/twterm/repository/friendship_repository_spec.rb +108 -0
- data/spec/twterm/status_spec.rb +58 -0
- data/spec/twterm/user_spec.rb +94 -0
- data/twterm.gemspec +13 -10
- metadata +129 -35
- data/lib/twterm/event/notification.rb +0 -33
- data/lib/twterm/extensions/integer.rb +0 -5
- data/lib/twterm/filter_query_window.rb +0 -91
- data/lib/twterm/filterable_list.rb +0 -41
- data/lib/twterm/history/base.rb +0 -21
- data/lib/twterm/history/hashtag.rb +0 -13
- data/lib/twterm/history/savable.rb +0 -37
- data/lib/twterm/history/screen_name.rb +0 -11
- data/lib/twterm/promise.rb +0 -143
@@ -0,0 +1,102 @@
|
|
1
|
+
{
|
2
|
+
"id": 2244994945,
|
3
|
+
"id_str": "2244994945",
|
4
|
+
"name": "TwitterDev",
|
5
|
+
"screen_name": "TwitterDev",
|
6
|
+
"location": "Internet",
|
7
|
+
"profile_location": null,
|
8
|
+
"description": "Developer and Platform Relations @Twitter. We are developer advocates. We can't answer all your questions, but we listen to all of them!",
|
9
|
+
"url": "https://t.co/66w26cua1O",
|
10
|
+
"entities": {
|
11
|
+
"url": {
|
12
|
+
"urls": [
|
13
|
+
{
|
14
|
+
"url": "https://t.co/66w26cua1O",
|
15
|
+
"expanded_url": "https://dev.twitter.com/",
|
16
|
+
"display_url": "dev.twitter.com",
|
17
|
+
"indices": [
|
18
|
+
0,
|
19
|
+
23
|
20
|
+
]
|
21
|
+
}
|
22
|
+
]
|
23
|
+
},
|
24
|
+
"description": {
|
25
|
+
"urls": []
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"protected": false,
|
29
|
+
"followers_count": 429831,
|
30
|
+
"friends_count": 1535,
|
31
|
+
"listed_count": 999,
|
32
|
+
"created_at": "Sat Dec 14 04:35:55 +0000 2013",
|
33
|
+
"favourites_count": 1713,
|
34
|
+
"utc_offset": -25200,
|
35
|
+
"time_zone": "Pacific Time (US & Canada)",
|
36
|
+
"geo_enabled": true,
|
37
|
+
"verified": true,
|
38
|
+
"statuses_count": 2588,
|
39
|
+
"lang": "en",
|
40
|
+
"status": {
|
41
|
+
"created_at": "Tue Aug 30 10:52:20 +0000 2016",
|
42
|
+
"id": 770574870841331700,
|
43
|
+
"id_str": "770574870841331712",
|
44
|
+
"text": "@lesterhan oops! Thanks for pointing that out, looks like the image is no longer available! we will fix in a future doc version! ^AP",
|
45
|
+
"truncated": false,
|
46
|
+
"entities": {
|
47
|
+
"hashtags": [],
|
48
|
+
"symbols": [],
|
49
|
+
"user_mentions": [
|
50
|
+
{
|
51
|
+
"screen_name": "lesterhan",
|
52
|
+
"name": "Lester Han",
|
53
|
+
"id": 126025266,
|
54
|
+
"id_str": "126025266",
|
55
|
+
"indices": [
|
56
|
+
0,
|
57
|
+
10
|
58
|
+
]
|
59
|
+
}
|
60
|
+
],
|
61
|
+
"urls": []
|
62
|
+
},
|
63
|
+
"source": "<a href=\"https://about.twitter.com/products/tweetdeck\" rel=\"nofollow\">TweetDeck</a>",
|
64
|
+
"in_reply_to_status_id": 770332467626672100,
|
65
|
+
"in_reply_to_status_id_str": "770332467626672129",
|
66
|
+
"in_reply_to_user_id": 126025266,
|
67
|
+
"in_reply_to_user_id_str": "126025266",
|
68
|
+
"in_reply_to_screen_name": "lesterhan",
|
69
|
+
"geo": null,
|
70
|
+
"coordinates": null,
|
71
|
+
"place": null,
|
72
|
+
"contributors": null,
|
73
|
+
"is_quote_status": false,
|
74
|
+
"retweet_count": 0,
|
75
|
+
"favorite_count": 0,
|
76
|
+
"favorited": false,
|
77
|
+
"retweeted": false,
|
78
|
+
"lang": "en"
|
79
|
+
},
|
80
|
+
"contributors_enabled": false,
|
81
|
+
"is_translator": false,
|
82
|
+
"is_translation_enabled": false,
|
83
|
+
"profile_background_color": "FFFFFF",
|
84
|
+
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
|
85
|
+
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
|
86
|
+
"profile_background_tile": false,
|
87
|
+
"profile_image_url": "http://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png",
|
88
|
+
"profile_image_url_https": "https://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png",
|
89
|
+
"profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1396995246",
|
90
|
+
"profile_link_color": "0084B4",
|
91
|
+
"profile_sidebar_border_color": "FFFFFF",
|
92
|
+
"profile_sidebar_fill_color": "DDEEF6",
|
93
|
+
"profile_text_color": "333333",
|
94
|
+
"profile_use_background_image": false,
|
95
|
+
"has_extended_profile": false,
|
96
|
+
"default_profile": false,
|
97
|
+
"default_profile_image": false,
|
98
|
+
"following": false,
|
99
|
+
"follow_request_sent": false,
|
100
|
+
"notifications": false,
|
101
|
+
"translator_type": "regular"
|
102
|
+
}
|
data/spec/spec_helper.rb
CHANGED
@@ -4,4 +4,11 @@ RSpec.configure do |config|
|
|
4
4
|
config.order = :random
|
5
5
|
end
|
6
6
|
|
7
|
+
def fixture(path)
|
8
|
+
dir = File.expand_path('../fixtures', __FILE__)
|
9
|
+
File.read("#{dir}/#{path}")
|
10
|
+
end
|
11
|
+
|
12
|
+
Dir['spec/supports/**/*.rb'].each { |f| require File.expand_path(f, __dir__ + '/..') }
|
13
|
+
|
7
14
|
require 'twterm'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'twterm/key_mapper/abstract_key_mapper'
|
2
|
+
|
3
|
+
RSpec.shared_examples Twterm::KeyMapper::AbstractKeyMapper do
|
4
|
+
describe '.commands' do
|
5
|
+
subject { described_class.commands }
|
6
|
+
|
7
|
+
it { is_expected.to be_an Array }
|
8
|
+
|
9
|
+
it { is_expected.to all be_kind_of Symbol }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.category' do
|
13
|
+
subject { described_class.category }
|
14
|
+
|
15
|
+
it { is_expected.to be_an String }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Enumerator::Lazy do
|
4
|
+
describe '#scan' do
|
5
|
+
context 'when calculating summation of 0 thorugh 9' do
|
6
|
+
subject { [*0..9].lazy.scan(0, :+).to_a }
|
7
|
+
|
8
|
+
it { is_expected.to eq [0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45] }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,104 +1,2 @@
|
|
1
1
|
describe Twterm::Friendship do
|
2
|
-
describe '.already_looked_up?' do
|
3
|
-
before do
|
4
|
-
described_class.looked_up!(1)
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'returns true when the user is already looked up' do
|
8
|
-
expect(described_class.already_looked_up?(1)).to be true
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns false when the user is not looked up yet' do
|
12
|
-
expect(described_class.already_looked_up?(2)).to be false
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.blocking?' do
|
17
|
-
before do
|
18
|
-
described_class.block(1, 2)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns true when user 1 blocks user 2' do
|
22
|
-
expect(described_class.blocking?(1, 2)).to be true
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'returns false when user 1 does not block user 2' do
|
26
|
-
expect(described_class.blocking?(2, 1)).to be false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '.following?' do
|
31
|
-
before do
|
32
|
-
described_class.follow(1, 2)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns true when user 1 follows user 2' do
|
36
|
-
expect(described_class.following?(1, 2)).to be true
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns false when user 1 does not follow user 2' do
|
40
|
-
expect(described_class.following?(2, 1)).to be false
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '.following_requested?' do
|
45
|
-
before do
|
46
|
-
described_class.following_requested(1, 2)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'returns true when user 1 have sent following request to user 2' do
|
50
|
-
expect(described_class.following_requested?(1, 2)).to be true
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns false when user 1 have not sent following request to user 2' do
|
54
|
-
expect(described_class.following_requested?(2, 1)).to be false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '.muting?' do
|
59
|
-
before do
|
60
|
-
described_class.mute(1, 2)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns true when user 1 mutes user 2' do
|
64
|
-
expect(described_class.muting?(1, 2)).to be true
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns false when user 1 does not mute user 2' do
|
68
|
-
expect(described_class.muting?(2, 1)).to be false
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '.unblock' do
|
73
|
-
before do
|
74
|
-
described_class.block(1, 2)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'works' do
|
78
|
-
described_class.unblock(1, 2)
|
79
|
-
expect(described_class.blocking?(1, 2)).to be false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '.unfollow' do
|
84
|
-
before do
|
85
|
-
described_class.follow(1, 2)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'works' do
|
89
|
-
described_class.unfollow(1, 2)
|
90
|
-
expect(described_class.following?(1, 2)).to be false
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '.unmute' do
|
95
|
-
before do
|
96
|
-
described_class.mute(1, 2)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'works' do
|
100
|
-
described_class.unmute(1, 2)
|
101
|
-
expect(described_class.muting?(1, 2)).to be false
|
102
|
-
end
|
103
|
-
end
|
104
2
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image::Brackets do
|
4
|
+
let(:image) { described_class.new(foo) }
|
5
|
+
let(:foo) { Twterm::Image::StringImage.new('foo') }
|
6
|
+
|
7
|
+
describe '#to_s' do
|
8
|
+
subject { image.to_s }
|
9
|
+
|
10
|
+
it { is_expected.to eq '[foo]' }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image::Color do
|
4
|
+
let(:string_image) { Twterm::Image::StringImage.new(str) }
|
5
|
+
let(:str) { 'Hello' }
|
6
|
+
|
7
|
+
describe '#to_s' do
|
8
|
+
subject { image.to_s }
|
9
|
+
|
10
|
+
context 'when only with foreground color' do
|
11
|
+
let(:image) { described_class.new(string_image, :red) }
|
12
|
+
|
13
|
+
it { is_expected.to eq "\e[31mHello\e[0m" }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when with foreground and background color' do
|
17
|
+
let(:image) { described_class.new(string_image, :red, :white) }
|
18
|
+
|
19
|
+
it { is_expected.to eq "\e[47m\e[31mHello\e[0m" }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image::HorizontalSequentialImage do
|
4
|
+
let(:image) { described_class.new([foo, ws, bar, ws, baz]) }
|
5
|
+
let(:foo) { Twterm::Image::StringImage.new('foo') }
|
6
|
+
let(:bar) { Twterm::Image::StringImage.new('bar') }
|
7
|
+
let(:baz) { Twterm::Image::StringImage.new('baz') }
|
8
|
+
let(:ws) { Twterm::Image::StringImage.new(' ') }
|
9
|
+
|
10
|
+
describe '#to_s' do
|
11
|
+
subject { image.to_s }
|
12
|
+
|
13
|
+
it { is_expected.to eq 'foo bar baz' }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image::Parens do
|
4
|
+
let(:image) { described_class.new(foo) }
|
5
|
+
let(:foo) { Twterm::Image::StringImage.new('foo') }
|
6
|
+
|
7
|
+
describe '#to_s' do
|
8
|
+
subject { image.to_s }
|
9
|
+
|
10
|
+
it { is_expected.to eq '(foo)' }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image::VerticalSequentialImage do
|
4
|
+
let(:image) { described_class.new([foo, bar, baz]) }
|
5
|
+
let(:foo) { Twterm::Image::StringImage.new('foo') }
|
6
|
+
let(:bar) { Twterm::Image::StringImage.new('bar') }
|
7
|
+
let(:baz) { Twterm::Image::StringImage.new('baz') }
|
8
|
+
|
9
|
+
describe '#to_s' do
|
10
|
+
subject { image.to_s }
|
11
|
+
|
12
|
+
it { is_expected.to eq "foo\nbar\nbaz"}
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'twterm/image'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Image do
|
4
|
+
describe '.number' do
|
5
|
+
subject { described_class.number(n) }
|
6
|
+
|
7
|
+
context 'when n = 42' do
|
8
|
+
let(:n) { 42 }
|
9
|
+
|
10
|
+
it 'is stringified as it is' do
|
11
|
+
expect(subject.to_s).to eq '42'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when n = 1000000' do
|
16
|
+
let(:n) { 1_000_000 }
|
17
|
+
|
18
|
+
it 'is formatted with commas' do
|
19
|
+
expect(subject.to_s).to eq '1,000,000'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.plural' do
|
25
|
+
context 'the plural form is not given' do
|
26
|
+
subject { described_class.plural(n, 'image') }
|
27
|
+
|
28
|
+
context 'when n = 1' do
|
29
|
+
let(:n) { 1 }
|
30
|
+
|
31
|
+
it 'returns the singular form' do
|
32
|
+
expect(subject.to_s).to eq 'image'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when n = 42' do
|
37
|
+
let(:n) { 42 }
|
38
|
+
|
39
|
+
it 'returns the plural form' do
|
40
|
+
expect(subject.to_s).to eq 'images'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'the plural form is explicitly given' do
|
46
|
+
subject { described_class.plural(n, 'index', 'indices') }
|
47
|
+
|
48
|
+
context 'when n = 1' do
|
49
|
+
let(:n) { 1 }
|
50
|
+
|
51
|
+
it 'returns the singular form' do
|
52
|
+
expect(subject.to_s).to eq 'index'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when n = 42' do
|
57
|
+
let(:n) { 42 }
|
58
|
+
|
59
|
+
it 'returns the plural form' do
|
60
|
+
expect(subject.to_s).to eq 'indices'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'twterm/key_mapper/abstract_key_mapper'
|
2
|
+
|
3
|
+
describe Twterm::KeyMapper::AbstractKeyMapper do
|
4
|
+
describe '#translate' do
|
5
|
+
subject { described_class.new({}).send(:translate, key) }
|
6
|
+
|
7
|
+
before { described_class.define_singleton_method(:commands) { [] } }
|
8
|
+
|
9
|
+
context 'when key is ^A' do
|
10
|
+
let(:key) { '^A' }
|
11
|
+
|
12
|
+
it { is_expected.to eq 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when key is F1' do
|
16
|
+
let(:key) { 'F1' }
|
17
|
+
|
18
|
+
it { is_expected.to eq Curses::Key::F1 }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'twterm/repository/friendship_repository'
|
2
|
+
|
3
|
+
RSpec.describe Twterm::Repository::FriendshipRepository do
|
4
|
+
let(:repository) { described_class.new }
|
5
|
+
|
6
|
+
describe '#already_looked_up?' do
|
7
|
+
before do
|
8
|
+
repository.looked_up!(1)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns true when the user is already looked up' do
|
12
|
+
expect(repository.already_looked_up?(1)).to be true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns false when the user is not looked up yet' do
|
16
|
+
expect(repository.already_looked_up?(2)).to be false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#blocking?' do
|
21
|
+
before do
|
22
|
+
repository.block(1, 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns true when user 1 blocks user 2' do
|
26
|
+
expect(repository.blocking?(1, 2)).to be true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns false when user 1 does not block user 2' do
|
30
|
+
expect(repository.blocking?(2, 1)).to be false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#following?' do
|
35
|
+
before do
|
36
|
+
repository.follow(1, 2)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns true when user 1 follows user 2' do
|
40
|
+
expect(repository.following?(1, 2)).to be true
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns false when user 1 does not follow user 2' do
|
44
|
+
expect(repository.following?(2, 1)).to be false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#following_requested?' do
|
49
|
+
before do
|
50
|
+
repository.following_requested(1, 2)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns true when user 1 have sent following request to user 2' do
|
54
|
+
expect(repository.following_requested?(1, 2)).to be true
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns false when user 1 have not sent following request to user 2' do
|
58
|
+
expect(repository.following_requested?(2, 1)).to be false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#muting?' do
|
63
|
+
before do
|
64
|
+
repository.mute(1, 2)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns true when user 1 mutes user 2' do
|
68
|
+
expect(repository.muting?(1, 2)).to be true
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns false when user 1 does not mute user 2' do
|
72
|
+
expect(repository.muting?(2, 1)).to be false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#unblock' do
|
77
|
+
before do
|
78
|
+
repository.block(1, 2)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'works' do
|
82
|
+
repository.unblock(1, 2)
|
83
|
+
expect(repository.blocking?(1, 2)).to be false
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#unfollow' do
|
88
|
+
before do
|
89
|
+
repository.follow(1, 2)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'works' do
|
93
|
+
repository.unfollow(1, 2)
|
94
|
+
expect(repository.following?(1, 2)).to be false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#unmute' do
|
99
|
+
before do
|
100
|
+
repository.mute(1, 2)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'works' do
|
104
|
+
repository.unmute(1, 2)
|
105
|
+
expect(repository.muting?(1, 2)).to be false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
describe Twterm::Status do
|
4
|
+
let(:status) { described_class.new(Twitter::Tweet.new(json)) }
|
5
|
+
let(:json) { JSON.parse(fixture('status.json'), symbolize_names: true) }
|
6
|
+
|
7
|
+
describe '#==' do
|
8
|
+
subject { status === other }
|
9
|
+
|
10
|
+
context 'when having the same id' do
|
11
|
+
let(:other) { status.dup }
|
12
|
+
|
13
|
+
it { is_expected.to be true }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when having different id' do
|
17
|
+
let(:other) { json[:id] = 42; described_class.new(Twitter::Tweet.new(json)) }
|
18
|
+
|
19
|
+
it { is_expected.to be false }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when not being an instance of Twterm::Status' do
|
23
|
+
let(:other) { :foo }
|
24
|
+
|
25
|
+
it { is_expected.to be false }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#update!' do
|
30
|
+
subject { -> { status.update!(Hashie::Mash.new(params)) } }
|
31
|
+
|
32
|
+
before { status.update!(Hashie::Mash.new(retweet_count: 0, favorite_count: 0, retweeted: false, favorited: false)) }
|
33
|
+
|
34
|
+
context 'when updating retweet_count' do
|
35
|
+
let(:params) { { retweet_count: 42 } }
|
36
|
+
|
37
|
+
it { is_expected.to change { status.retweet_count }.from(0).to(42) }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when updating favorite_count' do
|
41
|
+
let(:params) { { favorite_count: 42 } }
|
42
|
+
|
43
|
+
it { is_expected.to change { status.favorite_count }.from(0).to(42) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when updating retweeted' do
|
47
|
+
let(:params) { { retweeted: true } }
|
48
|
+
|
49
|
+
it { is_expected.to change { status.retweeted? }.from(false).to(true) }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when updating favorited' do
|
53
|
+
let(:params) { { favorited: true } }
|
54
|
+
|
55
|
+
it { is_expected.to change { status.favorited? }.from(false).to(true) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|