2014-01-17 13:52:37 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-02-01 00:26:58 +00:00
|
|
|
describe HomePagePresenter do
|
2014-01-17 13:52:37 +00:00
|
|
|
|
|
|
|
let(:presenter) { described_class.new }
|
|
|
|
|
|
|
|
describe '#asciicast' do
|
|
|
|
subject { presenter.asciicast }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(CFG).to receive(:home_asciicast) { home_asciicast }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when home_asciicast is present" do
|
2014-01-18 11:21:33 +00:00
|
|
|
let(:home_asciicast) { double('home_asciicast',
|
|
|
|
decorate: decorated_asciicast) }
|
|
|
|
let(:decorated_asciicast) { double('decorated_asciicast') }
|
2014-01-17 13:52:37 +00:00
|
|
|
|
|
|
|
it "returns decorated asciicast" do
|
2014-01-18 11:21:33 +00:00
|
|
|
expect(subject).to be(decorated_asciicast)
|
2014-01-17 13:52:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when home_asciicast isn't present" do
|
|
|
|
let(:home_asciicast) { nil }
|
|
|
|
|
|
|
|
it { should be(nil) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-18 13:12:10 +00:00
|
|
|
describe '#playback_options' do
|
|
|
|
subject { presenter.playback_options }
|
|
|
|
|
|
|
|
it "has speed set to 2.0" do
|
|
|
|
expect(subject.speed).to eq(2.0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "has HUD hidden" do
|
|
|
|
expect(subject.hide_hud).to be(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-17 13:52:37 +00:00
|
|
|
describe '#latest_asciicasts' do
|
|
|
|
subject { presenter.latest_asciicasts }
|
|
|
|
|
2014-01-18 11:21:33 +00:00
|
|
|
let(:latest) { double('latest', decorate: decorated_latest) }
|
|
|
|
let(:decorated_latest) { double('decorated_latest') }
|
2014-01-17 13:52:37 +00:00
|
|
|
|
|
|
|
before do
|
2014-01-18 11:21:33 +00:00
|
|
|
allow(Asciicast).to receive(:latest_limited) { latest }
|
2014-01-17 13:52:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns decorated latest asciicasts" do
|
2014-01-18 11:21:33 +00:00
|
|
|
expect(subject).to be(decorated_latest)
|
2014-01-17 13:52:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#featured_asciicasts' do
|
|
|
|
subject { presenter.featured_asciicasts }
|
|
|
|
|
2014-01-18 11:21:33 +00:00
|
|
|
let(:featured) { double('featured', decorate: decorated_featured) }
|
|
|
|
let(:decorated_featured) { double('decorated_featured') }
|
2014-01-17 13:52:37 +00:00
|
|
|
|
|
|
|
before do
|
2014-01-18 11:21:33 +00:00
|
|
|
allow(Asciicast).to receive(:random_featured_limited) { featured }
|
2014-01-17 13:52:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns decorated random featured asciicasts" do
|
2014-01-18 11:21:33 +00:00
|
|
|
expect(subject).to be(decorated_featured)
|
2014-01-17 13:52:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|