Sha256: d71e17387b267c226abd6046d267ab50a13699c5c8fd46554be87fafb81a0575
Contents?: true
Size: 1.8 KB
Versions: 5
Compression:
Stored size: 1.8 KB
Contents
require 'spec_helper' describe Ridley::Search do let(:connection) { double('connection') } let(:index) { :role } let(:query) { "*:*" } let(:response) { double("response", body: Hash.new) } describe "ClassMethods" do subject { Ridley::Search } describe "::indexes" do it "sends a get request to the connection to receive the indexes" do connection.should_receive(:get).with("search").and_return(response) subject.indexes(connection) end end end describe "#run" do subject do Ridley::Search.new(connection, index, query) end it "sends a get request to the connection to the index's location with the given query" do connection.should_receive(:get).with("search/#{index}", q: query).and_return(response) subject.run end context "when 'sort' is set" do let(:sort) { "DESC" } before(:each) { subject.sort = sort } it "sends a get request to the connection with a query parameter for 'set'" do connection.should_receive(:get).with("search/#{index}", q: query, sort: sort).and_return(response) subject.run end end context "when 'start' is set" do let(:start) { 1 } before(:each) { subject.start = start } it "sends a get request to the connection with a query parameter for 'start'" do connection.should_receive(:get).with("search/#{index}", q: query, start: start).and_return(response) subject.run end end context "when 'rows' is set" do let(:rows) { 1 } before(:each) { subject.rows = rows } it "sends a get request to the connection with a query parameter for 'rows'" do connection.should_receive(:get).with("search/#{index}", q: query, rows: rows).and_return(response) subject.run end end end end
Version data entries
5 entries across 5 versions & 1 rubygems