diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..19c66501 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/coverage/ +.DS_Store diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..82e5a661 --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.test_files = FileList['specs/*_spec.rb'] + end + +task default: :test diff --git a/far_mar.rb b/far_mar.rb new file mode 100644 index 00000000..cab74027 --- /dev/null +++ b/far_mar.rb @@ -0,0 +1,14 @@ +require 'csv' +require_relative './lib/market' +require_relative './lib/product' +require_relative './lib/sale' +require_relative './lib/vendor' + +module FarMar +end + +a = FarMar::Market.all.sample +puts a.vendors.length +puts a.products +puts a.products[0].vendor_id +puts a.products[2].vendor_id diff --git a/lib/market.rb b/lib/market.rb new file mode 100644 index 00000000..634b69e6 --- /dev/null +++ b/lib/market.rb @@ -0,0 +1,79 @@ +module FarMar + class Market + attr_reader :id, :name + + def initialize(market_hash) + + @id = market_hash[:id] + @name = market_hash[:name] + @address = market_hash[:address] + @city = market_hash[:city] + @county = market_hash[:county] + @state = market_hash[:state] + @zip = market_hash[:zip] + + end + + def self.read + markets = [] #array to store all of the hashes with market info + CSV.read("../FarMar/support/markets.csv").each do |line| + market = { + id: line[0].to_i, + name: line[1], + address: line[2], + city: line[3], + county: line[4], + state: line[5], + zip: line[6] + } #create a new hash for each market to store specific info + + markets << self.new(market) #creates a new instance with the hash info and puts it in the array to be returned + end + markets #returns this array + end + + def self.all #what happens if the csv file is updated - this variable will not include new data + @@all_markets ||= self.read + return @@all_markets + end + + def self.find(id) + if FarMar::Market.ids.include?(id) + self.all.find { |m| m.id == id } + else + raise ArgumentError.new("There are no vendors with that id") + end + end + + def vendors #returns a collection of FarMar::Vendor instances that are associated with the market + FarMar::Vendor.by_market(@id) #has clause for ArgError in method + end + + def self.ids + market_ids = [] + + self.all.each do |m| + market_ids << m.id + end + return market_ids + end + + def products #returns an array of Products that are associated to the market via the Vendor class + all_products = [] + + this_markets_vendors = FarMar::Vendor.by_market(@id) #returns array of Vendors + + this_markets_vendors.each do |v| + vendor_products = FarMar::Product.by_vendor(v.id) #returns array of Products + vendor_products.each do |pro| + all_products << pro + end + end + return all_products + end + + #find all vendors associated with this market + #find all products associated with those vendors + #end + end +end diff --git a/lib/product.rb b/lib/product.rb new file mode 100644 index 00000000..05e4f872 --- /dev/null +++ b/lib/product.rb @@ -0,0 +1,63 @@ +module FarMar + class Product + attr_reader :id, :name, :vendor_id + + def initialize(product_hash) + @id = product_hash[:id] + @name = product_hash[:name] + @vendor_id = product_hash[:vendor_id] + end + + def self.read + products = [] #array to store all of the hashes with product info + CSV.read("../FarMar/support/products.csv").each do |line| + product = {id: line[0].to_i, name: line[1], vendor_id: line[2].to_i} #create a new hash for each product to store specific info + + products << self.new(product) #creates a new instance with the hash info and puts it in the array to be returned + end + products #returns this array + end + + def self.all #what happens if the csv file is updated - this variable will not include new data + @@all_products ||= self.read + return @@all_products + end + + def self.find(id) + if FarMar::Product.ids.include?(id) + self.all.find { |pro| pro.id == id } + else + raise ArgumentError.new("There are no products with that id") + end + end + + def vendor #returns the object:Vendor instance that is associated with Product + FarMar::Vendor.find(@vendor_id) + end + + def sales #returns an array of Sale objects that are accociated with this product + FarMar::Sale.all.select { |s| s.product_id == @id } + end + + def number_of_sales #returns the number of times this product has been sold + sales.length + end + + def self.by_vendor(vendor_id) #returns all the products associated with the given vendor_id + if FarMar::Vendor.ids.include?(vendor_id) + self.all.select { |pro| pro.vendor_id == vendor_id } + else + raise ArgumentError.new("There are no vendors with that id") + end + end + + def self.ids + product_ids = [] + + self.all.each do |pro| + product_ids << pro.id + end + return product_ids + end + end +end diff --git a/lib/sale.rb b/lib/sale.rb new file mode 100644 index 00000000..248f5693 --- /dev/null +++ b/lib/sale.rb @@ -0,0 +1,58 @@ +module FarMar + class Sale + attr_reader :id, :amount, :vendor_id, :product_id, :purchase_time + + def initialize(sale_hash) + @id = sale_hash[:id] + @amount = sale_hash[:amount] + @purchase_time = sale_hash[:purchase_time] + @vendor_id = sale_hash[:vendor_id] + @product_id = sale_hash[:product_id] + end + + def self.read + # IDEA make this an instance variable so you only have to make it run once + sales = [] #array to store all of the hashes with sale info + CSV.read("../FarMar/support/sales.csv").each do |line| + sale = {id: line[0].to_i, amount: line[1].to_i, purchase_time: DateTime.parse(line[2]), vendor_id: line[3].to_i, product_id: line[4].to_i } #create a new hash for each sale to store specific info + + sales << self.new(sale) #creates a new instance with the hash info and puts it in the array to be returned + end + sales #returns this array + end + + def self.all #what happens if the csv file is updated - this variable will not include new data + @@all_sales ||= self.read + return @@all_sales + end + + def self.find(id) + if FarMar::Sale.ids.include?(id) + self.all.find { |s| s.id == id } + else + raise ArgumentError.new("There are no sales with that id") + end + end + + def vendor #returns the Vendor instance that is associated with this sale + FarMar::Vendor.find(@vendor_id) + end + + def product + FarMar::Product.find(@product_id) + end + + def self.between(beginning_time, end_time) + self.all.select { |s| beginning_time <= s.purchase_time && s.purchase_time <= end_time } + end + + def self.ids + sale_ids = [] + + self.all.each do |s| + sale_ids << s.id + end + return sale_ids + end + end +end diff --git a/lib/vendor.rb b/lib/vendor.rb new file mode 100644 index 00000000..0f5887c5 --- /dev/null +++ b/lib/vendor.rb @@ -0,0 +1,82 @@ +module FarMar + class Vendor + attr_reader :id, :name, :num_employees, :market_id + + def initialize(vendor_hash) + @id = vendor_hash[:id] + @name = vendor_hash[:name] + @num_employees = vendor_hash[:num_employees] + @market_id = vendor_hash[:market_id] + end + + def self.read #returns an array of objects:Vendors + vendors = [] #array to store all of the hashes with vendor info + CSV.read("../FarMar/support/vendors.csv").each do |line| + vendor = {id: line[0].to_i, name: line[1], num_employees: line[2].to_i, market_id: line[3].to_i} #create a new hash for each vendor to store specific info + + vendors << self.new(vendor) #creates a new instance with the hash info and puts it in the array to be returned + end + vendors #returns this array + end + + def self.all #what happens if the csv file is updated - this variable will not include new data + @@all_vendors ||= self.read + return @@all_vendors + end + + def self.find(id) #returns the object:Vendor with arg. id + if FarMar::Vendor.ids.include?(id) + self.all.find { |v| v.id == id } + else + raise ArgumentError.new("There are no vendors with that id") + end + + #OLD CODE WITH .each LOOP + # self.all.each do |v| + # if v.id == id + # return v #returns the object whose id matches the argument + # end + # end + end + + def market #returns the object:Market that this vendor belongs to + FarMar::Market.find(@market_id) + end + + def products #returns an array of object:Products that belong to this Vendor + FarMar::Product.by_vendor(@id) + end + + def sales #returns a collection of object:Sales that are associated with this vendor + FarMar::Sale.all.select { |s| s.vendor_id == @id } + end + + def revenue #returns the sum of all the vendor's sales + total = 0 + self.sales.each do |s| + total += s.amount + end + return total + end + + def self.by_market(market_id) #returns an array of the vendors with the given market_id + # self.all.select { |v| v.market_id == market_id } + + if FarMar::Market.ids.include?(market_id) + self.all.select { |v| v.market_id == market_id } + else + raise ArgumentError.new("There are no vendors associated with this market") + end + end + + def self.ids + vendor_ids = [] + + self.all.each do |v| + vendor_ids << v.id + end + return vendor_ids + end + + end +end diff --git a/specs/market_spec.rb b/specs/market_spec.rb new file mode 100644 index 00000000..5f561626 --- /dev/null +++ b/specs/market_spec.rb @@ -0,0 +1,113 @@ +require_relative 'spec_helper' + +module FarMar + describe Market do + + describe "#initialize" do + let(:new_market) { Market.new({}) } + + it "should create a new instace of Market" do + new_market.must_be_instance_of(Market) + end + end + + describe ".read" do + it "should return an array" do + Market.read.must_be_kind_of(Array) + end + + it "should return an object: Market at any index of the array" do + Market.read[0].must_be_instance_of(Market) + Market.read[10].must_be_instance_of(Market) + Market.read[20].must_be_instance_of(Market) + end + end + + describe "self.all" do + it "should return an array" do + Market.all.must_be_kind_of(Array) + end + + it "should return an object: Market at any index of the array" do + Market.all[0].must_be_instance_of(Market) + Market.all[10].must_be_instance_of(Market) + Market.all[20].must_be_instance_of(Market) + end + end + + describe ".find(id)" do + it "should return an object: Market with name Scottdale Farmers Market at ID 20" do + scots = Market.find(20) + + scots.must_be_instance_of(Market) + scots.name.must_equal("Scottdale Farmers Market") + end + + it "should raise argument error when given an invalid id" do + proc { Market.find(987654321) }.must_raise(ArgumentError) + end + end + + describe "#vendors" do + before(:each) do #unnecessary because the tests dont change the values of this variable, but I wanted to try it out + @example_market = Market.new({id: 4, name: "Allison's Market", address: "address", city: "city", county: "county", state: "state", zip: "zip"}) + @four = @example_market.vendors + @another_market = Market.new({id: 987654321987654321, name: "Dustin's Market"}) + end + + it "returns an array" do + @example_market.vendors.must_be_kind_of(Array) + end + + it "should return an object: Vendor at any index of the array" do + @four[0].must_be_instance_of(Vendor) + @four[1].must_be_instance_of(Vendor) + @four[2].must_be_instance_of(Vendor) + end + + it "should return the correct market_id that matches the one searched" do + @four[0].market_id.must_equal(4) + @four[1].market_id.must_equal(4) + @four[2].market_id.must_equal(4) + end + end + + describe "self.ids" do + it "should return an array" do + Market.ids.must_be_kind_of(Array) + end + + it "should have a fixnum at any index of the array" do + Market.ids[0].must_be_kind_of(Fixnum) + Market.ids[10].must_be_kind_of(Fixnum) + Market.ids[50].must_be_kind_of(Fixnum) + end + + it "should have id numbers at the correct index of the array" do + Market.ids[0].must_equal(Market.all[0].id) + Market.ids[10].must_equal(Market.all[10].id) + Market.ids[50].must_equal(Market.all[50].id) + end + end + + describe "#products" do + before(:each) do #unnecessary because the tests dont change the values of this variable, but I wanted to try it out + @example_market = Market.new({id: 4, name: "Allison's Market", address: "address", city: "city", county: "county", state: "state", zip: "zip"}) + end + + it "should return an array" do + @example_market.products.must_be_kind_of(Array) + end + + it "should have an object:Product at any index of the array" do + @example_market.products[0].must_be_instance_of(Product) + @example_market.products[2].must_be_instance_of(Product) + end + + it "all products should have the correct market id" do + @example_market.products[0].vendor_id.between?(13, 16).must_equal(true) + @example_market.products[3].vendor_id.between?(13, 16).must_equal(true) + end + end + end +end diff --git a/specs/product_spec.rb b/specs/product_spec.rb new file mode 100644 index 00000000..1d7d1f02 --- /dev/null +++ b/specs/product_spec.rb @@ -0,0 +1,121 @@ +require_relative 'spec_helper' + +module FarMar + describe Product do + + describe "#initialize" do + let(:new_product) { Product.new({}) } + + it "should create a new instace of Product" do + new_product.must_be_instance_of(Product) + end + end + + describe ".read" do + let(:read_products) { Product.read } + + it "should return an array" do + read_products.must_be_kind_of(Array) + end + + it "should return an object: Product at any index of the array" do + read_products[0].must_be_instance_of(Product) + read_products[10].must_be_instance_of(Product) + read_products[20].must_be_instance_of(Product) + end + end + + describe ".all" do + let(:all_products) { Product.all } + + it "should return an array" do + all_products.must_be_kind_of(Array) + end + + it "should return an object: Product at any index of the array" do + all_products[0].must_be_instance_of(Product) + all_products[10].must_be_instance_of(Product) + all_products[20].must_be_instance_of(Product) + end + end + + describe ".find(id)" do + it "should return an object: Product with name Tall Pretzel at ID 20" do + tp = Product.find(20) + + tp.must_be_instance_of(Product) + tp.name.must_equal("Tall Pretzel") + end + + it "should raise argument error when given an invalid id" do + proc { Product.find(987654321) }.must_raise(ArgumentError) + end + end + + describe "#vendor" do + let(:new_product) { Product.new({id: 213, name: "greens", vendor_id: 4}) } + + it "should return a object:Vendor" do + new_product.vendor.must_be_instance_of(Vendor) + end + + it "should return the correct Vendor" do + new_product.vendor.name.must_equal("Kris and Sons") + end + end + + describe "#sales" do + let(:new_product) { Product.new({id: 21, name: "greens", vendor_id: 4}) } + + it "should return an array" do + new_product.sales.must_be_kind_of(Array) + end + + it "should have an object:Sale at any index of that array" do + #puts new_product.sales + new_product.sales[0].must_be_instance_of(Sale) + new_product.sales[1].must_be_instance_of(Sale) + end + + it "should have the correct sales in the array" do + new_product.sales[0].amount.must_equal(2510) + new_product.sales[1].amount.must_equal(9341) + end + end + + describe "#number_of_sales" do + let(:new_product) { Product.new({id: 21, name: "greens", vendor_id: 4}) } + + it "should return a fixnum" do + #puts new_product.number_of_sales + new_product.number_of_sales.must_be_kind_of(Fixnum) + end + + it "should return the correct number of sales" do + new_product.number_of_sales.must_equal(2) + end + end + + describe "self.by_vendor(vendor_id)" do + let(:example_vendor) { Vendor.new({id: 5, name: "Allison", num_employees: 75, market_id: 6}) } + + it "should return an array" do + FarMar::Product.by_vendor(example_vendor.id).must_be_kind_of(Array) + end + + it "should return an object: Product at any index of the array" do + FarMar::Product.by_vendor(example_vendor.id)[0].must_be_instance_of(Product) + FarMar::Product.by_vendor(example_vendor.id)[2].must_be_instance_of(Product) + end + + it "each object returned should be associated with the correct vendor_id by checking the name" do #IS THIS A BETTER TEST? + FarMar::Product.by_vendor(example_vendor.id)[0].name.must_equal("Shaky Honey") + FarMar::Product.by_vendor(example_vendor.id)[2].name.must_equal("Black Apples") + end + + it "should raise an argument error if invalid vendor id is supplied" do + proc { FarMar::Product.by_vendor(98765432) }.must_raise(ArgumentError) + end + end + end +end diff --git a/specs/sale_spec.rb b/specs/sale_spec.rb new file mode 100644 index 00000000..1e003358 --- /dev/null +++ b/specs/sale_spec.rb @@ -0,0 +1,121 @@ +require_relative 'spec_helper' + +module FarMar + describe Sale do + + describe "#initialize" do + let(:new_sale) { Sale.new({}) } + + it "should create a new instace of Sale" do + new_sale.must_be_instance_of(Sale) + end + end + + describe ".read" do + let(:read_sales) { Sale.read } + + it "should return an array" do + #puts FarMar::Sale.read.length + read_sales.must_be_kind_of(Array) + end + + it "should return an object: Sale at any index of the array" do + read_sales[0].must_be_instance_of(Sale) + read_sales[10].must_be_instance_of(Sale) + read_sales[20].must_be_instance_of(Sale) + end + end + + describe ".all" do + let(:all_sales) { Sale.all } + + it "should return an array" do + #puts FarMar::Sale.all.length + all_sales.must_be_kind_of(Array) + end + + it "should return an object: Sale at any index of the array" do + all_sales[0].must_be_instance_of(Sale) + all_sales[10].must_be_instance_of(Sale) + all_sales[20].must_be_instance_of(Sale) + end + end + + describe ".find(id)" do + it "should return an object: Sale with amount 51 at ID 20" do + tp = Sale.find(20) + + tp.must_be_instance_of(Sale) + tp.amount.must_equal(51) + end + + it "should raise argument error when given an invalid id" do + proc { Sale.find(987654321) }.must_raise(ArgumentError) + end + end + + describe "#vendor" do + let(:new_sale) { Sale.new({vendor_id: 5}) } + + it "should return an object:Vendor" do + new_sale.vendor.must_be_instance_of(Vendor) + end + + it "should return the correct vendor" do + new_sale.vendor.name.must_equal("Reynolds, Schmitt and Klocko") + end + end + + describe "#product" do + let(:new_sale) { Sale.new({product_id: 5}) } + it "should return an object:Product" do + new_sale.product.must_be_instance_of(Product) + end + + it "should return the correct Product" do + new_sale.product.name.must_equal("Green Apples") + end + end + + describe "self.between(beginning_time, end_time)" do + let(:sales_between) { Sale.between(DateTime.parse("2013-11-10 05:19:05 -0800"), DateTime.parse("2013-11-13 01:48:15 -0800")) } + + it "should return an array" do + sales_between.must_be_kind_of(Array) + end + + it "should have an object:Sale at any index of the array" do + #puts sales_between.length + sales_between[0].must_be_instance_of(Sale) + sales_between[10].must_be_instance_of(Sale) + sales_between[50].must_be_instance_of(Sale) + sales_between[100].must_be_instance_of(Sale) + end + + it "the time of the sale at any index should be between the arguments(beg_time, end_time)" do + (sales_between[0].purchase_time.between?(DateTime.parse("2013-11-10 05:19:05 -0800"), DateTime.parse("2013-11-13 01:48:15 -0800"))).must_equal(true) + (sales_between[10].purchase_time.between?(DateTime.parse("2013-11-10 05:19:05 -0800"), DateTime.parse("2013-11-13 01:48:15 -0800"))).must_equal(true) + (sales_between[50].purchase_time.between?(DateTime.parse("2013-11-10 05:19:05 -0800"), DateTime.parse("2013-11-13 01:48:15 -0800"))).must_equal(true) + (sales_between[100].purchase_time.between?(DateTime.parse("2013-11-10 05:19:05 -0800"), DateTime.parse("2013-11-13 01:48:15 -0800"))).must_equal(true) + end + end + + describe "self.ids" do + it "should return an array" do + Sale.ids.must_be_kind_of(Array) + end + + it "should have a fixnum at any index of the array" do + Sale.ids[0].must_be_kind_of(Fixnum) + Sale.ids[10].must_be_kind_of(Fixnum) + Sale.ids[50].must_be_kind_of(Fixnum) + end + + it "should have id numbers at the correct index of the array" do + Sale.ids[0].must_equal(Sale.all[0].id) + Sale.ids[10].must_equal(Sale.all[10].id) + Sale.ids[50].must_equal(Sale.all[50].id) + end + end + end +end diff --git a/specs/spec_helper.rb b/specs/spec_helper.rb new file mode 100644 index 00000000..6e851fe8 --- /dev/null +++ b/specs/spec_helper.rb @@ -0,0 +1,13 @@ +require 'simplecov' +SimpleCov.start + + +require 'minitest' +require 'minitest/spec' +require "minitest/autorun" +require "minitest/reporters" +require 'minitest/pride' + +require_relative "../far_mar" + +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/specs/vendor_spec.rb b/specs/vendor_spec.rb new file mode 100644 index 00000000..6f910711 --- /dev/null +++ b/specs/vendor_spec.rb @@ -0,0 +1,158 @@ +require_relative 'spec_helper' + +module FarMar + describe Vendor do + + describe "#initialize" do + let(:new_vendor) { Vendor.new({}) } + + it "should create a new instace of Vendor" do + new_vendor.must_be_instance_of(Vendor) + end + end + + describe ".read" do + it "should return an array" do + Vendor.read.must_be_kind_of(Array) + end + + it "should return an object: Vendor at any index of the array" do + Vendor.read[0].must_be_instance_of(Vendor) + Vendor.read[10].must_be_instance_of(Vendor) + Vendor.read[20].must_be_instance_of(Vendor) + end + end + + describe "self.all" do + it "should return an array" do + Vendor.all.must_be_kind_of(Array) + end + + it "should return an object: Vendor at any index of the array" do + Vendor.all[0].must_be_instance_of(Vendor) + Vendor.all[10].must_be_instance_of(Vendor) + Vendor.all[20].must_be_instance_of(Vendor) + end + end + + describe ".find(id)" do + it "should return an object: Vendor with name Ledner Group at ID 20" do + led = Vendor.find(20) + + led.must_be_instance_of(Vendor) + led.name.must_equal("Ledner Group") + end + + it "should raise argument error when given an invalid id" do + proc { Vendor.find(987654321) }.must_raise(ArgumentError) + end + end + + describe "#market" do + let(:example_vendor) { Vendor.new({id: 9876, name: "Allison", num_employees: 75, market_id: 6}) } + + it "should return an object: Market" do + example_vendor.market.must_be_instance_of(Market) + end + + it "should return the correct instance of Market" do + jcfm = example_vendor.market + jcfm.name.must_equal("Jefferson City Farmer's Market") + jcfm.id.must_equal(6) + end + end + + describe "#products" do + before(:each) do + @example_vendor = Vendor.new({id: 5, name: "Allison", num_employees: 75, market_id: 6}) + end + + it "should return an array" do + @example_vendor.products.must_be_kind_of(Array) + end + + it "should return an object: Product at any index of the array" do + @example_vendor.products[0].must_be_instance_of(Product) + @example_vendor.products[2].must_be_instance_of(Product) + end + + it "each object should have the correct vendor id" do #IS THIS A BETTER TEST? + @example_vendor.products[0].vendor_id.must_equal(@example_vendor.id) + @example_vendor.products[2].vendor_id.must_equal(@example_vendor.id) + end + end + + describe "#sales" do + let(:example_vendor) { Vendor.new({id: 5, name: "Allison", num_employees: 75, market_id: 6}) } + + it "should return an array" do + example_vendor.sales.must_be_kind_of(Array) + end + + it "should return an object:Sale at any index of the array" do + #puts example_vendor.sales + + example_vendor.sales[0].must_be_instance_of(Sale) + example_vendor.sales[8].must_be_instance_of(Sale) + end + + it "each sale should have the correct vendor id" do + example_vendor.sales[0].vendor_id.must_equal(example_vendor.id) + end + end + + describe "#revenue" do + let(:example_vendor) { Vendor.new({id: 5, name: "Allison", num_employees: 75, market_id: 6}) } + + it "should return a fixnum" do + example_vendor.revenue.must_be_kind_of(Fixnum) + end + + it "should return the correct amount" do + example_vendor.revenue.must_equal(61749) + end + end + + describe "self.by_market(market_id)" do + let(:vendors_by_market) { Vendor.by_market(4) } + let(:example_market) { Market.new({id: 987654321987654321})} + + it "should return an array" do + vendors_by_market.must_be_kind_of(Array) + end + + it "should have an object:Vendor at any index of the array" do + vendors_by_market[0].must_be_instance_of(Vendor) + vendors_by_market[3].must_be_instance_of(Vendor) + end + + it "should return the correct vendors" do + vendors_by_market[0].id.must_equal(13) + vendors_by_market[2].id.must_equal(15) + vendors_by_market[3].id.must_equal(16) + end + + it "should raise and ArgumentError if there is no vendor with that market id" do + proc{ Vendor.by_market(example_market.id) }.must_raise(ArgumentError) + end + end + + describe "self.ids" do + it "should return an array" do + Vendor.ids.must_be_kind_of(Array) + end + + it "should have a fixnum at any index of the array" do + Vendor.ids[0].must_be_kind_of(Fixnum) + Vendor.ids[10].must_be_kind_of(Fixnum) + Vendor.ids[50].must_be_kind_of(Fixnum) + end + + it "should have id numbers at the correct index of the array" do + Vendor.ids[0].must_equal(Vendor.all[0].id) + Vendor.ids[10].must_equal(Vendor.all[10].id) + Vendor.ids[50].must_equal(Vendor.all[50].id) + end + end + end +end