ayadn 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {"meta":{"code":200,"more":false},"data":[{"user_id":69904,"rank":3.816259,"is_human":true,"user":{"username":"ericd","account_age":513,"following":277,"followers":261,"posts":5933,"stars":345,"posts_day":11.5653,"days_idle":0},"account":{"has_avatar":true,"has_bio":true,"has_cover":true,"is_verified":true,"is_human":true,"real_person":true},"stats":{"robo_posts":6,"post_count":294,"conversations":229,"links":36,"mentions":232,"questions":25}}]}
@@ -0,0 +1,139 @@
1
+ require 'spec_helper'
2
+ require 'helpers'
3
+ require 'json'
4
+
5
+ describe Ayadn::Annotations do
6
+
7
+ before do
8
+ Ayadn::Settings.stub(:options).and_return(
9
+ {
10
+ timeline: {
11
+ directed: 1,
12
+ deleted: 0,
13
+ html: 0,
14
+ annotations: 1,
15
+ show_source: true,
16
+ show_symbols: true,
17
+ show_real_name: true,
18
+ show_date: true,
19
+ show_spinner: true,
20
+ show_debug: false
21
+ },
22
+ counts: {
23
+ default: 50,
24
+ unified: 100,
25
+ global: 100,
26
+ checkins: 100,
27
+ conversations: 50,
28
+ photos: 50,
29
+ trending: 100,
30
+ mentions: 100,
31
+ convo: 100,
32
+ posts: 100,
33
+ messages: 50,
34
+ search: 200,
35
+ whoreposted: 50,
36
+ whostarred: 50,
37
+ whatstarred: 100,
38
+ files: 100
39
+ },
40
+ formats: {
41
+ table: {
42
+ width: 75
43
+ }
44
+ },
45
+ colors: {
46
+ id: :blue,
47
+ index: :red,
48
+ username: :green,
49
+ name: :magenta,
50
+ date: :cyan,
51
+ link: :yellow,
52
+ dots: :blue,
53
+ hashtags: :cyan,
54
+ mentions: :red,
55
+ source: :cyan,
56
+ symbols: :green,
57
+ debug: :red
58
+ },
59
+ backup: {
60
+ auto_save_sent_posts: false,
61
+ auto_save_sent_messages: false,
62
+ auto_save_lists: false
63
+ },
64
+ scroll: {
65
+ timer: 3
66
+ },
67
+ nicerank: {
68
+ threshold: 2.1,
69
+ cache: 48,
70
+ filter: true,
71
+ filter_unranked: false
72
+ },
73
+ nowplaying: {},
74
+ movie: {
75
+ hashtag: 'nowwatching'
76
+ },
77
+ tvshow: {
78
+ hashtag: 'nowwatching'
79
+ }
80
+ }
81
+ )
82
+ Ayadn::Settings.stub(:config).and_return({
83
+ identity: {
84
+ username: 'test',
85
+ handle: '@test'
86
+ },
87
+ post_max_length: 256,
88
+ message_max_length: 2048,
89
+ version: 'wee'
90
+ })
91
+ Ayadn::Errors.stub(:warn).and_return("warned")
92
+ Ayadn::Logs.stub(:rec).and_return("logged")
93
+ Ayadn::FileOps.stub(:make_paths).and_return(['~/your/path/cat.jpg', '~/your/path/dog.png']) # STUB1
94
+ Ayadn::FileOps.stub(:upload_files).and_return([{'data' => {'id' => 3312,'file_token' => '0x3312-YOLO'}},{'data' => {'id' => 5550,'file_token' => '0x5550-WOOT'}}])
95
+ end
96
+
97
+ describe "#base" do
98
+ it "creates basic annotations" do
99
+ ann = Ayadn::Annotations.new({})
100
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]
101
+ end
102
+ end
103
+
104
+ describe "#movie" do
105
+ it "creates movie annotations" do
106
+ ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {movie: true}})
107
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.movie", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
108
+ end
109
+ end
110
+
111
+ describe "#tvshow" do
112
+ it "creates tvshow annotations" do
113
+ ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {tvshow: true}})
114
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.tvshow", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
115
+ end
116
+ end
117
+
118
+ describe "#nowplaying --silent" do
119
+ it "creates nowplaying --silent annotations" do
120
+ ann = Ayadn::Annotations.new({source: 'wadawadawada', options: {nowplaying: true, no_url: true}})
121
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"status"=>"no-url", "source"=>"wadawadawada"}}]
122
+ end
123
+ end
124
+
125
+ describe "#nowplaying" do
126
+ it "creates nowplaying annotations" do
127
+ ann = Ayadn::Annotations.new({source: 'rspec', title: 'ibelieveicanfly', artist: 'big jim', artwork: 'http://ahah', link: 'http://ohoh', source: 'fake', width: 9000, height: 30000, artwork_thumb: 'http://hihi', width_thumb: 9, height_thumb: 3, options: {nowplaying: true}})
128
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"title"=>"ibelieveicanfly", "artist"=>'big jim', "artwork"=>"http://ahah", "link"=>"http://ohoh", "source"=>"fake"}}, {"type"=>"net.app.core.oembed", "value"=>{"version"=>"1.0", "type"=>"photo", "width"=>9000, "height"=>30000, "title"=>"ibelieveicanfly", "url"=>"http://ahah", "embeddable_url"=>"http://ahah", "provider_url"=>"https://itunes.apple.com", "provider_name"=>"iTunes", "thumbnail_url"=>"http://hihi", "thumbnail_width"=>9, "thumbnail_height"=>3}}]
129
+ end
130
+ end
131
+
132
+ describe "#files" do
133
+ it "creates files annotations" do
134
+ ann = Ayadn::Annotations.new({options: {embed: ['whatever.jpg', 'another.png']}}) # fake array, cf STUB1
135
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>3312, "file_token"=>"0x3312-YOLO", "format"=>"oembed"}}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>5550, "file_token"=>"0x5550-WOOT", "format"=>"oembed"}}}]
136
+ end
137
+ end
138
+
139
+ end
@@ -50,41 +50,20 @@ describe Ayadn::BlacklistWorkers do
50
50
  end
51
51
 
52
52
  describe "add" do
53
- it "adds a client to the blacklist" do
54
- k = Ayadn::BlacklistWorkers.new
55
- k.add(['client', 'IFTTT'])
56
- expect(Ayadn::Databases.blacklist['ifttt']).to eq :client
57
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"IFTTT\"]' to blacklist of clients."
58
- end
59
53
  it "adds a client to the blacklist" do
60
54
  k = Ayadn::BlacklistWorkers.new
61
55
  k.add(['source', 'Zapier'])
62
56
  expect(Ayadn::Databases.blacklist['zapier']).to eq :client
63
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"Zapier\"]' to blacklist of clients."
64
- end
65
- it "adds a hashtag to the blacklist" do
66
- k = Ayadn::BlacklistWorkers.new
67
- k.add(['hashtag', 'Sports'])
68
- expect(Ayadn::Databases.blacklist['sports']).to eq :hashtag
69
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"Sports\"]' to blacklist of hashtags."
70
57
  end
71
58
  it "adds a hashtag to the blacklist" do
72
59
  k = Ayadn::BlacklistWorkers.new
73
60
  k.add(['tag', 'tv'])
74
61
  expect(Ayadn::Databases.blacklist['tv']).to eq :hashtag
75
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"tv\"]' to blacklist of hashtags."
76
- end
77
- it "adds a mention to the blacklist" do
78
- k = Ayadn::BlacklistWorkers.new
79
- k.add(['mention', 'mrTest'])
80
- expect(Ayadn::Databases.blacklist['@mrtest']).to eq :mention
81
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"@mrTest\"]' to blacklist of mentions."
82
62
  end
83
63
  it "adds a mention to the blacklist" do
84
64
  k = Ayadn::BlacklistWorkers.new
85
65
  k.add(['mentions', 'yolo'])
86
66
  expect(Ayadn::Databases.blacklist['@yolo']).to eq :mention
87
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"@yolo\"]' to blacklist of mentions."
88
67
  end
89
68
  end
90
69
 
@@ -93,11 +72,37 @@ describe Ayadn::BlacklistWorkers do
93
72
  k = Ayadn::BlacklistWorkers.new
94
73
  k.add(['client', 'IFTTT'])
95
74
  expect(Ayadn::Databases.blacklist['ifttt']).to eq :client
96
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"IFTTT\"]' to blacklist of clients."
75
+
97
76
  k = Ayadn::BlacklistWorkers.new
98
77
  k.remove(['client', 'IFTTT'])
99
78
  expect(Ayadn::Databases.blacklist['ifttt']).to eq nil
100
- #expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Removed 'client:[\"IFTTT\"]' from blacklist."
79
+ end
80
+ it "removes a hashtag from the blacklist" do
81
+ k = Ayadn::BlacklistWorkers.new
82
+ k.add(['hashtag', 'Sports'])
83
+ expect(Ayadn::Databases.blacklist['sports']).to eq :hashtag
84
+
85
+ k = Ayadn::BlacklistWorkers.new
86
+ k.remove(['hashtag', 'Sports'])
87
+ expect(Ayadn::Databases.blacklist['sports']).to eq nil
88
+ end
89
+ it "removes a mention from the blacklist" do
90
+ k = Ayadn::BlacklistWorkers.new
91
+ k.add(['mention', 'mrTest'])
92
+ expect(Ayadn::Databases.blacklist['@mrtest']).to eq :mention
93
+
94
+ k = Ayadn::BlacklistWorkers.new
95
+ k.remove(['mention', 'mrTest'])
96
+ expect(Ayadn::Databases.blacklist['@mrtest']).to eq nil
97
+ end
98
+ it "removes a user from the blacklist" do
99
+ k = Ayadn::BlacklistWorkers.new
100
+ k.add(['user', 'mrTest'])
101
+ expect(Ayadn::Databases.blacklist['-@mrtest']).to eq :user
102
+
103
+ k = Ayadn::BlacklistWorkers.new
104
+ k.remove(['account', 'mrTest'])
105
+ expect(Ayadn::Databases.blacklist['-@mrtest']).to eq nil
101
106
  end
102
107
  end
103
108
 
@@ -43,6 +43,13 @@ describe Ayadn::Databases do
43
43
  Ayadn::Databases.save_max_id(stream)
44
44
  expect(Ayadn::Databases.pagination.keys).to eq ['test_stream']
45
45
  expect(Ayadn::Databases.pagination['test_stream']).to eq '33666'
46
+
47
+ Ayadn::Databases.pagination.delete('test_stream')
48
+
49
+ stream = {'meta'=>{'max_id'=>'12'}}
50
+ Ayadn::Databases.save_max_id(stream, 'yolo')
51
+ expect(Ayadn::Databases.pagination.keys).to eq ['yolo']
52
+ expect(Ayadn::Databases.pagination['yolo']).to eq '12'
46
53
  end
47
54
  end
48
55
  describe ".has_new?" do
@@ -6,7 +6,8 @@ describe Ayadn::Endpoints do
6
6
  Ayadn::Settings.stub(:options).and_return({
7
7
  counts: {
8
8
  unified: 33,
9
- default: 100
9
+ default: 100,
10
+ conversations: 12
10
11
  },
11
12
  timeline: {
12
13
  directed: 1,
@@ -25,11 +26,60 @@ describe Ayadn::Endpoints do
25
26
  it "returns the Unified url" do
26
27
  expect(Ayadn::Endpoints.new.unified({})).to eq 'https://api.app.net/posts/stream/unified?access_token=XXX&count=33&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
27
28
  end
28
- it "returns the Unified url" do
29
- expect(Ayadn::Endpoints.new.unified({count: 66, html: 1})).to eq 'https://api.app.net/posts/stream/unified?access_token=XXX&count=66&include_html=1&include_directed=1&include_deleted=0&include_annotations=1'
29
+ end
30
+ describe '#global' do
31
+ it "returns the Global url" do
32
+ expect(Ayadn::Endpoints.new.global({since_id: 336699})).to eq 'https://api.app.net/posts/stream/global?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&since_id=336699'
30
33
  end
31
- it "returns the Unified url" do
32
- expect(Ayadn::Endpoints.new.unified({since_id: 336699})).to eq 'https://api.app.net/posts/stream/unified?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&since_id=336699'
34
+ end
35
+ describe "#checkins" do
36
+ 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=1&include_directed=1&include_deleted=0&include_annotations=1'
38
+ end
39
+ end
40
+ describe '#trending' do
41
+ it "returns the trending url" do
42
+ expect(Ayadn::Endpoints.new.trending({deleted: 1})).to eq 'https://api.app.net/posts/stream/explore/trending?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
43
+ end
44
+ end
45
+ describe '#photos' do
46
+ it "returns the photos url" do
47
+ expect(Ayadn::Endpoints.new.photos({count: 33})).to eq "https://api.app.net/posts/stream/explore/photos?access_token=XXX&count=33&include_html=0&include_directed=1&include_deleted=0&include_annotations=1"
48
+ end
49
+ end
50
+ describe '#conversations' do
51
+ it "returns the conversations url" do
52
+ expect(Ayadn::Endpoints.new.conversations({})).to eq "https://api.app.net/posts/stream/explore/conversations?access_token=XXX&count=12&include_html=0&include_directed=1&include_deleted=0&include_annotations=1"
53
+ end
54
+ end
55
+ describe '#mentions' do
56
+ it "returns the mentions url" do
57
+ expect(Ayadn::Endpoints.new.mentions('@test', {count: 33})).to eq 'https://api.app.net/users/@test/mentions/?access_token=XXX&count=33&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
58
+ end
59
+ end
60
+ describe '#posts' do
61
+ it "returns the posts url" do
62
+ expect(Ayadn::Endpoints.new.posts('@test', {count: 8})).to eq 'https://api.app.net/users/@test/posts/?access_token=XXX&count=8&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
63
+ end
64
+ end
65
+ describe '#whatstarred' do
66
+ it "returns the whatstarred url" do
67
+ expect(Ayadn::Endpoints.new.whatstarred('@test', {count: 16})).to eq 'https://api.app.net/users/@test/stars/?access_token=XXX&count=16&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
68
+ end
69
+ end
70
+ describe '#channel' do
71
+ it "returns the channel url" do
72
+ expect(Ayadn::Endpoints.new.channel([56789, 12345])).to eq 'https://api.app.net/channels/?ids=56789,12345&access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
73
+ end
74
+ end
75
+ describe '#messages' do
76
+ it "returns the messages url" do
77
+ expect(Ayadn::Endpoints.new.messages(56789)).to eq 'https://api.app.net/channels/56789/messages?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&include_machine=1'
78
+ end
79
+ end
80
+ describe '#file' do
81
+ it "returns the file url" do
82
+ expect(Ayadn::Endpoints.new.file(56789)).to eq 'https://api.app.net/files/56789?access_token=XXX'
33
83
  end
34
84
  end
35
85
  end
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+ require 'helpers'
3
+ require 'json'
4
+ #require 'io/console'
5
+
6
+ describe Ayadn::NiceRank do
7
+ before do
8
+ Ayadn::Settings.stub(:options).and_return(
9
+ {
10
+ timeline: {
11
+ directed: 1,
12
+ deleted: 0,
13
+ html: 0,
14
+ annotations: 1,
15
+ show_source: true,
16
+ show_symbols: true,
17
+ show_real_name: true,
18
+ show_date: true,
19
+ show_spinner: true,
20
+ show_debug: false
21
+ },
22
+ counts: {
23
+ default: 50,
24
+ unified: 100,
25
+ global: 100,
26
+ checkins: 100,
27
+ conversations: 50,
28
+ photos: 50,
29
+ trending: 100,
30
+ mentions: 100,
31
+ convo: 100,
32
+ posts: 100,
33
+ messages: 50,
34
+ search: 200,
35
+ whoreposted: 50,
36
+ whostarred: 50,
37
+ whatstarred: 100,
38
+ files: 100
39
+ },
40
+ formats: {
41
+ table: {
42
+ width: 75
43
+ }
44
+ },
45
+ colors: {
46
+ id: :blue,
47
+ index: :red,
48
+ username: :green,
49
+ name: :magenta,
50
+ date: :cyan,
51
+ link: :yellow,
52
+ dots: :blue,
53
+ hashtags: :cyan,
54
+ mentions: :red,
55
+ source: :cyan,
56
+ symbols: :green,
57
+ debug: :red
58
+ },
59
+ backup: {
60
+ auto_save_sent_posts: false,
61
+ auto_save_sent_messages: false,
62
+ auto_save_lists: false
63
+ },
64
+ scroll: {
65
+ timer: 3
66
+ },
67
+ nicerank: {
68
+ threshold: 2.1,
69
+ cache: 48,
70
+ filter: true,
71
+ filter_unranked: false
72
+ },
73
+ nowplaying: {},
74
+ movie: {
75
+ hashtag: 'nowwatching'
76
+ },
77
+ tvshow: {
78
+ hashtag: 'nowwatching'
79
+ }
80
+ }
81
+ )
82
+ Ayadn::Settings.stub(:config).and_return({
83
+ identity: {
84
+ username: 'test',
85
+ handle: '@test'
86
+ },
87
+ post_max_length: 256,
88
+ message_max_length: 2048,
89
+ version: 'wee'
90
+ })
91
+ Ayadn::Settings.stub(:user_token).and_return('XYZ')
92
+ Ayadn::Settings.stub(:check_for_accounts)
93
+ Ayadn::Errors.stub(:warn).and_return("warned")
94
+ Ayadn::Logs.stub(:rec).and_return("logged")
95
+ end
96
+
97
+ let(:rest) {Ayadn::CNX = double} #verbose in RSpec output, but useful
98
+ # let(:nicerank) { JSON.parse(File.read("spec/mock/nicerank.json")) }
99
+
100
+ describe "#get_posts_day" do
101
+ before do
102
+ rest.stub(:get).and_return(File.read("spec/mock/nicerank.json"))
103
+ end
104
+ it "get posts/day for a user" do
105
+ expect(rest).to receive(:get).with("http://api.nice.social/user/nicerank?ids=69904&show_details=Y")
106
+ x = Ayadn::NiceRank.new.get_posts_day(['69904'])
107
+ expect(x).to eq [{:id=>69904, :posts_day=>11.57}]
108
+ end
109
+ end
110
+ describe "#from_ids" do
111
+ before do
112
+ rest.stub(:get).and_return(File.read("spec/mock/nicerank.json"))
113
+ end
114
+ it "get niceranks from user ids" do
115
+ expect(rest).to receive(:get).with("http://api.nice.social/user/nicerank?ids=69904&show_details=Y")
116
+ x = Ayadn::NiceRank.new.from_ids(['69904'])
117
+ expect(x).to eq [{"user_id"=>69904,"rank"=>3.816259,"is_human"=>true,"user"=> {"username"=>"ericd","account_age"=>513,"following"=>277,"followers"=>261,"posts"=>5933,"stars"=>345,"posts_day"=>11.5653,"days_idle"=>0},"account"=> {"has_avatar"=>true,"has_bio"=>true,"has_cover"=>true,"is_verified"=>true,"is_human"=>true,"real_person"=>true},"stats"=>{"robo_posts"=>6,"post_count"=>294,"conversations"=>229,"links"=>36,"mentions"=>232,"questions"=>25}}]
118
+ end
119
+ end
120
+ end
@@ -51,12 +51,6 @@ describe Ayadn::Post do
51
51
  before do
52
52
  rest.stub(:post).and_return(File.read("spec/mock/posted.json"))
53
53
  end
54
- # it "should raise an error if args are empty" do
55
- # printed = capture_stdout do
56
- # post.post([])
57
- # end
58
- # expect(printed).to include "You should provide some text."
59
- # end
60
54
  it "posts a post" do
61
55
  expect(rest).to receive(:post).with("https://api.app.net/posts/?include_annotations=1&access_token=XYZ", {"text"=>"YOLO", "entities"=>{"parse_markdown_links"=>true, "parse_links"=>true}, "annotations"=>[{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]})
62
56
  x = post.post({text: 'YOLO'})
@@ -67,18 +61,6 @@ describe Ayadn::Post do
67
61
  end
68
62
  end
69
63
 
70
- # describe "#reply" do
71
- # it "formats a reply" do
72
- # new_post = "Hey guys!"
73
- # replied_to = {1=>{:handle => "@test",:username => "test", :mentions => ["user1", "user2"]}}
74
- # expect(post.reply(new_post, replied_to)).to eq "@test Hey guys! @user1 @user2"
75
- # replied_to = {1=>{:handle => "@test",:username => "test", :mentions => ["user1", "test"]}}
76
- # expect(post.reply(new_post, replied_to)).to eq "@test Hey guys! @user1"
77
- # replied_to = {1=>{:handle => "@yo",:username => "test", :mentions => ["test", "lol"]}}
78
- # expect(post.reply(new_post, replied_to)).to eq "@yo Hey guys! @lol"
79
- # end
80
- # end
81
-
82
64
  describe "#text_is_empty?" do
83
65
  it "checks if empty" do
84
66
  expect(post.text_is_empty?(["allo"])).to be false
@@ -99,6 +81,15 @@ describe Ayadn::Post do
99
81
  end
100
82
  end
101
83
 
84
+ describe "#post_size" do
85
+ it "tests if size of post string is ok" do
86
+ printed = capture_stderr do
87
+ 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)
88
+ end
89
+ expect(printed).to include 'Canceled: too long. 256 max, 4 characters to remove.'
90
+ end
91
+ end
92
+
102
93
  describe "#check_post_length" do
103
94
  it "checks normal post length" do
104
95
  expect(post.check_post_length(["allo", "wtf"])).to be nil #no error