spec/mailbox_spec.rb in gmail-0.3.0 vs spec/mailbox_spec.rb in gmail-0.3.2

- old
+ new

@@ -1,48 +1,38 @@ require 'spec_helper' describe "A Gmail mailbox" do subject { Gmail::Mailbox } - - def within_gmail(&block) - gmail = Gmail.connect!(*TEST_ACCOUNT) - yield(gmail) - gmail.logout if gmail - end - + context "on initialize" do it "should set client and name" do within_gmail do |gmail| mailbox = subject.new(gmail, "TEST") mailbox.instance_variable_get("@gmail").should == gmail mailbox.name.should == "TEST" end end - + it "should work in INBOX by default" do within_gmail do |gmail| mailbox = subject.new(@gmail) mailbox.name.should == "INBOX" end end end - + context "instance" do - def mock_mailbox(box="INBOX", &block) - within_gmail do |gmail| - mailbox = subject.new(gmail, box) - yield(mailbox) if block_given? - mailbox - end - end - + it "should be able to count all emails" do mock_mailbox do |mailbox| mailbox.count.should > 0 end end - + it "should be able to find messages" do - pending + mock_mailbox do |mailbox| + message = mailbox.emails.first + mailbox.emails(:all, :from => message.from.first.name) == message.from.first.name + end end end end