Sha256: b2c0c49d296a1d0eda16c0e527aa3ed9f19ee0efc87af186070c19323a28c4ac

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

shared_examples "noteable" do |noteable_type|

  let(:scope) { mock }

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

    it "passes the token and applies the params" do
      subject.
        should_receive(:pass_headers).
        with(BaseCrm::Note).
        and_return(scope)
      scope.should_receive(:params).
        with({
          :noteable_type => noteable_type,
          :noteable_id => subject.id
        }).and_return(fetch_scope)
      subject.notes.should == fetch_scope
    end

  end

  describe "#create_note" do
    let(:message) { mock }
    let(:note) { mock }

    it "creates a new note" do
      subject.
        should_receive(:pass_headers).
        with(BaseCrm::Note).
        and_return(scope)
      scope.should_receive(:create).with({
        :content => message,
        :noteable_type => noteable_type,
        :noteable_id => subject.id
      }).and_return(note)
      subject.create_note(message).should == note
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

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