Sha256: 3f32f2838ffb16160bb0e48c22d70bea1098c5c89aba07c79d38c111449373ed

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

RSpec::Matchers.define :have_valid_kid_keys do |expected|
  match do |actual|
    actual.kid_date.to_s.should =~ /\d{1,5}/
    actual.kid_time.to_s.should =~ /\d{1,5}/
    actual.kid_user.should =~ /\w{4}/
    actual.kid_mult.to_s.should =~ /\d{1,3}/
    actual.kid_comm.to_s.should =~ /\d{1,3}/
  end
end


class Sequel::Model::Associations::OneToManyAssociationReflection
  # one_to_many associations can only have associated objects if none of
  # the :keys options have a nil value.
  def can_have_associated_objects?(obj)
    !self[:primary_keys].any?{|k| obj.send(k).nil?}
#     !self[:primary_keys].any?{|k| obj.send(:[],k).nil?}
  end
end

describe CityPair do

    it "sets kid values for new city_pair" do
      city_pair = CityPair.new
      begin
        city_pair.should have_valid_kid_keys
#        p CityPair.aliases
        p city_pair.city_costs
#        p city_pair.kid_user
#        p city_pair.send(:[],:'kid - user')
      rescue => e
        pp [e,e.backtrace]
      end
    end

    it "sets kid vlues for CityCost" do
#      city_pair = CityPair.new
#      city_cost = CityCost.new(:city_pair=>city_pair)
#      city_cost.should have_valid_kid_keys
#      city_pair.kid_date.to_s.should =~ /\d{4,5}/
#      city_pair.kid_time.to_s.should =~ /\d{4,5}/
#      city_pair.kid_user.should =~ /\w{4}/
#      city_pair.kid_mult.to_s.should =~ /\d{1,3}/
#      city_pair.kid_comm.to_s.should =~ /\d{1,3}/
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fossil-0.5.36 spec/models/city_pair_spec.rb
fossil-0.5.35 spec/models/city_pair_spec.rb