ayadn 1.8.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +73 -52
- data/README.md +17 -3
- data/ayadn.gemspec +3 -4
- data/doc/01-index.md +6 -5
- data/doc/02-install.md +23 -1
- data/doc/03-first-steps.md +22 -28
- data/doc/04-options.md +1 -1
- data/doc/05-streams.md +29 -9
- data/doc/06-post.md +13 -5
- data/doc/07-actions.md +63 -1
- data/doc/08-listings.md +112 -4
- data/doc/09-accounts.md +17 -3
- data/doc/10-nicerank.md +5 -5
- data/doc/11-blacklist.md +8 -14
- data/doc/12-alias.md +1 -13
- data/doc/14-set.md +8 -110
- data/doc/15-nowplaying.md +16 -4
- data/doc/18-contact.md +14 -13
- data/doc/19-examples.md +2 -0
- data/lib/ayadn/action.rb +322 -183
- data/lib/ayadn/alias.rb +17 -45
- data/lib/ayadn/annotations.rb +1 -1
- data/lib/ayadn/api.rb +7 -8
- data/lib/ayadn/app.rb +99 -12
- data/lib/ayadn/authorize.rb +92 -57
- data/lib/ayadn/blacklist.rb +52 -62
- data/lib/ayadn/check.rb +81 -74
- data/lib/ayadn/cnx.rb +77 -26
- data/lib/ayadn/databases.rb +890 -105
- data/lib/ayadn/debug.rb +30 -89
- data/lib/ayadn/descriptions.rb +876 -329
- data/lib/ayadn/endpoints.rb +2 -2
- data/lib/ayadn/errors.rb +9 -9
- data/lib/ayadn/extend.rb +8 -1
- data/lib/ayadn/fileops.rb +10 -8
- data/lib/ayadn/mark.rb +79 -56
- data/lib/ayadn/migration.rb +427 -0
- data/lib/ayadn/nicerank.rb +74 -72
- data/lib/ayadn/nowplaying.rb +123 -60
- data/lib/ayadn/nowwatching.rb +26 -10
- data/lib/ayadn/pinboard.rb +12 -7
- data/lib/ayadn/post.rb +40 -37
- data/lib/ayadn/profile.rb +5 -2
- data/lib/ayadn/scroll.rb +20 -5
- data/lib/ayadn/search.rb +30 -22
- data/lib/ayadn/set.rb +146 -50
- data/lib/ayadn/settings.rb +66 -67
- data/lib/ayadn/status.rb +459 -234
- data/lib/ayadn/stream.rb +80 -46
- data/lib/ayadn/switch.rb +51 -47
- data/lib/ayadn/tvshow.rb +47 -15
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +119 -60
- data/lib/ayadn/workers.rb +144 -92
- data/lib/ayadn.rb +7 -8
- data/spec/mock/ayadn/accounts.sqlite +0 -0
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +12 -13
- data/spec/unit/api_spec.rb +3 -4
- data/spec/unit/blacklistworkers_spec.rb +18 -23
- data/spec/unit/databases_spec.rb +51 -36
- data/spec/unit/endpoints_spec.rb +5 -2
- data/spec/unit/extend_spec.rb +24 -0
- data/spec/unit/nicerank_spec.rb +13 -13
- data/spec/unit/post_spec.rb +47 -36
- data/spec/unit/set_spec.rb +67 -96
- data/spec/unit/view_spec.rb +12 -6
- data/spec/unit/workers_spec.rb +38 -12
- data/tags +1285 -0
- metadata +29 -39
- data/spec/mock/aliases.db +0 -0
- data/spec/mock/blacklist.db +0 -0
- data/spec/mock/bookmarks.db +0 -0
- data/spec/mock/channels.db +0 -0
- data/spec/mock/index.db +0 -0
- data/spec/mock/nicerank.db +0 -0
- data/spec/mock/pagination.db +0 -0
- data/spec/mock/users.db +0 -0
- data/spec/unit/status_spec.rb +0 -9
data/spec/unit/databases_spec.rb
CHANGED
@@ -3,53 +3,72 @@ require 'helpers'
|
|
3
3
|
|
4
4
|
describe Ayadn::Databases do
|
5
5
|
before do
|
6
|
-
Ayadn::Settings.stub(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
Ayadn::Settings.stub(:options).and_return({
|
7
|
+
colors: {
|
8
|
+
hashtags: :cyan,
|
9
|
+
mentions: :red,
|
10
|
+
username: :green,
|
11
|
+
excerpt: :green
|
12
|
+
},
|
13
|
+
timeline: {compact: false},
|
14
|
+
formats: {table: {width: 75}, list: {reverse: true}},
|
15
|
+
blacklist: {active: true}
|
11
16
|
})
|
12
|
-
Ayadn::Settings.stub(:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
Ayadn::Settings.stub(:config).and_return({
|
18
|
+
identity: {
|
19
|
+
username: 'test',
|
20
|
+
handle: '@test'
|
21
|
+
},
|
22
|
+
post_max_length: 256,
|
23
|
+
message_max_length: 2048,
|
24
|
+
version: 'wee',
|
25
|
+
paths: {
|
26
|
+
db: 'spec/mock/',
|
27
|
+
log: 'spec/mock'
|
28
|
+
}
|
29
|
+
})
|
30
|
+
Ayadn::Settings.stub(:global).and_return({
|
31
|
+
scrolling: false,
|
32
|
+
force: false
|
33
|
+
})
|
34
|
+
Ayadn::Logs.stub(:rec).and_return("logged")
|
35
|
+
Dir.stub(:home).and_return("spec/mock")
|
19
36
|
Ayadn::Databases.open_databases
|
20
37
|
end
|
21
38
|
describe ".add_to_users_db" do
|
22
39
|
it "adds a user" do
|
23
40
|
Ayadn::Databases.add_to_users_db(33, 'test', 'Mr Test')
|
24
|
-
expect(Ayadn::Databases.
|
25
|
-
u = Ayadn::Databases.
|
26
|
-
expect(u[
|
41
|
+
expect(Ayadn::Databases.all_users_ids).to eq [33]
|
42
|
+
u = Ayadn::Databases.find_user_object_by_id(33)
|
43
|
+
expect(u[2]).to eq 'Mr Test'
|
27
44
|
end
|
28
45
|
end
|
29
46
|
describe ".add_to_users_db_from_list" do
|
30
47
|
it "imports users from a list" do
|
31
48
|
list = {12=>['yolo', 'Miss YOLO'], 666=>['lucy', 'Lucy Fair']}
|
32
49
|
Ayadn::Databases.add_to_users_db_from_list(list)
|
33
|
-
expect(Ayadn::Databases.
|
34
|
-
u = Ayadn::Databases.
|
35
|
-
expect(u[
|
36
|
-
u = Ayadn::Databases.
|
37
|
-
expect(u[
|
50
|
+
expect(Ayadn::Databases.all_users_ids).to eq [12, 666]
|
51
|
+
u = Ayadn::Databases.find_user_object_by_id(12)
|
52
|
+
expect(u[2]).to eq 'Miss YOLO'
|
53
|
+
u = Ayadn::Databases.find_user_object_by_id(666)
|
54
|
+
expect(u[0]).to eq 666
|
55
|
+
expect(u[1]).to eq 'lucy'
|
56
|
+
expect(u[2]).to eq 'Lucy Fair'
|
38
57
|
end
|
39
58
|
end
|
40
59
|
describe ".save_max_id" do
|
41
60
|
it "saves pagination" do
|
42
61
|
stream = {'meta'=>{'max_id'=>'33666','marker'=>{'name'=>'test_stream'}}}
|
43
62
|
Ayadn::Databases.save_max_id(stream)
|
44
|
-
expect(Ayadn::Databases.
|
45
|
-
expect(Ayadn::Databases.
|
63
|
+
expect(Ayadn::Databases.all_pagination).to eq ['test_stream', 33666]
|
64
|
+
expect(Ayadn::Databases.find_last_id_from('test_stream')).to eq 33666
|
46
65
|
|
47
|
-
Ayadn::Databases.
|
66
|
+
Ayadn::Databases.pagination_delete('test_stream')
|
48
67
|
|
49
68
|
stream = {'meta'=>{'max_id'=>'12'}}
|
50
69
|
Ayadn::Databases.save_max_id(stream, 'yolo')
|
51
|
-
expect(Ayadn::Databases.
|
52
|
-
expect(Ayadn::Databases.
|
70
|
+
expect(Ayadn::Databases.all_pagination).to eq ['yolo', 12]
|
71
|
+
expect(Ayadn::Databases.find_last_id_from('yolo')).to eq 12
|
53
72
|
end
|
54
73
|
end
|
55
74
|
describe ".has_new?" do
|
@@ -63,24 +82,22 @@ describe Ayadn::Databases do
|
|
63
82
|
end
|
64
83
|
describe ".save_indexed_posts" do
|
65
84
|
it "saves index" do
|
66
|
-
posts = {'33666' =>{:count=>1},'424242' =>{:count=>2}}
|
85
|
+
posts = {'33666' =>{:count=>1, :id=>33666},'424242' =>{:count=>2, :id=>424242}}
|
67
86
|
Ayadn::Databases.save_indexed_posts(posts)
|
68
|
-
expect(Ayadn::Databases.
|
87
|
+
expect(Ayadn::Databases.get_post_from_index('2')['id']).to eq 424242
|
69
88
|
end
|
70
89
|
end
|
71
90
|
describe ".get_post_from_index" do
|
72
91
|
it "gets post id from index" do
|
73
92
|
posts = {'33666' =>{:count=>1, :id=>33666},'424242' =>{:count=>2, :id=>424242}}
|
74
93
|
Ayadn::Databases.save_indexed_posts(posts)
|
75
|
-
|
76
|
-
expect(r[:count]).to eq 1
|
77
|
-
expect(r[:id]).to eq 33666
|
94
|
+
expect(Ayadn::Databases.get_post_from_index(1)['id']).to eq 33666
|
78
95
|
end
|
79
96
|
end
|
80
97
|
describe ".create_alias" do
|
81
98
|
it "creates an alias for a channel id" do
|
82
99
|
Ayadn::Databases.create_alias('42','everything')
|
83
|
-
expect(Ayadn::Databases.
|
100
|
+
expect(Ayadn::Databases.get_channel_id('everything')).to eq 42
|
84
101
|
end
|
85
102
|
end
|
86
103
|
describe ".get_alias_from_id" do
|
@@ -90,10 +107,8 @@ describe Ayadn::Databases do
|
|
90
107
|
end
|
91
108
|
end
|
92
109
|
after do
|
93
|
-
Ayadn::Databases.
|
94
|
-
Ayadn::Databases.
|
95
|
-
Ayadn::Databases.
|
96
|
-
Ayadn::Databases.aliases.clear
|
97
|
-
Ayadn::Databases.close_all
|
110
|
+
Ayadn::Databases.clear_users
|
111
|
+
Ayadn::Databases.clear_pagination
|
112
|
+
Ayadn::Databases.clear_index
|
98
113
|
end
|
99
114
|
end
|
data/spec/unit/endpoints_spec.rb
CHANGED
@@ -11,11 +11,14 @@ describe Ayadn::Endpoints do
|
|
11
11
|
},
|
12
12
|
timeline: {
|
13
13
|
directed: 1,
|
14
|
-
deleted: 0,
|
15
14
|
html: 0,
|
16
15
|
annotations: 1
|
17
16
|
}
|
18
17
|
})
|
18
|
+
Ayadn::Settings.stub(:global).and_return({
|
19
|
+
scrolling: false,
|
20
|
+
force: false
|
21
|
+
})
|
19
22
|
end
|
20
23
|
describe '#token_info' do
|
21
24
|
it "returns the Token url" do
|
@@ -34,7 +37,7 @@ describe Ayadn::Endpoints do
|
|
34
37
|
end
|
35
38
|
describe "#checkins" do
|
36
39
|
it "returns the Checkins url" do
|
37
|
-
expect(Ayadn::Endpoints.new.checkins({count: 66, html: 1})).to eq 'https://api.app.net/posts/stream/explore/checkins?access_token=XXX&count=66&include_html=
|
40
|
+
expect(Ayadn::Endpoints.new.checkins({count: 66, html: 1})).to eq 'https://api.app.net/posts/stream/explore/checkins?access_token=XXX&count=66&include_html=0&include_directed_posts=1&include_deleted=0&include_annotations=1'
|
38
41
|
end
|
39
42
|
end
|
40
43
|
describe '#trending' do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
describe "is_integer?" do
|
5
|
+
it 'returns true if string is an integer and not 0' do
|
6
|
+
expect("1".is_integer?).to eq true
|
7
|
+
end
|
8
|
+
it 'returns true if string is an integer and not 0' do
|
9
|
+
expect("01".is_integer?).to eq true
|
10
|
+
end
|
11
|
+
it 'returns true if string is an integer and not 0' do
|
12
|
+
expect("331299".is_integer?).to eq true
|
13
|
+
end
|
14
|
+
it 'returns true if string is an integer and not 0' do
|
15
|
+
expect("000331299".is_integer?).to eq true
|
16
|
+
end
|
17
|
+
it 'returns false if string is not an integer or is 0' do
|
18
|
+
expect("0".is_integer?).to eq false
|
19
|
+
end
|
20
|
+
it 'returns false if string is not an integer or is 0' do
|
21
|
+
expect("yolo".is_integer?).to eq false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/unit/nicerank_spec.rb
CHANGED
@@ -9,15 +9,14 @@ describe Ayadn::NiceRank do
|
|
9
9
|
{
|
10
10
|
timeline: {
|
11
11
|
directed: 1,
|
12
|
-
deleted: 0,
|
13
12
|
html: 0,
|
14
13
|
annotations: 1,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
source: true,
|
15
|
+
symbols: true,
|
16
|
+
name: true,
|
17
|
+
date: true,
|
18
|
+
spinner: true,
|
19
|
+
debug: false
|
21
20
|
},
|
22
21
|
counts: {
|
23
22
|
default: 50,
|
@@ -54,12 +53,13 @@ describe Ayadn::NiceRank do
|
|
54
53
|
mentions: :red,
|
55
54
|
source: :cyan,
|
56
55
|
symbols: :green,
|
57
|
-
debug: :red
|
56
|
+
debug: :red,
|
57
|
+
excerpt: :green
|
58
58
|
},
|
59
59
|
backup: {
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
posts: false,
|
61
|
+
messages: false,
|
62
|
+
lists: false
|
63
63
|
},
|
64
64
|
scroll: {
|
65
65
|
timer: 3
|
@@ -68,7 +68,7 @@ describe Ayadn::NiceRank do
|
|
68
68
|
threshold: 2.1,
|
69
69
|
cache: 48,
|
70
70
|
filter: true,
|
71
|
-
|
71
|
+
unranked: false
|
72
72
|
},
|
73
73
|
nowplaying: {},
|
74
74
|
movie: {
|
@@ -95,7 +95,7 @@ describe Ayadn::NiceRank do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
#let(:rest) {Ayadn::CNX = double} #verbose in RSpec output, but useful
|
98
|
-
let(:rest) {Ayadn::CNX}
|
98
|
+
let(:rest) {Ayadn::CNX}
|
99
99
|
# let(:nicerank) { JSON.parse(File.read("spec/mock/nicerank.json")) }
|
100
100
|
|
101
101
|
describe "#get_posts_day" do
|
data/spec/unit/post_spec.rb
CHANGED
@@ -16,13 +16,14 @@ describe Ayadn::Post do
|
|
16
16
|
symbols: :green,
|
17
17
|
index: :blue,
|
18
18
|
date: :cyan,
|
19
|
-
link: :magenta
|
19
|
+
link: :magenta,
|
20
|
+
excerpt: :green
|
20
21
|
},
|
21
22
|
timeline: {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
name: true,
|
24
|
+
date: true,
|
25
|
+
symbols: true,
|
26
|
+
source: true
|
26
27
|
},
|
27
28
|
formats: {table: {width: 75}},
|
28
29
|
counts: {
|
@@ -68,56 +69,66 @@ describe Ayadn::Post do
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
|
-
describe "#text_is_empty?" do
|
72
|
-
it "checks if empty" do
|
73
|
-
expect(post.text_is_empty?(["allo"])).to be false
|
74
|
-
expect(post.text_is_empty?([""])).to be true
|
75
|
-
expect(post.text_is_empty?([])).to be true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
72
|
describe "#markdown_extract" do
|
80
73
|
it "splits markdown" do
|
81
74
|
expect(post.markdown_extract("[ayadn](http://ayadn-app.net)")).to eq ["ayadn", "http://ayadn-app.net"]
|
82
75
|
end
|
83
76
|
end
|
84
77
|
|
85
|
-
describe "#
|
78
|
+
describe "#keep_text_from_markdown_links" do
|
86
79
|
it "extracts markdown text" do
|
87
|
-
expect(post.
|
80
|
+
expect(post.keep_text_from_markdown_links("[ayadn](http://ayadn-app.net)")).to eq "ayadn"
|
88
81
|
end
|
89
82
|
end
|
90
83
|
|
91
|
-
describe "#
|
92
|
-
it "
|
93
|
-
|
94
|
-
expect(lambda {post.post_size("Black malt berliner weisse, filter. Ibu degrees plato alcohol. ipa hard cider ester infusion conditioning tank. Dry stout bottom fermenting yeast wort chiller wort chiller lager hand pump ! All-malt dunkle bright beer grainy, original gravity wheat beer glass.")}).to raise_error(SystemExit)
|
95
|
-
end
|
96
|
-
expect(printed).to include 'Canceled: too long. 256 max, 4 characters to remove.'
|
84
|
+
describe "#post_size_ok?" do
|
85
|
+
it "checks excessive post length" do
|
86
|
+
expect(post.post_size_ok?(["1" * 257].join())).to eq false
|
97
87
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
it "checks
|
102
|
-
expect(post.
|
88
|
+
it "checks excessive post length with markdown" do
|
89
|
+
expect(post.post_size_ok?(["1" * 251, "[aya.io](http://aya.io)"].join())).to eq false
|
90
|
+
end
|
91
|
+
it "checks empty post length" do
|
92
|
+
expect(post.post_size_ok?("")).to eq false
|
93
|
+
end
|
94
|
+
it "checks full post length" do
|
95
|
+
expect(post.post_size_ok?(["1" * 256].join())).to eq true
|
96
|
+
end
|
97
|
+
it "checks full post length" do
|
98
|
+
expect(post.post_size_ok?(["Y😈" * 128].join())).to eq true
|
103
99
|
end
|
104
100
|
it "checks excessive post length" do
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
expect(
|
101
|
+
expect(post.post_size_ok?(["😈" * 257].join())).to eq false
|
102
|
+
end
|
103
|
+
it "checks post length" do
|
104
|
+
expect(post.post_size_ok?(["."].join())).to eq true
|
105
|
+
end
|
106
|
+
it "checks full post length" do
|
107
|
+
expect(post.post_size_ok?(["1\n" * 128].join())).to eq true
|
108
|
+
end
|
109
|
+
it "checks excessive post length" do
|
110
|
+
expect(post.post_size_ok?(["1\n" * 128, "\n"].join())).to eq false
|
111
|
+
end
|
112
|
+
it "checks full post length with markdown" do
|
113
|
+
expect(post.post_size_ok?(["1" * 250, "[aya.io](http://aya.io)"].join())).to eq true
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
112
|
-
describe "#
|
117
|
+
describe "#message_size_ok?" do
|
113
118
|
it "checks normal message length" do
|
114
|
-
expect(post.
|
119
|
+
expect(post.message_size_ok?(["1" * 2048].join())).to eq true
|
120
|
+
end
|
121
|
+
it "checks normal message length with markdown" do
|
122
|
+
expect(post.message_size_ok?(["1" * 2042, "[aya.io](http://aya.io)"].join())).to eq true
|
123
|
+
end
|
124
|
+
it "checks empty message length" do
|
125
|
+
expect(post.message_size_ok?("")).to eq false
|
115
126
|
end
|
116
127
|
it "checks excessive message length" do
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
expect(
|
128
|
+
expect(post.message_size_ok?(["1" * 2049].join())).to eq false
|
129
|
+
end
|
130
|
+
it "checks excessive message length with markdown" do
|
131
|
+
expect(post.message_size_ok?(["1" * 2043, "[aya.io](http://aya.io)"].join())).to eq false
|
121
132
|
end
|
122
133
|
end
|
123
134
|
end
|
data/spec/unit/set_spec.rb
CHANGED
@@ -13,19 +13,19 @@ def init_stubs
|
|
13
13
|
symbols: :green,
|
14
14
|
index: :blue,
|
15
15
|
date: :cyan,
|
16
|
-
link: :magenta
|
16
|
+
link: :magenta,
|
17
|
+
excerpt: :green
|
17
18
|
},
|
18
19
|
timeline: {
|
19
20
|
directed: 1,
|
20
|
-
deleted: 0,
|
21
21
|
html: 0,
|
22
22
|
annotations: 1,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
source: true,
|
24
|
+
symbols: true,
|
25
|
+
name: true,
|
26
|
+
date: true,
|
27
|
+
spinner: true,
|
28
|
+
debug: false
|
29
29
|
},
|
30
30
|
formats: {
|
31
31
|
table: {width: 75},
|
@@ -62,15 +62,15 @@ def init_stubs
|
|
62
62
|
threshold: 2.1,
|
63
63
|
cache: 48,
|
64
64
|
filter: true,
|
65
|
-
|
65
|
+
unranked: false
|
66
66
|
},
|
67
67
|
backup: {
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
posts: false,
|
69
|
+
messages: false,
|
70
|
+
lists: false
|
71
71
|
},
|
72
72
|
marker: {
|
73
|
-
|
73
|
+
messages: true
|
74
74
|
}
|
75
75
|
})
|
76
76
|
Ayadn::Settings.stub(:config).and_return({
|
@@ -83,7 +83,6 @@ def init_stubs
|
|
83
83
|
version: 'wee',
|
84
84
|
paths: {
|
85
85
|
db: 'spec/mock/',
|
86
|
-
pagination: 'spec/mock/',
|
87
86
|
log: 'spec/mock'
|
88
87
|
}
|
89
88
|
})
|
@@ -113,6 +112,28 @@ describe Ayadn::SetScroll do
|
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
115
|
+
describe "#spinner" do
|
116
|
+
it "creates a default value" do
|
117
|
+
Ayadn::SetScroll.new.spinner('true')
|
118
|
+
expect(Ayadn::Settings.options[:scroll][:spinner]).to eq true
|
119
|
+
Ayadn::SetScroll.new.spinner('false')
|
120
|
+
expect(Ayadn::Settings.options[:scroll][:spinner]).to eq false
|
121
|
+
Ayadn::SetScroll.new.spinner('0')
|
122
|
+
expect(Ayadn::Settings.options[:scroll][:spinner]).to eq false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#date" do
|
127
|
+
it "creates a default value" do
|
128
|
+
Ayadn::SetScroll.new.date('true')
|
129
|
+
expect(Ayadn::Settings.options[:scroll][:date]).to eq true
|
130
|
+
Ayadn::SetScroll.new.date('false')
|
131
|
+
expect(Ayadn::Settings.options[:scroll][:date]).to eq false
|
132
|
+
Ayadn::SetScroll.new.date('0')
|
133
|
+
expect(Ayadn::Settings.options[:scroll][:date]).to eq false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
116
137
|
after do
|
117
138
|
File.delete('spec/mock/ayadn.log')
|
118
139
|
end
|
@@ -166,10 +187,9 @@ describe Ayadn::SetFormats do
|
|
166
187
|
expect(Ayadn::Settings.options[:formats][:list][:reverse]).to eq false
|
167
188
|
end
|
168
189
|
it "raises an error" do
|
169
|
-
printed =
|
190
|
+
printed = capture_stdout do
|
170
191
|
expect(lambda {Ayadn::SetFormats.new.send(:list, ['reverse', 'yolo'])}).to raise_error(SystemExit)
|
171
192
|
end
|
172
|
-
expect(printed).to include 'You have to submit valid items'
|
173
193
|
end
|
174
194
|
end
|
175
195
|
|
@@ -185,21 +205,13 @@ describe Ayadn::SetTimeline do
|
|
185
205
|
|
186
206
|
describe "#" do
|
187
207
|
it "creates a default value" do
|
188
|
-
%w{directed
|
208
|
+
%w{directed source symbols name date debug compact}.each do |meth|
|
189
209
|
command = meth.to_sym
|
190
210
|
Ayadn::SetTimeline.new.send(command, 'true')
|
191
211
|
expect(Ayadn::Settings.options[:timeline][command]).to eq true
|
192
|
-
printed =
|
212
|
+
printed = capture_stdout do
|
193
213
|
expect(lambda {Ayadn::SetTimeline.new.send(command, 'yolo')}).to raise_error(SystemExit)
|
194
214
|
end
|
195
|
-
expect(printed).to include 'You have to submit valid items'
|
196
|
-
end
|
197
|
-
['deleted', 'annotations'].each do |meth|
|
198
|
-
command = meth.to_sym
|
199
|
-
printed = capture_stderr do
|
200
|
-
expect(lambda {Ayadn::SetTimeline.new.send(command, 'false')}).to raise_error(SystemExit)
|
201
|
-
end
|
202
|
-
expect(printed).to include 'This parameter is not modifiable'
|
203
215
|
end
|
204
216
|
end
|
205
217
|
end
|
@@ -220,31 +232,12 @@ describe Ayadn::SetCounts do
|
|
220
232
|
command = meth.to_sym
|
221
233
|
Ayadn::SetCounts.new.send(command, '199')
|
222
234
|
expect(Ayadn::Settings.options[:counts][command]).to eq 199
|
223
|
-
printed =
|
224
|
-
|
235
|
+
printed = capture_stdout do
|
236
|
+
Ayadn::SetCounts.new.send(command, '333')
|
225
237
|
end
|
226
|
-
expect(printed).to include 'This paramater must be an integer between 1 and 200'
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe "#validate" do
|
232
|
-
it "raises error if incorrect count value" do
|
233
|
-
printed = capture_stderr do
|
234
|
-
expect(lambda {Ayadn::SetCounts.new.validate('0')}).to raise_error(SystemExit)
|
235
238
|
end
|
236
|
-
expect(printed).to include 'This paramater must be an integer between 1 and 200'
|
237
|
-
end
|
238
|
-
it "raises error if incorrect count value" do
|
239
|
-
printed = capture_stderr do
|
240
|
-
expect(lambda {Ayadn::SetCounts.new.validate('yolo')}).to raise_error(SystemExit)
|
241
|
-
end
|
242
|
-
expect(printed).to include 'This paramater must be an integer between 1 and 200'
|
243
239
|
end
|
244
240
|
end
|
245
|
-
after do
|
246
|
-
File.delete('spec/mock/ayadn.log')
|
247
|
-
end
|
248
241
|
end
|
249
242
|
|
250
243
|
describe Ayadn::SetMarker do
|
@@ -252,11 +245,11 @@ describe Ayadn::SetMarker do
|
|
252
245
|
init_stubs
|
253
246
|
end
|
254
247
|
|
255
|
-
describe "#
|
248
|
+
describe "#messages" do
|
256
249
|
it "creates a default value" do
|
257
|
-
expect(Ayadn::Settings.options[:marker][:
|
258
|
-
Ayadn::SetMarker.new.
|
259
|
-
expect(Ayadn::Settings.options[:marker][:
|
250
|
+
expect(Ayadn::Settings.options[:marker][:messages]).to eq true
|
251
|
+
Ayadn::SetMarker.new.messages('0')
|
252
|
+
expect(Ayadn::Settings.options[:marker][:messages]).to eq false
|
260
253
|
end
|
261
254
|
end
|
262
255
|
|
@@ -270,25 +263,25 @@ describe Ayadn::SetBackup do
|
|
270
263
|
init_stubs
|
271
264
|
end
|
272
265
|
|
273
|
-
describe "#
|
266
|
+
describe "#posts" do
|
274
267
|
it "creates a default value" do
|
275
|
-
expect(Ayadn::Settings.options[:backup][:
|
276
|
-
Ayadn::SetBackup.new.
|
277
|
-
expect(Ayadn::Settings.options[:backup][:
|
268
|
+
expect(Ayadn::Settings.options[:backup][:posts]).to eq false
|
269
|
+
Ayadn::SetBackup.new.posts('1')
|
270
|
+
expect(Ayadn::Settings.options[:backup][:posts]).to eq true
|
278
271
|
end
|
279
272
|
end
|
280
|
-
describe "#
|
273
|
+
describe "#messages" do
|
281
274
|
it "creates a default value" do
|
282
|
-
expect(Ayadn::Settings.options[:backup][:
|
283
|
-
Ayadn::SetBackup.new.
|
284
|
-
expect(Ayadn::Settings.options[:backup][:
|
275
|
+
expect(Ayadn::Settings.options[:backup][:messages]).to eq false
|
276
|
+
Ayadn::SetBackup.new.messages('True')
|
277
|
+
expect(Ayadn::Settings.options[:backup][:messages]).to eq true
|
285
278
|
end
|
286
279
|
end
|
287
|
-
describe "#
|
280
|
+
describe "#lists" do
|
288
281
|
it "creates a default value" do
|
289
|
-
expect(Ayadn::Settings.options[:backup][:
|
290
|
-
Ayadn::SetBackup.new.
|
291
|
-
expect(Ayadn::Settings.options[:backup][:
|
282
|
+
expect(Ayadn::Settings.options[:backup][:lists]).to eq false
|
283
|
+
Ayadn::SetBackup.new.lists('YES')
|
284
|
+
expect(Ayadn::Settings.options[:backup][:lists]).to eq true
|
292
285
|
end
|
293
286
|
end
|
294
287
|
|
@@ -298,10 +291,9 @@ describe Ayadn::SetBackup do
|
|
298
291
|
expect(value).to eq false
|
299
292
|
end
|
300
293
|
it "raises error if incorrect boolean" do
|
301
|
-
printed =
|
294
|
+
printed = capture_stdout do
|
302
295
|
expect(lambda {Ayadn::SetBackup.new.validate('yolo')}).to raise_error(SystemExit)
|
303
296
|
end
|
304
|
-
expect(printed).to include "You have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values"
|
305
297
|
end
|
306
298
|
end
|
307
299
|
after do
|
@@ -352,14 +344,6 @@ describe Ayadn::SetNiceRank do
|
|
352
344
|
expect(Ayadn::Settings.options[:nicerank][:threshold]).to eq 3
|
353
345
|
Ayadn::SetNiceRank.new.threshold('3.2')
|
354
346
|
expect(Ayadn::Settings.options[:nicerank][:threshold]).to eq 3.2
|
355
|
-
printed = capture_stderr do
|
356
|
-
expect(lambda {Ayadn::SetNiceRank.new.threshold('6')}).to raise_error(SystemExit)
|
357
|
-
end
|
358
|
-
expect(printed).to include 'Please enter a value between 0.1 and 3.5, example: 2.1'
|
359
|
-
printed = capture_stderr do
|
360
|
-
expect(lambda {Ayadn::SetNiceRank.new.threshold('yolo')}).to raise_error(SystemExit)
|
361
|
-
end
|
362
|
-
expect(printed).to include 'Please enter a value between 0.1 and 3.5, example: 2.1'
|
363
347
|
end
|
364
348
|
end
|
365
349
|
describe "#filter" do
|
@@ -369,34 +353,21 @@ describe Ayadn::SetNiceRank do
|
|
369
353
|
expect(Ayadn::Settings.options[:nicerank][:filter]).to eq false
|
370
354
|
Ayadn::SetNiceRank.new.filter('1')
|
371
355
|
expect(Ayadn::Settings.options[:nicerank][:filter]).to eq true
|
372
|
-
printed =
|
356
|
+
printed = capture_stdout do
|
373
357
|
expect(lambda {Ayadn::SetNiceRank.new.filter('6')}).to raise_error(SystemExit)
|
374
358
|
end
|
375
|
-
expect(printed).to include "You have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values."
|
376
|
-
end
|
377
|
-
end
|
378
|
-
describe "#filter_unranked" do
|
379
|
-
it "creates a new filter_unranked default" do
|
380
|
-
expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq false
|
381
|
-
Ayadn::SetNiceRank.new.filter_unranked('true')
|
382
|
-
expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq true
|
383
|
-
Ayadn::SetNiceRank.new.filter_unranked('0')
|
384
|
-
expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq false
|
385
|
-
printed = capture_stderr do
|
386
|
-
expect(lambda {Ayadn::SetNiceRank.new.filter_unranked('yolo')}).to raise_error(SystemExit)
|
387
|
-
end
|
388
|
-
expect(printed).to include "You have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values."
|
389
359
|
end
|
390
360
|
end
|
391
|
-
describe "#
|
392
|
-
it "creates a new
|
393
|
-
expect(Ayadn::Settings.options[:nicerank][:
|
394
|
-
Ayadn::SetNiceRank.new.
|
395
|
-
expect(Ayadn::Settings.options[:nicerank][:
|
396
|
-
|
397
|
-
|
361
|
+
describe "#unranked" do
|
362
|
+
it "creates a new unranked default" do
|
363
|
+
expect(Ayadn::Settings.options[:nicerank][:unranked]).to eq false
|
364
|
+
Ayadn::SetNiceRank.new.unranked('true')
|
365
|
+
expect(Ayadn::Settings.options[:nicerank][:unranked]).to eq true
|
366
|
+
Ayadn::SetNiceRank.new.unranked('0')
|
367
|
+
expect(Ayadn::Settings.options[:nicerank][:unranked]).to eq false
|
368
|
+
printed = capture_stdout do
|
369
|
+
expect(lambda {Ayadn::SetNiceRank.new.unranked('yolo')}).to raise_error(SystemExit)
|
398
370
|
end
|
399
|
-
expect(printed).to include "Please enter a number of hours between 1 and 168"
|
400
371
|
end
|
401
372
|
end
|
402
373
|
after do
|