diff --git a/lib/far_mar.rb b/lib/far_mar.rb index 7b60d8ee..d4a1be8b 100644 --- a/lib/far_mar.rb +++ b/lib/far_mar.rb @@ -2,6 +2,7 @@ require "time" require "rspec" require "csv" +require "date" require "./lib/far_mar/market.rb" require "./lib/far_mar/vendor.rb" require "./lib/far_mar/product.rb" diff --git a/lib/far_mar/market.rb b/lib/far_mar/market.rb index 4d3a2c84..208e3864 100644 --- a/lib/far_mar/market.rb +++ b/lib/far_mar/market.rb @@ -1,15 +1,157 @@ -CSV.read("./support/markets.csv") module FarMar class Market - CSV.read("./support/markets.csv") - # @id = - # @name = - # @address = - # @city = - # @county = - # @state = - # @zip = + + attr_reader :id, :name + + def initialize(id, name, address, city, county, state, zip) + @id = id + @name = name + @address = address + @city = city + @county = county + @state = state + @zip = zip + end + + def self.all + @@all_markets ||= [] + + if @@all_markets == [] + CSV.read("./support/markets.csv").each do |line| + y = FarMar::Market.new(line[0].to_i, line[1], line[2], line[3], line[4], line[5], line[6]) + @@all_markets.push(y) + end + end + + return @@all_markets + end + + def self.find(id) + FarMar::Market.all.find do |market_instance| + market_instance.id == id + end + end + + def vendors + FarMar::Vendor.all.find_all do |vendor_instance| + vendor_instance.market_id == @id + end + end + + def products + # empty array to fill with collection of products + all_products = [] + + # get a collection of all vendors + all_vendors = vendors + + # to each vendor instance, run the products method to get a list of products, + # then push all of those proudcts into an array + all_vendors.each do |vendor_instance| + all_products.push(vendor_instance.products) + end + + # need to flatten all products so it doesn't return an array of arrays + return all_products.flatten! + end + + def self.search(search_term) + search_term_instances = [] + + markets = FarMar::Market.all + + markets.each do |mkt_instance| + if mkt_instance.name.match(/#{search_term}/i) + search_term_instances.push(mkt_instance) + end + + mkt_vendors = mkt_instance.vendors + + mkt_vendors.each do |vendor_instance| + if vendor_instance.name.match(/#{search_term}/i) + search_term_instances.push(mkt_instance) + end + end + end + return search_term_instances + end + + def prefered_vendor + highest_revenue = 0 + ven_highest_revenue = nil + + vendors.each do |vendor_instance| + ven_revenue = vendor_instance.revenue + if ven_revenue > highest_revenue + highest_revenue = ven_revenue + ven_highest_revenue = vendor_instance + end + end + return ven_highest_revenue + end + + def prefered_vendor_on(date) + date = DateTime.strptime(date, "%Y-%m-%d").to_date + highest_revenue = 0 + ven_highest_revenue = nil + + vendors.each do |vendor_instance| + vendor_instance.sales.each do |sales_instance| + sales_on_date = [] + revenue = 0 + if sales_instance.purchase_time.to_date == date + sales_on_date.push(sales_instance.amount) + end + if sales_on_date.length > 0 + sales_on_date.each {|amount| revenue += amount} + if revenue > highest_revenue + highest_revenue = revenue + ven_highest_revenue = vendor_instance + end + end + end + end + return ven_highest_revenue + end + + def worst_vendor + lowest_revenue = Float::INFINITY + ven_lowest_revenue = nil + + vendors.each do |vendor_instance| + ven_revenue = vendor_instance.revenue + if ven_revenue < lowest_revenue + lowest_revenue = ven_revenue + ven_lowest_revenue = vendor_instance + end + end + return ven_lowest_revenue + end + + def worst_vendor_on(date) + date = Date.parse(date) + lowest_revenue = Float::INFINITY + ven_lowest_revenue = nil + + vendors.each do |vendor_instance| + sales_on_date = [] + revenue = 0 + vendor_instance.sales.each do |sales_instance| + if sales_instance.purchase_time.to_date == date + sales_on_date.push(sales_instance.amount) + end + end + if sales_on_date.length > 0 + sales_on_date.each {|amount| revenue += amount} + if revenue < lowest_revenue + lowest_revenue = revenue + ven_lowest_revenue = vendor_instance + end + end + end + return ven_lowest_revenue + end end end diff --git a/lib/far_mar/product.rb b/lib/far_mar/product.rb index 433fcdaa..d7a06942 100644 --- a/lib/far_mar/product.rb +++ b/lib/far_mar/product.rb @@ -2,5 +2,63 @@ module FarMar class Product + attr_reader :id, :name, :vendor_id + + def initialize(id, name, vendor_id) + @id = id + @name = name + @vendor_id = vendor_id + end + + def self.all + @@all_products ||= [] + + if @@all_products == [] + CSV.read("./support/products.csv").each do |line| + y = FarMar::Product.new(line[0].to_i, line[1], line[2].to_i) + @@all_products.push(y) + end + end + + return @@all_products + end + + def self.find(id) + FarMar::Product.all.find do |product_instance| + product_instance.id == id + end + end + + def self.by_vendor(vendor_id) + FarMar::Product.all.find_all do |product_instance| + product_instance.vendor_id == vendor_id + end + end + + def vendor + FarMar::Vendor.all.find do |vendor_instance| + vendor_instance.id == @vendor_id + end + end + + def sales + FarMar::Sale.all.find_all do |sales_instance| + sales_instance.product_id == @id + end + end + + def number_of_sales + self.sales.length + end + + # def self.most_revenue(n) + # most_revenue = [] + # + # all.each do |product_instance| + # product_instance + # end + # + # + # end end end diff --git a/lib/far_mar/sale.rb b/lib/far_mar/sale.rb index a824f086..f5e64727 100644 --- a/lib/far_mar/sale.rb +++ b/lib/far_mar/sale.rb @@ -1,6 +1,54 @@ -CSV.read("./support/sales.csv") module FarMar class Sale + attr_reader :id, :amount, :purchase_time, :vendor_id, :amount, :product_id + + def initialize(id, amount, purchase_time, vendor_id, product_id) + @id = id + @amount = amount + @purchase_time = DateTime.strptime(purchase_time, "%Y-%m-%d %H:%M:%S %z") + @vendor_id = vendor_id + @product_id = product_id + end + + def self.all + @@all_sales ||= [] + + if @@all_sales == [] + CSV.read("./support/sales.csv").each do |line| + y = FarMar::Sale.new(line[0].to_i, line[1].to_i, line[2], line[3].to_i, line[4].to_i) + @@all_sales.push(y) + end + end + + return @@all_sales + end + + def self.find(id) + FarMar::Sale.all.find do |sale_instance| + sale_instance.id == id + end + end + + def self.between(beginning_time, end_time) + beginning_time = DateTime.strptime(beginning_time, "%Y-%m-%d %H:%M:%S %z") + end_time = DateTime.strptime(end_time, "%Y-%m-%d %H:%M:%S %z") + + FarMar::Sale.all.find_all do |sales_instance| + sales_instance.purchase_time >= beginning_time && sales_instance.purchase_time <= end_time + end + end + + def vendor + FarMar::Vendor.all.find do |vendor_instance| + vendor_instance.id == @vendor_id + end + end + + def product + FarMar::Product.all.find do |product_instance| + product_instance.id == @product_id + end + end end end diff --git a/lib/far_mar/vendor.rb b/lib/far_mar/vendor.rb index c9c2a7d1..39308f28 100644 --- a/lib/far_mar/vendor.rb +++ b/lib/far_mar/vendor.rb @@ -1,6 +1,117 @@ -CSV.read("./support/vendors.csv") module FarMar class Vendor + attr_reader :id, :name, :market_id + + def initialize(id, name, num_employees, market_id) + @id = id + @name = name + @num_employees = num_employees + @market_id = market_id + end + + def self.all + @@all_vendors ||= [] + + if @@all_vendors == [] + CSV.read("./support/vendors.csv").each do |line| + y = FarMar::Vendor.new(line[0].to_i, line[1], line[2].to_i, line[3].to_i) + @@all_vendors.push(y) + end + end + + return @@all_vendors + end + + def self.find(id) + FarMar::Vendor.all.find do |vendor_instance| + vendor_instance.id == id + end + end + + def market + FarMar::Market.all.find do |market_instance| + market_instance.id == @market_id + end + end + + def products + FarMar::Product.all.find_all do |product_instance| + product_instance.vendor_id == @id + end + end + + def sales + FarMar::Sale.all.find_all do |sales_instance| + sales_instance.vendor_id == @id + end + end + + def revenue + revenue = 0 + + sales.each do |sales_instance| + revenue += sales_instance.amount + end + + return revenue + end + + def self.by_market(market_id) + FarMar::Vendor.all.find_all do |vendor_instance| + vendor_instance.market_id == market_id + end + end + + def self.most_revenue(n) + vendors_by_revenue = [] + + all.each do |vendor| + vendors_by_revenue.push(vendor) + end + + vendors_by_revenue = vendors_by_revenue.sort_by { |vendor| vendor.revenue } + + return vendors_by_revenue[0...n] + end + + def self.most_items(n) + vendors_by_items = self.all + + vendors_by_items = vendors_by_items.sort_by { |vendor| vendor.products.length } + + return vendors_by_items[0...n] + + end + + def self.revenue(date) + date = DateTime.strptime(date, "%Y-%m-%d").to_date + revenue = 0 + + self.all.each do |vendor_instance| + vendor_instance.sales.each do |sales_instance| + if sales_instance.purchase_time.to_date == date + revenue += sales_instance.amount + end + end + end + + return revenue + end + + def revenue_on(date) + date = DateTime.strptime(date, "%Y-%m-%d").to_date + revenue = 0 + + sales.each do |sales_instance| + if sales_instance.purchase_time.to_date == date + revenue += sales_instance.amount + end + end + + return revenue + end + + end end diff --git a/spec/far_mar/market_spec.rb b/spec/far_mar/market_spec.rb index 9e8744b2..d1fc258d 100644 --- a/spec/far_mar/market_spec.rb +++ b/spec/far_mar/market_spec.rb @@ -1,12 +1,111 @@ require "./spec/spec_helper" describe FarMar::Market do + before :each do + @market1 = FarMar::Market.new(100, "name", "address", "city", "county", "state", "zip") + @market2 = FarMar::Market.new(400, "name", "address", "city", "county", "state", "zip") + end describe "#initialize" do it "creates new instance of market" do - @market1 = FarMar::Market.new - @market2 = FarMar::Market.new expect(@market1).to be_instance_of FarMar::Market expect(@market2).to be_instance_of FarMar::Market end + it "allows access to id of instance" do + expect(@market1.id).to eq 100 + end + end + describe "#self.all" do + it "returns an array" do + expect(FarMar::Market.all).to be_an Array + end + it "returns 500 items in array" do + expect(FarMar::Market.all.length).to eq 500 + end + end + describe "#self.find(id)" do + it "returns an instance of FarMar::Market" do + expect(FarMar::Market.find(1)).to be_instance_of FarMar::Market + end + it "returns correct instance of FarMar::Market" do + expect(FarMar::Market.find(1).name).to eq "People's Co-op Farmers Market" + expect(FarMar::Market.find(2).name).to eq "Silverdale Farmers Market" + end + end + describe "#vendors" do + it "returns an array" do + expect(@market1.vendors).to be_an Array + end + it "returns array of instances of FarMar::Vendor" do + expect(@market1.vendors[0]).to be_instance_of FarMar::Vendor + expect(@market1.vendors[-1]).to be_instance_of FarMar::Vendor + end + it "returns correct array length" do + expect(@market1.vendors.length).to eq 6 + expect(@market2.vendors.length).to eq 10 + end + it "returns correct first instance of FarMar::Vendor" do + expect(@market1.vendors[0].name).to eq "Schiller-Ledner" + expect(@market2.vendors[0].name).to eq "McLaughlin-Metz" + end + end + describe "#products" do + it "returns an array" do + expect(@market1.products).to be_an Array + end + it "returns an array of FarMar::Product instances" do + expect(@market1.products[0]).to be_instance_of FarMar::Product + end + it "returns correct first instance of FarMar::Vendor" do + expect(@market1.products[0].id).to eq 1594 + expect(@market2.products[0].id).to eq 6370 + end + end + describe ".self.search(search_term)" do + it "returns an array" do + expect(FarMar::Market.search("School")).to be_an Array + end + it "returns an array of FarMar::Market instances" do + expect(FarMar::Market.search("School")[0]).to be_instance_of FarMar::Market + end + it "returns correct num of results in array" do + expect(FarMar::Market.search("School").length).to eq 3 + expect(FarMar::Market.search("green").length).to eq 54 + end + end + describe "#prefered_vendor" do + it "returns an instance of FarMar::Vendor" do + expect(@market1.prefered_vendor).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + @market3 = FarMar::Market.new(2, "name", "address", "city", "county", "state", "zip") + expect(@market3.prefered_vendor.id).to eq 8 + end + end + describe "#prefered_vendor_on(date)" do + it "returns an instance of FarMar::Vendor" do + expect(@market1.prefered_vendor_on("2013-11-10")).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + @market3 = FarMar::Market.new(2, "name", "address", "city", "county", "state", "zip") + expect(@market3.prefered_vendor_on("2013-11-10").id).to eq 7 + end + end + describe "#worst_vendor" do + it "returns an instance of FarMar::Vendor" do + expect(@market1.worst_vendor).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + @market3 = FarMar::Market.new(2, "name", "address", "city", "county", "state", "zip") + expect(@market3.worst_vendor.id).to eq 9 + end + describe "#worst_vendor_on(date)" do + it "returns an instance of FarMar::Vendor" do + expect(@market1.worst_vendor_on("2013-11-10")).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + @market3 = FarMar::Market.new(2, "name", "address", "city", "county", "state", "zip") + expect(@market3.worst_vendor_on("2013-11-07").id).to eq 9 + end + end end end diff --git a/spec/far_mar/product_spec.rb b/spec/far_mar/product_spec.rb index 67f40228..4ab2935d 100644 --- a/spec/far_mar/product_spec.rb +++ b/spec/far_mar/product_spec.rb @@ -1,12 +1,94 @@ require "./spec/spec_helper" describe FarMar::Product do + before :each do + @product1 = FarMar::Product.new(5, "name", 100) + @product2 = FarMar::Product.new(6, "name", 400) + end describe "#initialize" do it "creates new instance of product" do - @product1 = FarMar::Product.new - @product2 = FarMar::Product.new expect(@product1).to be_instance_of FarMar::Product expect(@product2).to be_instance_of FarMar::Product end end + describe "#self.all" do + it "returns an array" do + expect(FarMar::Product.all).to be_an Array + end + it "returns 8193 items in array" do + expect(FarMar::Product.all.length).to eq 8193 + end + end + describe "#self.find(id)" do + it "returns an instance of FarMar::Product" do + expect(FarMar::Product.find(1)).to be_instance_of FarMar::Product + end + it "returns correct instance of FarMar::Vendor" do + expect(FarMar::Product.find(1).name).to eq "Dry Beets" + expect(FarMar::Product.find(2).name).to eq "Fierce Greens" + end + end + describe "#vendor" do + it "returns an instance of FarMar::Vendor" do + expect(@product1.vendor).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + expect(@product1.vendor.name).to eq "Bernier, Moen and Torp" + expect(@product2.vendor.name).to eq "Howe LLC" + end + end + describe "#sales" do + it "returns an instance of FarMar::Sale" do + expect(@product1.sales).to be_an Array + end + it "returns array of instances of FarMar::Sale" do + expect(@product1.sales[0]).to be_instance_of FarMar::Sale + expect(@product1.sales[-1]).to be_instance_of FarMar::Sale + end + it "returns correct array length" do + expect(@product1.sales.length).to eq 2 + expect(@product2.sales.length).to eq 1 + end + it "returns correct first instance of FarMar::Vendor" do + expect(@product1.sales[0].id).to eq 18 + expect(@product2.sales[0].id).to eq 19 + end + end + describe "#number_of_sales" do + it "returns an integer" do + expect(@product1.number_of_sales).to be_a Fixnum + end + it "returns correct num times a product has been sold" do + expect(@product1.number_of_sales).to eq 2 + expect(@product2.number_of_sales).to eq 1 + end + end + describe "#self.by_vendor(vendor_id)" do + it "returns an array" do + expect(FarMar::Product.by_vendor(5)).to be_an Array + expect(FarMar::Product.by_vendor(100)).to be_an Array + end + it "returns correct length of array" do + expect(FarMar::Product.by_vendor(5).length).to eq 3 + expect(FarMar::Product.by_vendor(100).length).to eq 5 + end + it "returns correct first item in array" do + expect(FarMar::Product.by_vendor(5)[0].id).to eq 8 + expect(FarMar::Product.by_vendor(100)[0].id).to eq 307 + end + end + # describe ".self.most_revenue(n)" do + # it "returns an array" do + # expect(FarMar::Product.most_revenue(5)).to be_an Array + # end + # it "returns instances of Product class" do + # expect(FarMar::Product.most_revenue(5)[0]).to be_instance_of FarMar::Product + # end + # it "returns correct length of array" do + # expect(FarMar::Product.most_revenue(5).length).to eq 5 + # end + # # it "returns correct first item in array" do + # # expect(FarMar::Product.by_vendor(5)[0].id).to eq 7848 + # # end + # end end diff --git a/spec/far_mar/sale_spec.rb b/spec/far_mar/sale_spec.rb index 0e75b5aa..f7a335ef 100644 --- a/spec/far_mar/sale_spec.rb +++ b/spec/far_mar/sale_spec.rb @@ -1,12 +1,60 @@ require "./spec/spec_helper" describe FarMar::Sale do + before :each do + @sale1 = FarMar::Sale.new(5,4440,"2013-11-10 05:19:05 -0800",1,1) + @sale2 = FarMar::Sale.new(100,4573,"2013-11-08 15:18:32 -0800",19,56) + end describe "#initialize" do it "creates new instance of sale" do - @sale1 = FarMar::Sale.new - @sale2 = FarMar::Sale.new expect(@sale1).to be_instance_of FarMar::Sale expect(@sale2).to be_instance_of FarMar::Sale end end + describe ".self.all" do + it "returns an array" do + expect(FarMar::Sale.all).to be_an Array + end + it "returns 12798 items in array" do + expect(FarMar::Sale.all.length).to eq 12798 + end + end + describe ".self.find(id)" do + it "returns an instance of FarMar::Sale" do + expect(FarMar::Sale.find(1)).to be_instance_of FarMar::Sale + end + it "returns correct instance of FarMar::Sale" do + expect(FarMar::Sale.find(1).amount).to eq 9290 + expect(FarMar::Sale.find(2).amount).to eq 2262 + end + end + describe "#vendor" do + it "returns an instance of FarMar::Vendor" do + expect(@sale1.vendor).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Vendor" do + expect(@sale1.vendor.name).to eq "Feil-Farrell" + expect(@sale2.vendor.name).to eq "Labadie-Tremblay" + end + end + describe "#product" do + it "returns an instance of FarMar::Product" do + expect(@sale1.product).to be_instance_of FarMar::Product + end + it "returns correct instance of FarMar::Product" do + expect(@sale1.product.name).to eq "Dry Beets" + expect(@sale2.product.name).to eq "Nom nom Beef" + end + end + describe ".self.between(beginning_time, end_time)" do + it "returns an array" do + expect(FarMar::Sale.between("2013-11-10 05:19:05 -0800","2013-11-08 15:18:32 -0800")).to be_an Array + end + it "returns array of correct length" do + expect(FarMar::Sale.between("2013-11-10 02:44:56 -0800","2013-11-10 02:44:56 -0800").length).to eq 1 + end + it "returns correct first item in array" do + expect(FarMar::Sale.between("2013-11-10 02:44:56 -0800","2013-11-10 02:44:56 -0800")[0].id).to eq 2 + end + end end diff --git a/spec/far_mar/vendor_spec.rb b/spec/far_mar/vendor_spec.rb index bf12a6c7..94951101 100644 --- a/spec/far_mar/vendor_spec.rb +++ b/spec/far_mar/vendor_spec.rb @@ -1,12 +1,127 @@ require "./spec/spec_helper" describe FarMar::Vendor do + before :each do + @vendor1 = FarMar::Vendor.new(5, "name", 7, 8) + @vendor2 = FarMar::Vendor.new(6, "name", 9, 10) + end describe "#initialize" do it "creates new instance of vendor" do - @vendor1 = FarMar::Vendor.new - @vendor2 = FarMar::Vendor.new expect(@vendor1).to be_instance_of FarMar::Vendor expect(@vendor2).to be_instance_of FarMar::Vendor end end + + describe "#self.all" do + it "returns an array" do + expect(FarMar::Vendor.all).to be_an Array + end + it "returns 2690 items in array" do + expect(FarMar::Vendor.all.length).to eq 2690 + end + end + describe ".self.find(id)" do + it "returns an instance of FarMar::Vendor" do + expect(FarMar::Vendor.find(1)).to be_instance_of FarMar::Vendor + expect(FarMar::Vendor.find(2)).to be_instance_of FarMar::Vendor + end + it "returns correct instance of FarMar::Market" do + expect(FarMar::Vendor.find(1).name).to eq "Feil-Farrell" + expect(FarMar::Vendor.find(2).name).to eq "Hamill, Kilback and Pfeffer" + end + end + describe "#market" do + it "returns instance of Market class" do + expect(@vendor1.market).to be_instance_of FarMar::Market + end + it "returns correct instance of Market class" do + expect(@vendor1.market.name).to eq "Charlestown Farmers Market" + expect(@vendor2.market.name).to eq "Saratoga Farmers' Market" + end + end + describe "#products" do + it "returns an array" do + expect(@vendor1.products).to be_an Array + end + it "returns array of correct length" do + expect(@vendor1.products.length).to eq 3 + expect(@vendor2.products.length).to eq 3 + end + it "returns correct first item in array" do + expect(@vendor1.products[0].name).to eq "Shaky Honey" + expect(@vendor2.products[0].name).to eq "Gigantic Bread" + end + end + describe "#sales" do + it "returns an array" do + expect(@vendor1.sales).to be_an Array + end + it "returns array of correct length" do + expect(@vendor1.sales.length).to eq 9 + expect(@vendor2.sales.length).to eq 1 + end + end + describe "#revenue" do + it "returns an integer" do + expect(@vendor1.revenue).to be_a Fixnum + end + it "returns correct total sales" do + expect(@vendor1.revenue).to eq 61749 + end + end + describe ".self.by_market" do + it "returns an array" do + expect(FarMar::Vendor.by_market(100)).to be_an Array + end + it "returns array composed of instances of vendors class" do + expect(FarMar::Vendor.by_market(100)[0]).to be_instance_of FarMar::Vendor + expect(FarMar::Vendor.by_market(100)[-1]).to be_instance_of FarMar::Vendor + end + it "returns correct number of vendors" do + expect(FarMar::Vendor.by_market(100).length).to eq 6 + expect(FarMar::Vendor.by_market(400).length).to eq 10 + end + end + describe ".self.most_revenue(n)" do + it "returns an array" do + expect(FarMar::Vendor.most_revenue(5)).to be_an Array + end + it "returns an array of instances of FarMar::Vendor" do + expect(FarMar::Vendor.most_revenue(5)[0]).to be_instance_of FarMar::Vendor + end + it "returns array of correct length" do + expect(FarMar::Vendor.most_revenue(5).length).to eq 5 + end + it "returns correct first instance in array, with highest revenue" do + expect(FarMar::Vendor.most_revenue(5)[0].revenue).to be >= FarMar::Vendor.most_revenue(5)[1].revenue + end + end + describe ".self.most_items(n)" do + it "returns an array of instances of FarMar::Vendor" do + expect(FarMar::Vendor.most_items(5)[0]).to be_instance_of FarMar::Vendor + end + it "returns array of correct length" do + expect(FarMar::Vendor.most_items(5).length).to eq 5 + end + it "returns correct first instance in array, with highest revenue" do + expect(FarMar::Vendor.most_items(5)[0].products.length).to be >= FarMar::Vendor.most_items(5)[1].products.length + end + end + describe "self.revenue(date)" do + it "returns a Fixnum" do + expect(FarMar::Vendor.revenue("2013-11-07")).to be_a Fixnum + end + it "returns correct revenue for a date" do + expect(FarMar::Vendor.revenue("2013-11-07")).to eq 9060582 + end + end + describe "#revenue_on(date)" do + it "returns a Fixnum" do + expect(@vendor1.revenue_on("2013-11-07")).to be_a Fixnum + end + it "Returns correct revenue amount" do + @vendor3 = FarMar::Vendor.new(7, "name", 9, 10) + expect(@vendor3.revenue_on("2013-11-07")).to eq 12377 + end + end end