Sha256: f8e039ef98df069600a635828bb93bcdd49afe4a9cb2b6705e8353cae1d311db

Contents?: true

Size: 1.89 KB

Versions: 23

Compression:

Stored size: 1.89 KB

Contents

require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")

describe "'Data' source" do
  before :all do
    FakeWeb.register_uri("http://photos.tld/index.json", :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'))
    
    @source = Smoke.data(:photos) do
      url "http://photos.tld/index.json", :type => :json
      
      path :photos, :photo
    end
  end
  
  # it_should_behave_like "all sources"
  
  it "should have been activated" do
    Smoke[:photos].should(be_an_instance_of(Smoke::Source::Data))
  end
  
  it "should be a list of things" do
    Smoke[:photos].output.should be_an_instance_of(Array)
  end
  
  it "should respond to url" do
    Smoke[:photos].should respond_to(:url)
  end
  
  it "should hold the url used to query" do
    Smoke[:photos].request.uri.should == "http://photos.tld/index.json"
  end
  
  describe "results" do
    it "should have two items" do
      Smoke[:photos].output.size.should == 2
    end
    
    it "should be photo objects" do
      keys = [:ispublic, :title, :farm, :id, :isfamily, :server, :isfriend, :owner, :secret].each do |key|
        Smoke[:photos].output.first.should(have_key(key))
      end
    end
  end
  
  describe "making a request to a web service without a correctly set content-type in return" do
    before :each do
      FakeWeb.register_uri("http://photos.tld/no-format", :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'), :content_type => "text/plain")
    end
    
    it "should fail" do
      @source = Smoke.data(:flickr) do
        url "http://photos.tld/no-format"
        path :photos, :photo
      end
      lambda { @source.output }.should raise_error
    end
    
    it "should not fail" do
      @source = Smoke.data(:flickr) do
        url "http://photos.tld/no-format", :type => :json
        path :photos, :photo
      end
      lambda { @source.output }.should_not raise_error
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
benschwarz-smoke-0.3.11 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.4.0 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.4.1 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.4.2 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.0 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.1 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.10 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.13 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.2 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.3 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.4 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.5 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.6 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.7 spec/smoke/source/data_spec.rb
benschwarz-smoke-0.5.8 spec/smoke/source/data_spec.rb
smoke-0.5.16 spec/smoke/source/data_spec.rb
smoke-0.5.15 spec/smoke/source/data_spec.rb
smoke-0.5.14 spec/smoke/source/data_spec.rb
smoke-0.5.13 spec/smoke/source/data_spec.rb
smoke-0.5.12 spec/smoke/source/data_spec.rb