Sha256: dffcc4e07d71a9d291cf34c106ab94db5b464e024562a1b819fc5b8a9bb4f58f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

module Vacuum
  describe SearchOperations do
    let(:req) { Request.new('us') }

    before do
      req.configure do |c|
        c.key = 'foo'
        c.tag = 'bar'
      end
      req.stub!(:get)
    end

    describe "#search" do
      context "when given a keyword" do
        before do
          req.search('foo')
        end

        it "does a keyword search" do
          req.params['Keywords'].should eql 'foo'
        end

        it "searches all products" do
          req.params["SearchIndex"].should eql 'All'
        end
      end

      context "when given a search index and a keyword" do
        before do
          req.search('foo', 'bar')
        end

        it "does a keyword search" do
          req.params['Keywords'].should eql 'bar'
        end

        it "sets the search index" do
          req.params["SearchIndex"].should eql 'foo'
        end
      end

      context "when given a search index and parameters" do
        before do
          req.search('foo', :bar => 'baz')
        end

        it "sets the parameters" do
          req.params['Bar'].should eql 'baz'
        end

        it "sets the search index" do
          req.params["SearchIndex"].should eql 'foo'
        end
      end      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vacuum-0.0.1 spec/vacuum/search_operations_spec.rb