spec/kosher/seller_spec.rb in kosher-0.1.12 vs spec/kosher/seller_spec.rb in kosher-0.2.0
- old
+ new
@@ -1,70 +1,56 @@
require 'spec_helper'
module Kosher
describe Seller do
- describe ".build" do
- use_vcr_cassette '0143105825'
+ before do
+ Config.blacklist = nil
+ end
- let(:asin) { '0143105825' }
-
- let(:response) do
- request = Request.new(credentials)
- request.locale = :us
- request.batchify([asin])
- algorithm = request.get
-
- algorithm.instance_variable_get(:@response)
+ describe "#blacklisted?" do
+ before do
+ Config.blacklist = ['foo']
end
- let(:seller) do
- docs = response.find('Merchant')
- Seller.build(docs.first)
+ it "returns true if the seller is blacklisted" do
+ Seller.new('foo').should be_blacklisted
end
- it "populates the merchant ID of a seller" do
- seller.merchant_id.should match /^[0-9A-Z]{13,14}$/
+ it "returns false if the seller is not blacklisted" do
+ Seller.new('bar').should_not be_blacklisted
end
+ end
- it "populates the name of a seller" do
- seller.name.should_not be_nil
+ describe "#kosher?" do
+ before do
+ Config.min_rating = 4.8
end
- it "populates the average rating of a seller" do
- seller.average_rating.should be_an_instance_of Float
+ it "returns true if seller's average rating is 0.0" do
+ seller = Seller.new('foo', 'bar', 0.0)
+ seller.should be_kosher
end
- it "builds a newly-launched seller" do
- doc = response.find('Merchant').detect { |doc| doc["AverageFeedbackRating"] == "0.0" }
- new_seller = Seller.build(doc)
-
- new_seller.average_rating.should eql 0.0
- end
- end
-
- describe "#kosher?" do
- it "returns true if seller's average rating is 0.0" do
- seller = Fabricate(:new_seller)
+ it "returns true if seller's average rating is nil" do
+ seller = Seller.new
seller.should be_kosher
end
- it "returns true if seller's average rating is above 4.7" do
- seller = Fabricate(:good_seller)
+ it "returns true if seller's average rating is equal to or above the min average rating" do
+ seller = Seller.new('foo', 'bar', 4.8)
seller.should be_kosher
end
- it "returns false if sellers' average rating is 4.7 or below" do
- seller = Fabricate(:bad_seller)
+ it "returns false if sellers' average rating is below the min average rating" do
+ seller = Seller.new('foo', 'bar', 4.7)
seller.should_not be_kosher
end
it "returns false if seller is blacklisted" do
- seller = Fabricate(:good_seller)
+ seller = Seller.new('foo', 'bar', 5.0)
seller.should be_kosher
- seller.merchant_id = Faker::Amazon.merchant_id
- Seller.blacklist = [seller.merchant_id]
-
+ Config.blacklist = [seller.id]
seller.should_not be_kosher
end
end
end
end