spec/unit/view_spec.rb in ayadn-3.0 vs spec/unit/view_spec.rb in ayadn-4.0
- old
+ new
@@ -4,47 +4,120 @@
#require 'io/console'
describe Ayadn::View do
before do
- Ayadn::Settings.stub(:options).and_return({
+ Ayadn::Settings.stub(:options).and_return(
+ Ayadn::Preferences.new(
+ {
+ timeline: {
+ directed: true,
+ source: true,
+ symbols: true,
+ name: true,
+ date: true,
+ debug: false,
+ compact: false
+ },
+ marker: {
+ messages: true
+ },
+ counts: {
+ default: 50,
+ unified: 50,
+ global: 50,
+ checkins: 50,
+ conversations: 50,
+ photos: 50,
+ trending: 50,
+ mentions: 50,
+ convo: 50,
+ posts: 50,
+ messages: 20,
+ search: 200,
+ whoreposted: 20,
+ whostarred: 20,
+ whatstarred: 100,
+ files: 50
+ },
+ formats: {
+ table: {
+ width: 75,
+ borders: true
+ },
+ list: {
+ reverse: true
+ }
+ },
+ channels: {
+ links: true
+ },
colors: {
+ id: :blue,
+ index: :red,
+ username: :green,
+ name: :magenta,
+ date: :cyan,
+ link: :yellow,
+ dots: :blue,
hashtags: :cyan,
mentions: :red,
- username: :green,
- id: :blue,
- name: :yellow,
- source: :blue,
+ source: :cyan,
symbols: :green,
- index: :blue,
- date: :cyan,
- link: :magenta,
+ unread: :cyan,
+ debug: :red,
excerpt: :green
},
- timeline: {
- name: true,
- date: true,
- symbols: true,
- source: true
+ backup: {
+ posts: false,
+ messages: false,
+ lists: false
},
- formats: {
- table: {width: 75},
- list: {reverse: true}
+ scroll: {
+ spinner: true,
+ timer: 3,
+ date: false
},
- counts: {
- default: 33
+ nicerank: {
+ threshold: 2.1,
+ filter: true,
+ unranked: false
},
- blacklist: {active: true}
- })
- Ayadn::Settings.stub(:config).and_return({
- identity: {
- username: 'test'
+ nowplaying: {},
+ blacklist: {
+ active: true
}
- })
- Ayadn::Settings.stub(:global).and_return({
- scrolling: false
- })
+ }))
+ require 'json'
+ require 'ostruct'
+ obj =
+ {
+ identity: {
+ username: 'test',
+ handle: '@test'
+ },
+ post_max_length: 256,
+ message_max_length: 2048,
+ version: 'wee',
+ paths: {
+ db: 'spec/mock/',
+ log: 'spec/mock'
+ },
+ platform: 'shoes',
+ ruby: '0',
+ locale: 'gibberish'
+ }
+ Ayadn::Settings.stub(:config).and_return(
+ JSON.parse(obj.to_json, object_class: OpenStruct)
+ )
+ global_hash = {
+ scrolling: false,
+ force: false
+ }
+ Ayadn::Settings.stub(:global).and_return(
+ JSON.parse(global_hash.to_json, object_class: OpenStruct)
+ )
Ayadn::Logs.stub(:rec).and_return("logged")
Ayadn::Databases.stub(:blacklist).and_return("blacklist")
Ayadn::Databases.stub(:save_indexed_posts).and_return("indexed")
Ayadn::Databases.stub(:is_in_blacklist?).and_return(false)
end
@@ -164,11 +237,11 @@
end
describe "#show_posts" do
it 'outputs the stream' do
printed = capture_stdout do
- Ayadn::View.new.show_posts(stream['data'])
+ Ayadn::View.new.show_posts(Ayadn::StreamObject.new(stream))
end
expect(printed).to include "23184500"
expect(printed).to include "Backer of the Day"
expect(printed).to include '23184932'
expect(printed).to include '20:11:14'
@@ -178,30 +251,30 @@
end
describe "#show_raw" do
it 'outputs the raw stream' do
printed = capture_stdout do
- Ayadn::View.new.show_raw(stream['data'][0])
+ Ayadn::View.new.show_raw(Ayadn::StreamObject.new(stream))
end
expect(printed).to include '"created_at": "2013-05-19T22:33:57Z"'
end
end
describe "#show_simple_post" do
it 'outputs one post' do
printed = capture_stdout do
- Ayadn::View.new.show_simple_post([stream['data'][0]])
+ Ayadn::View.new.show_simple_post([Ayadn::StreamObject.new(stream).posts[0]])
end
expect(printed).to include "23187443"
expect(printed).to include "Julia Cory"
end
end
describe "#show_posts_with_index" do
it 'outputs the indexed stream' do
printed = capture_stdout do
- Ayadn::View.new.show_posts_with_index(stream['data'])
+ Ayadn::View.new.show_posts_with_index(Ayadn::StreamObject.new(stream))
end
expect(printed).to include "001"
expect(printed).to include "Backer of the Day"
end
end
@@ -210,10 +283,10 @@
before do
rest.stub(:get_response_from)
end
it "outputs user info" do
printed = capture_stdout do
- Ayadn::View.new.show_userinfos(user_e['data'], "")
+ Ayadn::View.new.show_userinfos(Ayadn::UserObject.new(user_e), "")
end
expect(printed).to include "Sound engineer"
expect(printed).to include "aya.io"
expect(printed).to include "69904"
expect(printed).to include "Eric"