Top Level Namespace
Defined Under Namespace
Modules: ActionDispatch, Adva, FormHelper, GlobalHelpers, HasOptions, Layouts, RoutingFilter, SectionsHelper, UrlHelper Classes: Account, Array, Article, ArticlesController, BaseController, Content, InstallationsController, Page, PagesController, Section, SectionsController, Site
Instance Method Summary collapse
- #assert_email_sent(attributes) ⇒ Object
- #silence_stdout ⇒ Object
-
#silence_stream(*streams) ⇒ Object
from lib/core/facets/kernel/silence.rb.
Instance Method Details
#assert_email_sent(attributes) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/testing/assertions.rb', line 1 def assert_email_sent(attributes) emails = ::ActionMailer::Base.deliveries assert !emails.empty?, "No emails were sent" matching_emails = emails.select do |email| attributes.all? do |name, value| case name when 'body' value.split(',').map(&:strip).all? { |value| email.body.include?(value) } else email.send(name).to_s == value end end end assert !matching_emails.empty?, begin msg = ["None of the #{emails.size} emails matched #{attributes.inspect}.\nInstead, there are the following emails:"] msg += emails.map { |email| attributes.keys.map { |key| [key, email.send(key)] }.map { |key, value| "#{key}: #{value}" }.join(',') } msg.join("\n") end end |
#silence_stdout ⇒ Object
15 16 17 |
# File 'lib/core_ext/ruby/kernel/silence_stream.rb', line 15 def silence_stdout silence_stream(STDOUT) { yield } end |
#silence_stream(*streams) ⇒ Object
from lib/core/facets/kernel/silence.rb
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/core_ext/ruby/kernel/silence_stream.rb', line 2 def silence_stream(*streams) on_hold = streams.collect{ |stream| stream.dup } streams.each do |stream| stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') stream.sync = true end yield ensure streams.each_with_index do |stream, i| stream.reopen(on_hold[i]) end end |