Sha256: 50c85e2b1feac806419a3902df197160b497d73d7ae982e7e51806e484db5130

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

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

describe Zelda::Zender do
  describe "when retrieving a list of zenders" do
    it "should call Zelda with the correct url" do
      Zelda::Request.should_receive(:get).with("zenders")
      Zelda::Zender.all
    end
  end
  
  describe "when retrieving a specific zender" do
    before(:each) do
      zender_attrs = { "zender" => {"code" => "NL1", "name" => "Nederland 1"} }
      Zelda::Request.stub!(:get).with("zenders/1").and_return zender_attrs
    end
    
    def find_zender
      Zelda::Zender.find(1)
    end
    
    it "should call Zelda with the correct url" do
      Zelda::Request.should_receive(:get).with("zenders/1")
      find_zender
    end
    
    it "should return a new Zender" do
      find_zender.should be_a(Zelda::Zender)
    end
    
    it "should return the correct name" do
      find_zender.name.should == "Nederland 1"
    end
    
    it "should raise the correct error for an undefined attribute" do
      lambda { find_zender.foo }.should raise_error(NoMethodError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bartzon-zelda-0.0.1 spec/zelda/zender_spec.rb