Top Level Namespace
Defined Under Namespace
Modules: ActionDispatch, ActiveRecord, Adva, AdvaCore, FormHelper, GlobalHelpers, HasOptions, Layouts, RoutingFilter, SectionsHelper, UrlHelper
Classes: Account, Array, Article, ArticlesController, BaseController, Content, InstallationsController, Page, PagesController, Section, SectionsController, Site
Constant Summary
collapse
- TRANSFORM_FOREIGN_KEY_TYPES =
Section.types.map(&:underscore) << 'section' << 'site'
- TRANSFORM_FOREIGN_KEY_MAP =
{}
Instance Method Summary
collapse
Instance Method Details
#assert_email_sent(attributes) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/testing/assertions.rb', line 14
def assert_email_sent(attributes)
emails = ::ActionMailer::Base.deliveries
assert !emails.empty?, "No emails were sent"
assert !emails_for_assertion(attributes).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
|
#assert_no_email_sent(attributes = {}) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/testing/assertions.rb', line 24
def assert_no_email_sent(attributes = {})
if attributes.empty?
assert ::ActionMailer::Base.deliveries.empty?
else
assert emails_for_assertion(attributes).empty?, "Expected none of the emails to match #{attributes.inspect}, but one did."
end
end
|
#emails_for_assertion(attributes) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/testing/assertions.rb', line 1
def emails_for_assertion(attributes)
::ActionMailer::Base.deliveries.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
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
|