content_helper_spec.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. require File.dirname(__FILE__) + '/../spec_helper'
  2. describe ContentHelper, 'calc_distributed_class' do
  3.   include ContentHelper
  4.   it 'should behave as specified in the old test_calc_distributed_class_basic ' do
  5.     calc_distributed_class(0, 0, "prefix", 5, 15).should == 'prefix5'
  6.     (0..10).each do |article|
  7.       calc_distributed_class(article, 10, "prefix", 0, 10).should == "prefix#{article}"
  8.     end
  9.     (0..20).each do |article|
  10.       calc_distributed_class(article, 20, "prefix", 0, 10).should == "prefix#{(article/2).to_i}"
  11.     end
  12.     (0..5).each do |article|
  13.       calc_distributed_class(article, 5, "prefix", 0, 10).should == "prefix#{(article*2).to_i}"
  14.     end
  15.   end
  16.   it "should behave like the old test_calc_distributed_class_offset" do
  17.     (0..10).each do |article|
  18.       calc_distributed_class(article, 10, "prefix", 6, 16).should == "prefix#{article+6}"
  19.     end
  20.   end
  21. end