Created
April 16, 2010 16:15
-
-
Save erichurst/368622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Elder < ActiveRecord::Base | |
def self.increment_distribution_count(user_id) | |
self.find_by_user_id(user_id).increment!(:distribution_count) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require File.dirname(__FILE__) + '/../spec_helper' | |
describe Elder do | |
before(:all) do | |
Elder.destroy_all | |
@elder = Factory(:elder) | |
end | |
it "should increment distribution count" do | |
lambda { Elder.increment_distribution_count(@elder.user_id) }.should change(@elder, :distribution_count).by(1) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elder | |
should increment distribution count | |
distribution_count should have been changed by 1, but was changed by 0 | |
./spec/models/elder_spec.rb:11 | |
9 | |
10 it "should increment distribution count" do | |
11 lambda { Elder.increment_distribution_count(@elder.user_id) }.should change(@elder, :distribution_count).by(1) | |
12 end | |
13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment