Sha256: 9cfbe6841910fe76c8d938ea579ddbd240d9a76b9feac7b027cba723dd1f4709
Contents?: true
Size: 1.67 KB
Versions: 8
Compression:
Stored size: 1.67 KB
Contents
require File.expand_path(File.dirname(__FILE__) + "/spec_helper.rb") describe "has_counter:", "using default after_create and after_destroy callbacks" do before :each do Counter.delete_all CounterSpec::Content.delete_all CounterSpec::Comment.delete_all @content = CounterSpec::Content.create! :title => 'first content' end it "instantiates a counter" do @content.comments.create! :text => 'first comment' @content.comments_counter.should_not be_nil end it "increments the counter on creation" do @content.comments.create! :text => 'first comment' @content.comments_count.should == 1 end it "decrements the counter on deletion" do @comment = @content.comments.create! :text => 'first comment' @comment.destroy @content.comments_count.should == 0 end end describe "has_counter:", "using a method name as after_create and after_destroy callbacks" do before :each do Counter.delete_all CounterSpec::Content.delete_all CounterSpec::Comment.delete_all @content = CounterSpec::Content.create! :title => 'first content' end it "instantiates a counter" do @content.comments.create! :text => 'first comment' @content.approved_comments_counter.should_not be_nil end it "increments the counter on creation" do @content.comments.create! :text => 'first comment', :approved => 1 @content.approved_comments_count.should == 1 end it "decrements the counter on deletion" do @comment = @content.comments.create! :text => 'first comment', :approved => 1 @content.approved_comments_count.should == 1 @comment.destroy @content.reload @content.approved_comments_count.should == 0 end end
Version data entries
8 entries across 8 versions & 3 rubygems