Sha256: af1b28dd4e9bec3ce44c92c33c98acfbc9055ad04b708c58a5dad84e0e31a23d

Contents?: true

Size: 1.5 KB

Versions: 8

Compression:

Stored size: 1.5 KB

Contents

require 'spec/spec_helper'
require 'examples/amazon'

describe PITA::ItemSearchResponse do
  before do
    @response = PITA::ItemSearchResponse.from_xml(xml_for('amazon'))
  end

  describe "#total_results" do
    it "should be parsed as a number" do
      @response.total_results.should > 0
    end
  end

  describe "#total_pages" do
    it "should be parsed as a number" do
      @response.total_pages.should > 0
    end
  end

  describe "#items" do
    it "should return a collection of items" do
      @response.items.should be_an_instance_of(Array)
      @response.items.size.should > 0
      @response.items.each {|item| item.should be_an_instance_of(PITA::Item) }
    end

    it "should have the some number less than or equal to #total_results" do
      @response.items.size.should > 0
      @response.items.size.should <= @response.total_results
    end
  end
end

describe PITA::Item do
  before do
    @items = PITA::ItemSearchResponse.from_xml(xml_for('amazon')).items
  end

  it "should extract asin" do
    @items.each {|item| item.asin.should be_an_instance_of(String) }
    @items.each {|item| item.asin.should_not be_empty }
  end

  it "should extract detail_page_url" do
    @items.each {|item| item.detail_page_url.should be_an_instance_of(String) }
    @items.each {|item| item.detail_page_url.should_not be_empty }
  end

  it "should extract manufacturer" do
    @items.each {|item| item.manufacturer.should be_an_instance_of(String) }
    @items.each {|item| item.manufacturer.should_not be_empty }
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
yob-roxml-3.1.6 spec/examples/amazon_spec.rb
roxml-3.1.5 spec/examples/amazon_spec.rb
roxml-3.1.4 spec/examples/amazon_spec.rb
roxml-3.1.3 spec/examples/amazon_spec.rb
roxml-3.1.2 spec/examples/amazon_spec.rb
roxml-3.1.1 spec/examples/amazon_spec.rb
roxml-3.1.0 spec/examples/amazon_spec.rb
ROXML-3.0.0 spec/examples/amazon_spec.rb