Sha256: e5b7092e51275dbe128062b726c09f006c44beaacb7b116d06619cf542cc81e4

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Zelda::Omroep do
  before do
    @model = Zelda::Omroep.new(:foo => "bar")
  end
  
  it_should_behave_like 'a zelda base model'

  describe "when retrieving a list of omroepen" do
    it "should call Zelda with the correct url" do
      Zelda::Request.should_receive(:get).with("omroepen").and_return('omroepen' => ['omroep'])
      Zelda::Omroep.all.should == ['omroep']
    end
  end
  
  describe "when retrieving a specific omroep" do
    before(:each) do
      omroep_attrs = { "omroep" => {"slug" => "kro", "name" => "KRO"} }
      Zelda::Request.stub!(:get).with("omroepen/kro").and_return omroep_attrs
    end
    
    def find_omroep
      Zelda::Omroep.find('kro')
    end
    
    it "should call Zelda with the correct url" do
      Zelda::Request.should_receive(:get).with("omroepen/kro")
      find_omroep
    end
    
    it "should return a new Omroep" do
      find_omroep.should be_a(Zelda::Omroep)
    end
    
    it "should return nil if the omroep cannot be found" do
      Zelda::Request.stub!(:get).and_return nil
      find_omroep.should be_nil
    end
    
    it "should return the correct slug" do
      find_omroep.slug.should == "kro"
    end
    
    it "should return the correct name" do
      find_omroep.name.should == "KRO"
    end
  end
  
  describe "when retrieving the series for an omroep" do
    before(:each) do
      @omroep = Zelda::Omroep.new('slug' => 'kro')
      
      Zelda::Request.stub!(:get).and_return('omroep' => {'series' => {'serie' => [{'foo' => 'bar'}]}})
    end
    
    def find_series
      @omroep.series
    end
    
    it "should call Zelda with the correct url" do
      Zelda::Request.should_receive(:get).with("omroepen/kro/series")
      find_series
    end
    
    it "should return an array of series" do
      find_series.first.should be_a(Zelda::Serie)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zelda-0.1.0 spec/zelda/omroep_spec.rb