Sha256: 2a908a407b990651dda81c2736aec042ebe343af8abb0d63043f7c20ac423dd1

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe "User updating a profile by" do
  
  before do
    @user = User.create! :name => 'bob'
    
    # Two equally weighted rules
    ReputationRule.create :name => 'misc',           :weighting => 1, :kind => 'singular'
    ReputationRule.create :name => 'profile_update', :weighting => 1, :kind => 'singular'
  end
  
  describe "adding content" do
    
    it "should increase reputation" do      
      expect {
        @user.behaviours.add 'profile_update', 0.5
      }.to change {
        @user.reputation
      }.by_at_least(0.1)
    end
    
  end
  
  describe "adding content and then removing" do
    
    it "should keep reputation static" do
      @user.behaviours.add 'profile_update', 0.5

      expect {
        @user.behaviours.add 'profile_update', 0.7
        @user.behaviours.add 'profile_update', 0.5
      }.to_not change {
        @user.reputation
      }
    end
    
  end
  
  describe "adding content and then removing more" do
    
    it "should reduce reputation" do
      @user.behaviours.add 'profile_update', 0.5
      
      expect {
        @user.behaviours.add 'profile_update', 0.7
        @user.behaviours.add 'profile_update', 0.3
      }.to change {
        @user.reputation
      }.by_at_least(-0.5).by_at_most(-0.1)
    end
    
  end
  
  describe "multiple times but not changing content" do
    
    it "should keep reputation static" do
      @user.behaviours.add 'profile_update', 0.7
      
      expect {
        @user.behaviours.add 'profile_update', 0.7
        @user.behaviours.add 'profile_update', 0.7
      }.to_not change {
        @user.reputation
      }
    end
    
  end
  
  describe "adding content, then increasing the weighting" do
    
    it "should increase reputation" do
      @user.behaviours.add 'profile_update', 1    
      
      expect {
        ReputationRule.find_by_name('profile_update').update_attribute :weight, 2
      }.to change {
        @user.reputation
      }.by_at_least(0.1)
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reputation-0.0.5 spec/scenarios/singular_spec.rb
reputation-0.0.4 spec/scenarios/singular_spec.rb
reputation-0.0.3 spec/scenarios/singular_spec.rb
reputation-0.0.2 spec/scenarios/singular_spec.rb