--- /dev/null
+Return-Path: <felipe.contreras@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 2010B431FC4\r
+ for <notmuch@notmuchmail.org>; Fri, 23 May 2014 03:45:56 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id V95y3NXdnrQl for <notmuch@notmuchmail.org>;\r
+ Fri, 23 May 2014 03:45:52 -0700 (PDT)\r
+Received: from mail-oa0-f52.google.com (mail-oa0-f52.google.com\r
+ [209.85.219.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 812C7431FBF\r
+ for <notmuch@notmuchmail.org>; Fri, 23 May 2014 03:45:52 -0700 (PDT)\r
+Received: by mail-oa0-f52.google.com with SMTP id eb12so5306111oac.25\r
+ for <notmuch@notmuchmail.org>; Fri, 23 May 2014 03:45:52 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=+rT3WnT606MhtF+BlvHH+wn44Xrd6X2aR32HVTAtBn0=;\r
+ b=mud0HMO83vzt/UUZQgieWEE7HFxn9uhS78c8xfLtFpI0y5KQa56j+bZ7p1HYseCtBz\r
+ Lw3gMlOuDdwH/obkfa/p2j+OVkDLLvG8t8lcULED5WyHt6tP+WUFPykJosNGWQtTv1PJ\r
+ G2rGKuZr3fO+MXW1+gtmKeae88YPIBswGvpC79rfCUGmTECZUrxJtCSfvP77MjGksA51\r
+ xo3DXKL183tgtP7DSGb4S4Wk6YyoafcKUc9YXVwDCYPBhbz/SPtf5B9jctodSZX3vV7Z\r
+ tiC14cbHeDtJOFx1KEljLC3vir/YfES8zKBWMZlvgTnJmMKDVyLHY6F44x6cKA6u2FIz\r
+ Z4vg==\r
+X-Received: by 10.60.55.97 with SMTP id r1mr3811442oep.5.1400841952145;\r
+ Fri, 23 May 2014 03:45:52 -0700 (PDT)\r
+Received: from localhost (189-211-224-40.static.axtel.net. [189.211.224.40])\r
+ by mx.google.com with ESMTPSA id ld8sm4881937obb.9.2014.05.23.03.45.50\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 23 May 2014 03:45:51 -0700 (PDT)\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] test: add tests for Ruby bindings\r
+Date: Fri, 23 May 2014 05:34:27 -0500\r
+Message-Id: <1400841267-12807-4-git-send-email-felipe.contreras@gmail.com>\r
+X-Mailer: git-send-email 1.9.3+fc1~5~gfaddd51\r
+In-Reply-To: <1400841267-12807-1-git-send-email-felipe.contreras@gmail.com>\r
+References: <1400841267-12807-1-git-send-email-felipe.contreras@gmail.com>\r
+Cc: Ali Polatel <alip@exherbo.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 23 May 2014 10:45:56 -0000\r
+\r
+Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
+---\r
+ test/T540-ruby.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/test-lib.sh | 1 +\r
+ 2 files changed, 99 insertions(+)\r
+ create mode 100755 test/T540-ruby.sh\r
+\r
+diff --git a/test/T540-ruby.sh b/test/T540-ruby.sh\r
+new file mode 100755\r
+index 0000000..a9f6ac5\r
+--- /dev/null\r
++++ b/test/T540-ruby.sh\r
+@@ -0,0 +1,98 @@\r
++#!/usr/bin/env bash\r
++#\r
++# Copyright (c) 2014 Felipe Contreras\r
++#\r
++\r
++test_description="Ruby bindings"\r
++\r
++. ./test-lib.sh\r
++\r
++export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib\r
++export RUBYLIB=$TEST_DIRECTORY/../bindings/ruby\r
++\r
++if ! test_have_prereq RUBY\r
++then\r
++ skip_all='skipping ruby tests'\r
++ test_done\r
++fi\r
++\r
++test_ruby () {\r
++ cat > test.rb <<-\EOF &&\r
++ #!/usr/bin/env ruby\r
++\r
++ require 'notmuch'\r
++\r
++ $MAIL_DIR = ENV['MAIL_DIR']\r
++ EOF\r
++ cat >> test.rb &&\r
++ ruby test.rb\r
++}\r
++\r
++test_expect_success 'setup' '\r
++ add_email_corpus &&\r
++ notmuch new --quiet &&\r
++ export MAIL_DIR\r
++'\r
++\r
++test_expect_success 'new and close' '\r
++ test_ruby <<-\EOF\r
++ db = Notmuch::Database.new($MAIL_DIR)\r
++ db.close\r
++ EOF\r
++'\r
++\r
++test_expect_success 'open' '\r
++ test_ruby <<-\EOF\r
++ Notmuch::Database.open($MAIL_DIR) do |db|\r
++ end\r
++ EOF\r
++'\r
++\r
++test_expect_success 'path' '\r
++ echo $MAIL_DIR > expected &&\r
++ test_ruby > actual <<-\EOF &&\r
++ Notmuch::Database.open($MAIL_DIR) do |db|\r
++ puts db.path\r
++ end\r
++ EOF\r
++ test_cmp expected actual\r
++'\r
++\r
++test_expect_success 'query' '\r
++ notmuch count "tag:inbox" > expected &&\r
++ test_ruby > actual <<-\EOF &&\r
++ Notmuch::Database.open($MAIL_DIR) do |db|\r
++ query = db.query("tag:inbox")\r
++ puts query.count_messages\r
++ end\r
++ EOF\r
++ test_cmp expected actual\r
++'\r
++\r
++test_expect_success 'query threads' '\r
++ notmuch search --output=threads "tag:inbox" > expected &&\r
++ test_ruby > actual <<-\EOF &&\r
++ Notmuch::Database.open($MAIL_DIR) do |db|\r
++ query = db.query("tag:inbox")\r
++ query.search_threads.each do |thread|\r
++ puts "thread:" + thread.thread_id\r
++ end\r
++ end\r
++ EOF\r
++ test_cmp expected actual\r
++'\r
++\r
++test_expect_success 'query messages' '\r
++ notmuch search --output=messages "tag:inbox" > expected &&\r
++ test_ruby > actual <<-\EOF &&\r
++ Notmuch::Database.open($MAIL_DIR) do |db|\r
++ query = db.query("tag:inbox")\r
++ query.search_messages.each do |message|\r
++ puts "id:" + message.message_id\r
++ end\r
++ end\r
++ EOF\r
++ test_cmp expected actual\r
++'\r
++\r
++test_done\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 8697d6a..1f9dd1f 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1208,6 +1208,7 @@ test_init_ () {\r
+ \r
+ emacs_generate_script\r
+ \r
++grep -q "WITH_RUBY = 1" ../Makefile.config && test_set_prereq RUBY\r
+ \r
+ # Use -P to resolve symlinks in our working directory so that the cwd\r
+ # in subprocesses like git equals our $PWD (for pathname comparisons).\r
+-- \r
+1.9.3+fc1~5~gfaddd51\r
+\r