Sha256: 14eb199d1e06962a8b809ba17e62844926337703d181a0c9c9636b57179c4a71

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

shared_examples "taskable" do |taskable_type|

  let(:scope) { mock }

  describe "#tasks" do
    let(:fetch_scope) { mock }

    it "passes the token and applies the params" do
      subject.
        should_receive(:pass_headers).
        with(BaseCrm::Task).
        and_return(scope)
      scope.should_receive(:params).
        with({
          :taskable_type => taskable_type,
          :taskable_id => subject.id
        }).and_return(fetch_scope)
      subject.tasks.should == fetch_scope
    end

  end

  describe "#create_task" do
    let(:params) do
      { :content => task_content }
    end
    let(:task_content) { mock }
    let(:task) { mock }

    it "creates a new task" do
      subject.
        should_receive(:pass_headers).
        with(BaseCrm::Task).
        and_return(scope)
      scope.should_receive(:create).with({
        :content => task_content,
        :taskable_type => taskable_type,
        :taskable_id => subject.id
      }).and_return(task)
      subject.create_task(params).should == task
    end

  end

end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basecrm-0.0.3 spec/support/taskable_shared_examples.rb
basecrm-0.0.2 spec/support/taskable_shared_examples.rb
basecrm-0.0.1 spec/support/taskable_shared_examples.rb