spec/lib/builder_spec.rb in radiodan-0.0.4 vs spec/lib/builder_spec.rb in radiodan-1.0.0
- old
+ new
@@ -5,14 +5,14 @@
before :each do
@player = mock
Radiodan::Player.stub(:new).and_return(@player)
end
- it 'passes a playlist to the player' do
+ it 'passes a playlist to the correct middleware' do
playlist = mock
- @player.should_receive(:playlist=).with(playlist)
+ Radiodan::Builder.any_instance.should_receive(:use).with(:playlist_to_start, playlist)
builder = Radiodan::Builder.new do |b|
b.playlist playlist
end
end
@@ -28,20 +28,41 @@
builder = Radiodan::Builder.new do |b|
b.adapter :mock_adapter, options
end
end
+ describe 'logger' do
+ it 'sets a log output and level' do
+ builder = Radiodan::Builder.new do |b|
+ b.log '/dev/null', :fatal
+ end
+
+ Radiodan::Logging.level.should == Logger::FATAL
+ Radiodan::Logging.output.should == '/dev/null'
+ end
+
+ it "has an optional log level" do
+ old_level = Radiodan::Logging.level
+
+ builder = Radiodan::Builder.new do |b|
+ b.log '/dev/null'
+ end
+
+ Radiodan::Logging.level.should == old_level
+ end
+ end
+
describe 'middleware' do
it 'creates an instance of middleware and stores internally' do
class Radiodan::MockMiddle; end
options, middleware = mock, mock
Radiodan::MockMiddle.should_receive(:new).with(options).and_return(middleware)
builder = Radiodan::Builder.new do |b|
b.use :mock_middle, options
end
-
+
builder.middleware.size.should == 1
builder.middleware.should include middleware
end
it 'executes middleware, passing player instance' do