Sha256: 1d2ff5e5244e2a053c427055f05324e943b20ef49d699a41da9c594017d2f5c0

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe "Intercom::Article" do
  let(:client) { Intercom::Client.new(token: 'token') }

  describe "Getting an Article" do
    it "successfully finds an article" do
      client.expects(:get).with("/articles/1", {}).returns(test_article)
      client.articles.find(id: "1")
    end
  end

  describe "Creating an Article" do
    it "successfully creates and article with information passed individually" do
      client.expects(:post).with("/articles", {"title" => "new title", "author_id" => 1, "body" => "<p>thingbop</p>", "state" => "draft"}).returns(test_article)
      client.articles.create(:title => "new title", :author_id => 1, :body => "<p>thingbop</p>", :state => "draft")
    end

    it "successfully creates and article with information in json" do
      client.expects(:post).with("/articles", {"title" => "new title", "author_id" => 1, "body" => "<p>thingbop</p>", "state" => "draft"}).returns(test_article)
      client.articles.create({title: "new title", author_id: 1, body: "<p>thingbop</p>", state: "draft"})
    end
  end

  describe "Updating an article" do
    it "successfully updates an article" do
      article = Intercom::Article.new(id: 12345)
      client.expects(:put).with('/articles/12345', {})
      client.articles.save(article)
    end
  end

  describe "Deleting an article" do
    it "successfully deletes an article" do
      article = Intercom::Article.new(id: 12345)
      client.expects(:delete).with('/articles/12345', {})
      client.articles.delete(article)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
intercom-4.2.1 spec/unit/intercom/article_spec.rb
intercom-4.2.0 spec/unit/intercom/article_spec.rb
intercom-4.1.3 spec/unit/intercom/article_spec.rb
intercom-4.1.2 spec/unit/intercom/article_spec.rb
intercom-4.1.1 spec/unit/intercom/article_spec.rb
intercom-4.1.0 spec/unit/intercom/article_spec.rb