You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
Ruby
64 lines
1.3 KiB
Ruby
11 years ago
|
require 'spec_helper'
|
||
|
|
||
|
describe AsciicastList do
|
||
|
|
||
|
let(:list) { described_class.new(category, order, repository) }
|
||
|
|
||
|
let(:category) { 'featured' }
|
||
|
let(:order) { 'recency' }
|
||
|
let(:repository) { double('repository') }
|
||
|
|
||
|
describe '#category' do
|
||
|
subject { list.category }
|
||
|
|
||
|
context "when it was passed as a string" do
|
||
|
let(:category) { 'thecat' }
|
||
|
|
||
|
it { should eq(:thecat) }
|
||
|
end
|
||
|
|
||
|
context "when it was passed as nil" do
|
||
|
let(:category) { nil }
|
||
|
|
||
|
it { should eq(:all) }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe '#order' do
|
||
|
subject { list.order }
|
||
|
|
||
|
context "when it was passed as a string" do
|
||
|
let(:order) { 'thecat' }
|
||
|
|
||
|
it { should eq(:thecat) }
|
||
|
end
|
||
|
|
||
|
context "when it was passed as nil" do
|
||
|
let(:order) { nil }
|
||
|
|
||
|
it { should eq(:recency) }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe '#items' do
|
||
|
subject { list.items }
|
||
|
|
||
|
let(:category) { 'foo' }
|
||
|
let(:order) { 'bar' }
|
||
|
let(:asciicasts) { [Asciicast.new] }
|
||
|
|
||
|
before do
|
||
|
allow(repository).to receive(:for_category_ordered) { asciicasts }
|
||
|
subject
|
||
|
end
|
||
|
|
||
|
it { should eq(asciicasts) }
|
||
|
|
||
|
it 'calls for_category_ordered on repository with proper args' do
|
||
|
expect(repository).to have_received(:for_category_ordered).
|
||
|
with(:foo, :bar)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|