Sha256: 6fee7b63eda890b85f79a1d5963f50fb07eb909852fb79c402abf8c4ddbdc688

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

shared_examples "taskable" do |taskable_type|

  let(:scope) { double }

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

    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 "#tasks.create" do
    let(:params) do
      { :content => task_content }
    end
    let(:task_content) { double }
    let(:task) { double }

    it "creates a new task" 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(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

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

    it "creates a new task" do
      subject.should_receive(:tasks).and_return(tasks)
      tasks.should_receive(:create).with({
        :content => task_content
      }).and_return(task)
      subject.create_task(params).should == task
    end

  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basecrm-0.1.0 spec/support/taskable_shared_examples.rb