Sha256: 48c0492ce7b667042cc1d4276ae42ef01b0b06a4947a3aff5bec859cc0a2afa1

Contents?: true

Size: 1.06 KB

Versions: 27

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

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

  describe "#search" do
    before do
      stub_get("http://localhost:3000/search/query?api_key=test_d7fd0429940&api_username=test_user").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("http://localhost:3000/search/query?api_key=test_d7fd0429940&api_username=test_user").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

27 entries across 27 versions & 1 rubygems

Version Path
discourse_api-0.33.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.32.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.31.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.30.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.29.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.28.1 spec/discourse_api/api/search_spec.rb
discourse_api-0.28.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.27.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.26.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.25.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.24.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.23.1 spec/discourse_api/api/search_spec.rb
discourse_api-0.23.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.22.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.20.1 spec/discourse_api/api/search_spec.rb
discourse_api-0.20.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.19.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.18.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.17.0 spec/discourse_api/api/search_spec.rb
discourse_api-0.16.1 spec/discourse_api/api/search_spec.rb