From fb17c49c8cfe00170829365119dfaba7e50fce9a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 2 Feb 2016 13:49:19 +0100 Subject: [PATCH] Improved hash generation. --- test/integration/twitter_browser_test.rb | 8 ++++++-- test/integration/twitter_test.rb | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/integration/twitter_browser_test.rb b/test/integration/twitter_browser_test.rb index 9a0021c7f..20cc7ecfe 100644 --- a/test/integration/twitter_browser_test.rb +++ b/test/integration/twitter_browser_test.rb @@ -34,7 +34,7 @@ class TwitterBrowserTest < TestCase end twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET'] - hash = "#sweetcheck#{rand(999_999)}" + hash = "#sweetcheck#{hash_gen}" @browser = browser_instance login( @@ -197,7 +197,7 @@ class TwitterBrowserTest < TestCase config.access_token_secret = twitter_customer_token_secret end - text = "Today... #{hash} #{rand(999_999)}" + text = "Today... #{hash} #{hash_gen}" tweet = client.update( text, ) @@ -273,4 +273,8 @@ class TwitterBrowserTest < TestCase end + def hash_gen + (0...10).map { ('a'..'z').to_a[rand(26)] }.join + rand(999).to_s + end + end diff --git a/test/integration/twitter_test.rb b/test/integration/twitter_test.rb index 9bd921828..4d6884005 100644 --- a/test/integration/twitter_test.rb +++ b/test/integration/twitter_test.rb @@ -178,7 +178,7 @@ class TwitterTest < ActiveSupport::TestCase config.access_token_secret = me_bauer_token_secret end - hash = '#citheo24 #' + rand(999_999).to_s + hash = '#citheo24 #' + hash_gen text = "Today... #{hash}" tweet = client.update( text, @@ -195,13 +195,13 @@ class TwitterTest < ActiveSupport::TestCase break if article sleep 20 } - assert(article) + assert(article, "Can't find tweet id #{tweet.id}") assert_equal('@me_bauer', article.from, 'ticket article from') assert_equal(nil, article.to, 'ticket article to') ticket = article.ticket # send reply - reply_text = '@me_bauer on my side #weather' + rand(999_999).to_s + reply_text = '@me_bauer on my side #weather' + hash_gen article = Ticket::Article.create( ticket_id: ticket.id, body: reply_text, @@ -254,7 +254,7 @@ class TwitterTest < ActiveSupport::TestCase dms.each {|dm| client.destroy_direct_message(dm.id) } - hash = '#citheo44' + rand(999_999).to_s + hash = '#citheo44' + hash_gen text = 'How about the details? ' + hash dm = client.create_direct_message( 'armin_theo', @@ -382,7 +382,7 @@ class TwitterTest < ActiveSupport::TestCase config.access_token = me_bauer_token config.access_token_secret = me_bauer_token_secret end - hash = '#citheo24 #' + rand(999_999).to_s + hash = '#citheo24 #' + hash_gen text = "Today... #{hash}" tweet = client.update( text, @@ -450,4 +450,8 @@ class TwitterTest < ActiveSupport::TestCase end + def hash_gen + rand(999).to_s + (0...10).map { ('a'..'z').to_a[rand(26)] }.join + end + end