Sha256: f1f6128eadb6a4d49d3a9eb4c3169e78dfae05e87bc8835726ccdfc8863737b4

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

require 'spec_helper'

describe Emotions::Emotive do
  before do
    emotions :happy, :sad

    run_migration do
      create_table(:users, force: true)
      create_table(:pictures, force: true) do |t|
        t.integer :happy_emotions_count, default: 0
        t.integer :sad_emotions_count, default: 0
      end
    end

    emotional 'User'
    emotive 'Picture'
  end

  let(:picture) { Picture.create }

  describe :InstanceMethods do
    describe :update_emotion_counter do
      let(:relation) do
        double.tap { |double| double.stub(:count).and_return(42) }
      end

      before do
        Picture.any_instance.stub(:happy_about).and_return(relation)
        picture.update_emotion_counter(:happy)
      end

      it { expect(picture.reload.happy_emotions_count).to eql 42 }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
emotions-0.3 spec/emotions/emotive_spec.rb
emotions-0.2.2 spec/emotions/emotive_spec.rb
emotions-0.2.1 spec/emotions/emotive_spec.rb
emotions-0.2 spec/emotions/emotive_spec.rb
emotions-0.1.7 spec/emotions/emotive_spec.rb