asciinema.org/spec/presenters/home_page_presenter_spec.rb

74 lines
1.8 KiB
Ruby
Raw Normal View History

2014-01-17 13:52:37 +00:00
require 'spec_helper'
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
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
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
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 }
let(:latest) { double('latest', decorate: decorated_latest) }
let(:decorated_latest) { double('decorated_latest') }
2014-01-17 13:52:37 +00:00
before do
allow(Asciicast).to receive(:latest_limited) { latest }
2014-01-17 13:52:37 +00:00
end
it "returns decorated latest asciicasts" do
expect(subject).to be(decorated_latest)
2014-01-17 13:52:37 +00:00
end
end
describe '#featured_asciicasts' do
subject { presenter.featured_asciicasts }
let(:featured) { double('featured', decorate: decorated_featured) }
let(:decorated_featured) { double('decorated_featured') }
2014-01-17 13:52:37 +00:00
before do
allow(Asciicast).to receive(:random_featured_limited) { featured }
2014-01-17 13:52:37 +00:00
end
it "returns decorated random featured asciicasts" do
expect(subject).to be(decorated_featured)
2014-01-17 13:52:37 +00:00
end
end
end