I did most of the initial work without any SCM. I am so bad.
[monoslider.git] / spec / slideshow_spec.rb
blob29b0ad40c3ca5eb512f393fc79c528d35bc9a0e7
1 require File.dirname(__FILE__) + '/spec_helper'
3 describe "Creating a slideshow from a single album without specifying prefs" do
4   
5   before(:each) do
6     @controller = Controller.new
7     @album = Model.new
8     @album.stub!(:slideshow_album_xml)
9   end
10   
11   it "should return a string" do
12     @controller.mono_slideshow_xml(@album).should be_an_instance_of String
13   end
14   
15   it "should call slideshow_album_xml on the album once" do
16     @album.should_receive(:slideshow_album_xml).once
17     @controller.mono_slideshow_xml(@album)
18   end
19   
20   it "should return expected XML doc with defaults" do
21     @album.should_receive(:slideshow_album_xml).once
22     slideshow = @controller.mono_slideshow_xml(@album)
23     slideshow.should be_an_instance_of String
24     pref_hash = {"imageScaleMode"=>"scaleToFit", "showAlbumsButton" => "false"}
25     Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}
26   end
27   
28   it "should convert each album to xml" do
29     @album.should_receive(:slideshow_album_xml).once
30     @controller.mono_slideshow_xml(@album)
31   end
32   
33 end
35 describe "Creating a slideshow from multiple albums" do
36   
37   before(:each) do
38     @controller = Controller.new
39     @album = Model.new
40     @album.stub!(:slideshow_album_xml)
41     @albums = [@album,@album]
42   end
44   
45   it "should return an xml doc" do
46     @album.should_receive(:slideshow_album_xml).twice
47     slideshow = @controller.mono_slideshow_xml(@albums)
48     slideshow.should be_an_instance_of String
49     pref_hash = {"imageScaleMode"=>"scaleToFit"}
50     Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}
51   end
52   
53   it "should convert each album to xml" do
54     @album.should_receive(:slideshow_album_xml).exactly(@albums.size).times
55     @controller.mono_slideshow_xml(@albums)
56   end
57   
58 end
60 describe "Specifying preferences for a slideshow" do
61   it "should return an XML doc with global prefs" do
62     @controller = Controller.new
63     @album = Model.new
64     @album.stub!(:slideshow_album_xml)
65     @albums = [@album,@album]
66     slideshow = @controller.mono_slideshow_xml(@albums, :showThumbnailsButton => :false, :imageScaleMode => :scaleToFill)
67     slideshow.should be_an_instance_of String
68     pref_hash = {"imageScaleMode"=>"scaleToFill", "showThumbnailsButton" => "false"}
69     Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}
70   end
71 end