Sha256: dea571888a94c86d7b69a2146d2fdd747e8dea4110fe5a2404faabf052590566

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

module Tasks
  describe Taskables::Taskable do
    class Question

      # This is probably a bad idea, but otherwise Ruby will complain that there's
      # no 'has_one' method on my stub and I don't really care about that.
      class << self
        def method_missing *args; end
      end

      include Taskables::Taskable

      def answers
        ['foo', 'bar', 'baz']
      end

      responses are: :answers
    end

    describe '.submissions' do

      it 'aliases a given relation to responses' do
        expect(Question.new.responses).to eq ['foo', 'bar', 'baz']
      end

    end

    describe '#completed_by?' do
      let(:taskable) { create :verification }
      let(:user)     { create :user }

      context 'with an incomplete task' do
        it 'determines that the author has not completed it' do
          expect(taskable).not_to be_completed_by user
        end
      end

      context 'with a completed task' do
        before { create :verification_confirmation, author: user, verification: taskable }

        it 'determines that the author has completed it' do
          expect(taskable).to be_completed_by user
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tasuku-0.0.1 spec/models/tasks/taskables/taskable_spec.rb