Sha256: 4484f4506dd984823091706cf3a0a41c0bc3037d7cef20fe0a54b7e87e9523c0

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

module Tasuku
  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

4 entries across 4 versions & 1 rubygems

Version Path
tasuku-1.1.0 spec/models/tasuku/taskables/taskable_spec.rb
tasuku-1.0.1 spec/models/tasuku/taskables/taskable_spec.rb
tasuku-0.1.1 spec/models/tasuku/taskables/taskable_spec.rb
tasuku-0.1.0 spec/models/tasuku/taskables/taskable_spec.rb