Sha256: f0dd851a4cd1962d1a14aabb3a52af445b85dcc7871762e1e526065845f0b850

Contents?: true

Size: 974 Bytes

Versions: 7

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true
require 'spec_helper'

describe DiscourseApi::API::Search do
  subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }

  describe "#search" do
    before do
      stub_get("#{host}/search/query").with(query: { term: "test" }).to_return(body: fixture("search.json"), headers: { content_type: "application/json" })
    end

    it "requests the correct resource" do
      subject.search("test")
      expect(a_get("#{host}/search/query").with(query: { term: "test" })).to have_been_made
    end

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

    it "raises an ArgumentError for nil" do
      expect { subject.search(nil) }.to raise_error(ArgumentError)
    end

    it "raises an ArgumentError for empty string" do
      expect { subject.search('') }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
discourse_api-0.45.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.44.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.43.1 spec/discourse_api/api/search_spec.rb
discourse_api-0.43.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.42.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.41.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.40.0 spec/discourse_api/api/search_spec.rb