Sha256: 5ec00f8a09a32e261c4d08b49bc9c9927589d185b4a25d5003b249300a709c77
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require 'acts_as_footprintable' require 'spec_helper' describe ActsAsFootprintable::Footprinter do it "should not be a footprinter" do NotUser.should_not be_footprinter end it "should be a footprinter" do User.should be_footprinter end describe "ユーザーのアクセス履歴を" do before do @user = User.create!(:name => "user") (1..5).each do |index| footprintable = Footprintable.create!(:name => "footprintable#{index}") second_footprintable = SecondFootprintable.create!(:name => "second_footprintable#{index}") 3.times do footprintable.leave_footprints @user second_footprintable.leave_footprints @user end end end context "対象のモデル毎に" do it "取得できること" do @user.access_histories_for(Footprintable).should have(5).items @user.access_histories_for(Footprintable).map{|footprintable| footprintable.name}.should == (1..5).to_a.reverse.map{|index| "footprintable#{index}"} end it "件数を絞り込めること" do @user.access_histories_for(Footprintable, 3).should have(3).items end end context "全てのモデルを通じて" do it "取得できること" do @user.access_histories.should have(10).items @user.access_histories.map{|footprintable| footprintable.name}.should == (1..5).to_a.reverse.inject([]) do |results, index| results.push "second_footprintable#{index}" results.push "footprintable#{index}" results end end it "件数を絞り込める事" do @user.access_histories(3).should have(3).items end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_footprintable-0.1.0 | spec/footprinter_spec.rb |