Sha256: fbaa288bd6594d425fd9532d9e6f2992c86325d86b2e4c0155a001f91cbf9b02

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Luggage::MailboxQueryBuilder do
  include_context "factories"

  describe "::new" do
    it "sets the mailbox" do
      expect(Luggage::MailboxQueryBuilder.new(mailbox).mailbox).to eq(mailbox)
    end

    it "requires a mailbox" do
      expect { Luggage::MailboxQueryBuilder.new(:not_a_mailbox) }.to raise_error(ArgumentError)
    end

    it "sets the connection" do
      expect(Luggage::MailboxQueryBuilder.new(mailbox).connection).to eq(connection)
    end
  end

  describe "#each" do
    it "yields to each member of #messages" do
      block = Proc.new {}
      query_builder.stub(:message_ids).and_return(['<one@example.com>', '<two@example.com>'])
      query_builder.messages.should_receive(:each) #.with(block)

      query_builder.each(&block)
    end
  end

  describe "::where" do
    it "returns self" do
      expect(query_builder.where(:foo => :bar)).to be_a(Luggage::MailboxQueryBuilder)
    end

    it "appends to the query" do
      expect(query_builder.where(:foo => :bar).where(:baz => :qux).query).to eq([:foo, :bar, :baz, :qux])
    end
  end

  describe "::[]" do
    it "returns messages[]" do
      query_builder.stub(:message_ids).and_return(['<one@example.com>', '<two@example.com>'])
      query_builder.messages.should_receive(:[]).with((1..2))

      query_builder[1..2]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
luggage-1.2.3 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.2.2 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.2.1 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.2.0 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.1.2 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.1.1 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.1.0 spec/luggage/mailbox_query_builder_spec.rb
luggage-1.0.0 spec/luggage/mailbox_query_builder_spec.rb