Skip to content

Instantly share code, notes, and snippets.

@erichurst
Created April 16, 2010 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichurst/368622 to your computer and use it in GitHub Desktop.
Save erichurst/368622 to your computer and use it in GitHub Desktop.
class Elder < ActiveRecord::Base
def self.increment_distribution_count(user_id)
self.find_by_user_id(user_id).increment!(:distribution_count)
end
end
# -*- 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
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