spec/spec_helper.rb in gmail-0.3.0 vs spec/spec_helper.rb in gmail-0.3.2
- old
+ new
@@ -2,12 +2,28 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'rspec'
require 'mocha'
+require 'yaml'
require 'gmail'
RSpec.configure do |config|
config.mock_with :mocha
end
-TEST_ACCOUNT = ["test@gmail.com", "test"]
+def within_gmail(&block)
+ gmail = Gmail.connect!(*TEST_ACCOUNT)
+ yield(gmail)
+ gmail.logout if gmail
+end
+
+def mock_mailbox(box="INBOX", &block)
+ within_gmail do |gmail|
+ mailbox = subject.new(gmail, box)
+ yield(mailbox) if block_given?
+ mailbox
+ end
+end
+
+# Run test by creating your own test account with credentials in account.yml
+TEST_ACCOUNT = YAML.load_file(File.join(File.dirname(__FILE__), 'account.yml'))
\ No newline at end of file