Skip to content

Instantly share code, notes, and snippets.

@erichurst erichurst/elder.rb
Created Apr 16, 2010

Embed
What would you like to do?
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
You can’t perform that action at this time.