Module: Assertions::Gmail
- Defined in:
- lib/gmail_test/assertions/gmail.rb
Instance Method Summary collapse
- #assert_basic_html_view ⇒ Object
- #assert_email_received(from, subject, &block) ⇒ Object
- #assert_email_sent(subject, body, to, cc) ⇒ Object
- #assert_logged_in(email, password) ⇒ Object
- #assert_logged_out ⇒ Object
Instance Method Details
#assert_basic_html_view ⇒ Object
66 67 68 69 |
# File 'lib/gmail_test/assertions/gmail.rb', line 66 def assert_basic_html_view() visit "http://mail.google.com/?ui=html" find("td#bm b", :text => "basic HTML") end |
#assert_email_received(from, subject, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gmail_test/assertions/gmail.rb', line 34 def assert_email_received(from,subject,&block) start_time = Time.now wait_time = 20 success = false begin visit "http://mail.google.com/?ui=html" within("form[name='f'] table.th tbody tr:nth-child(1)") do if find("td:nth-child(2)").text =~ Regexp.new(from) && find("td:nth-child(3)").text =~ Regexp.new(subject) success = true else raise "timeout" end end rescue assert false if (Time.now - start_time) >= wait_time sleep 3 retry end if block within("form[name='f'] table.th tbody tr:nth-child(1)") do find("td:nth-child(3) a").click end wait_until { find("table.h tr:first").text =~ /#{subject}/ } body = all("div.msg").last.text block.call(body) end end |
#assert_email_sent(subject, body, to, cc) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gmail_test/assertions/gmail.rb', line 22 def assert_email_sent(subject,body,to,cc) find("a",:text => "Compose Mail").click wait_until { has_css?("textarea[name='to']") } fill_in("to", :with => to) fill_in("cc", :with => cc) fill_in("subject", :with => subject) fill_in("body", :with => body) assert_appears("b", :text => "Your message has been sent.") do find("input[name='nvp_bu_send']").click end end |
#assert_logged_in(email, password) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gmail_test/assertions/gmail.rb', line 5 def assert_logged_in(email,password) visit "http://gmail.com" fill_in "Email", :with => email fill_in "Passwd", :with => password assert_appears("#loading") do "Sign in" end wait_until { has_css?("iframe#canvas_frame") } assert_basic_html_view wait_until{ has_css?("#guser b.gb4", :text => email) } end |
#assert_logged_out ⇒ Object
17 18 19 20 |
# File 'lib/gmail_test/assertions/gmail.rb', line 17 def assert_logged_out click_link "Sign out" assert has_css?("#gaia_loginform") end |