Sha256: 1de5f2c636bcbdb4120db9128dbfc121ba04266bb0b488ba34c19241cf7d223c

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe DiscourseApi::API::Categories do
  subject { DiscourseApi::Client.new("http://localhost:3000", "test_d7fd0429940", "test_user" )}

  describe "#categories" do
    before do
      stub_get("http://localhost:3000/categories.json?api_key=test_d7fd0429940&api_username=test_user").to_return(body: fixture("categories.json"), headers: { content_type: "application/json" })
    end

    it "requests the correct resource" do
      subject.categories
      expect(a_get("http://localhost:3000/categories.json?api_key=test_d7fd0429940&api_username=test_user")).to have_been_made
    end

    it "returns the requested categories" do
      categories = subject.categories
      expect(categories).to be_an Array
      expect(categories.first).to be_a Hash
    end
  end

  describe '#category_latest_topics' do
    before do
      stub_get("http://localhost:3000/category/category-slug/l/latest.json?api_key=test_d7fd0429940&api_username=test_user").to_return(body: fixture("category_latest_topics.json"), headers: { content_type: "application/json" })
    end

    it "returns the latest topics in a category" do
      latest_topics = subject.category_latest_topics('category-slug')
      expect(latest_topics).to be_an Array
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
discourse_api-0.3.0 spec/discourse_api/api/categories_spec.rb
discourse_api-0.2.9 spec/discourse_api/api/categories_spec.rb
discourse_api-0.2.8 spec/discourse_api/api/categories_spec.rb
discourse_api-0.2.7 spec/discourse_api/api/categories_spec.rb
discourse_api-0.2.5 spec/discourse_api/api/categories_spec.rb
discourse_api-0.2.4 spec/discourse_api/api/categories_spec.rb