test: ruby: don't use instance variables

Local variables are perfectly fine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras 2021-05-01 06:59:22 -05:00 committed by David Bremner
parent c4b23cf29a
commit faf5511c3e

View file

@ -12,7 +12,7 @@ test_ruby() {
( (
cat <<-EOF cat <<-EOF
require 'notmuch' require 'notmuch'
@db = Notmuch::Database.new('$MAIL_DIR') db = Notmuch::Database.new('$MAIL_DIR')
EOF EOF
cat cat
) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT ) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
@ -22,9 +22,9 @@ test_ruby() {
test_begin_subtest "compare thread ids" test_begin_subtest "compare thread ids"
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
@q = @db.query('tag:inbox') q = db.query('tag:inbox')
@q.sort = Notmuch::SORT_OLDEST_FIRST q.sort = Notmuch::SORT_OLDEST_FIRST
@q.search_threads.each do |t| q.search_threads.each do |t|
puts t.thread_id puts t.thread_id
end end
EOF EOF
@ -32,9 +32,9 @@ EOF
test_begin_subtest "compare message ids" test_begin_subtest "compare message ids"
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
@q = @db.query('tag:inbox') q = db.query('tag:inbox')
@q.sort = Notmuch::SORT_OLDEST_FIRST q.sort = Notmuch::SORT_OLDEST_FIRST
@q.search_messages.each do |m| q.search_messages.each do |m|
puts m.message_id puts m.message_id
end end
EOF EOF
@ -42,25 +42,25 @@ EOF
test_begin_subtest "get non-existent file" test_begin_subtest "get non-existent file"
echo nil > EXPECTED echo nil > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
p @db.find_message_by_filename('i-dont-exist') p db.find_message_by_filename('i-dont-exist')
EOF EOF
test_begin_subtest "count messages" test_begin_subtest "count messages"
notmuch count --output=messages tag:inbox > EXPECTED notmuch count --output=messages tag:inbox > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
puts @db.query('tag:inbox').count_messages() puts db.query('tag:inbox').count_messages()
EOF EOF
test_begin_subtest "count threads" test_begin_subtest "count threads"
notmuch count --output=threads tag:inbox > EXPECTED notmuch count --output=threads tag:inbox > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
puts @db.query('tag:inbox').count_threads() puts db.query('tag:inbox').count_threads()
EOF EOF
test_begin_subtest "get all tags" test_begin_subtest "get all tags"
notmuch search --output=tags '*' > EXPECTED notmuch search --output=tags '*' > EXPECTED
test_ruby <<"EOF" test_ruby <<"EOF"
@db.all_tags.each do |tag| db.all_tags.each do |tag|
puts tag puts tag
end end
EOF EOF