Sha256: 60d03ded138439713586f19c6e4b1293c6fbba7b8f735302d4b3d72c740a3ee1

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe "Stew::Store::AppOffers" do
  let(:file_name){"49520_offers"}
  let(:node){Nokogiri.HTML(open("spec/fixtures/store/apps/#{file_name}.txt"))}

  subject{Stew::Store::AppOffers.new(node)}

  describe ".entries" do
    it "sets the app offers" do
      node.css("div.game_area_purchase_game").each do |item|
        Stew::Store::AppOffer.should_receive(:create).with(item)
      end
      Stew::Store::AppOffers.new(node)
    end

    it "has the correct amount of offers" do
      subject.count.should eq 4
    end

    it "has offers" do
      subject.each do |offer|
        offer.should be_a(Stew::Store::AppOffer)
      end
    end
  end

  describe ".sale?" do
    context "when the app has no sale" do
      it "returns false" do
        subject.sale?.should be_false
      end
    end

    context "when the app has a sale" do
      let(:file_name){"211400_offers_sale"}
      it "returns true" do
        subject.sale?.should be_true
      end
    end
  end

  describe ".sales" do
    context "when the app has no sale" do
      it "returns an empty array" do
        subject.sales.should eq []
      end
    end

    context "when the app is on sale" do
      let(:file_name){"211400_offers_sale"}

      it "returns an array of the AppOffers on sale" do
        subject.sales.count.should eq 2
      end

      it "returns an array of AppOfferSale objects" do
        subject.sales.each do |app_offer|
          app_offer.should be_a(Stew::Store::AppOfferSale)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stew-0.6.0 spec/lib/stew/store/app_offers_spec.rb
stew-0.5.3 spec/lib/stew/store/app_offers_spec.rb
stew-0.5.2 spec/lib/stew/store/app_offers_spec.rb
stew-0.5.1 spec/lib/stew/store/app_offers_spec.rb
stew-0.5.0 spec/lib/stew/store/app_offers_spec.rb