asciinema.org/spec/presenters/home_page_presenter_spec.rb

70 lines
1.7 KiB
Ruby
Raw Normal View History

2014-08-30 17:38:47 +00:00
require 'rails_helper'
2014-01-17 13:52:37 +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
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
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(:homepage_latest) { 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(:homepage_featured) { featured }
2014-01-17 13:52:37 +00:00
end
it "returns decorated featured asciicasts" do
expect(subject).to be(decorated_featured)
2014-01-17 13:52:37 +00:00
end
end
end