Sha256: 75d71d0a561b6d6da90e667195f3f79cbafc74f1682f866801482563c6bd650d
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require "spec_helper" require 'fixtures/item' require 'db/db_creator' require 'rand' describe Rand::Orders do %w[sqlite postgresql mysql].each do |adapter| context adapter do before(:all) do @db_creator = DBCreator.new adapter @db_creator.establish_connection end before(:each) do Item.delete_all @items = [] 5.times { |i| @items << Item.make!(amount: i) } end context "random method" do it "should return 5 records" do Item.random.size.should be_equal(5) end end context "random_in_range method" do it "should return 2 records" do Item.random_in_range(:amount, (2..5)).size.should be_equal(2) end end context "random_equal method" do it "should return item with amount equal 1" do Item.random_equal(:amount, 1).first.amount.should be_equal(1) end end context "select_random method" do it "should return only selected field" do Item.select_random(:amount).first.class.should be_equal(Fixnum) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rand-orders-0.0.3 | spec/rand-orders/rand_orders_spec.rb |