Top Level Namespace

Defined Under Namespace

Modules: ActiveRecord, Adva, AdvaCore, EmailHelpers, FormHelper, GlobalHelpers, HasOptions, HtmlSelectorsHelpers, Layouts, RoutingFilter, SectionsHelper, UrlHelper, WithinHelpers Classes: Account, Array, Article, ArticlesController, BaseController, Content, InstallationsController, Page, PagesController, Repository, 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



18
19
20
21
22
23
24
25
26
# File 'lib/testing/assertions.rb', line 18

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_html(html, *args, &block) ⇒ Object



1
2
3
# File 'lib/testing/assertions.rb', line 1

def assert_html(html, *args, &block)
  assert_select(HTML::Document.new(html).root, *args, &block)
end

#assert_no_email_sent(attributes = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/testing/assertions.rb', line 28

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

#developer(name, preferences) ⇒ Object



111
112
113
# File 'lib/bundler/repository.rb', line 111

def developer(name, preferences)
  Repository.developer(name, preferences)
end

#emails_for_assertion(attributes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/testing/assertions.rb', line 5

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

#repository(*args) ⇒ Object



115
116
117
# File 'lib/bundler/repository.rb', line 115

def repository(*args)
  Repository.new(self, *args)
end

#silence_stdoutObject



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

#tables_differ_message(actual, expected, diff = nil) ⇒ Object



273
274
275
276
277
# File 'lib/testing/step_definitions/common_steps.rb', line 273

def tables_differ_message(actual, expected, diff = nil)
  msg = "\nActual table:#{actual.to_s}\nExpected table:#{expected.to_s}\n"
  msg += "Difference:#{diff.to_s}\n" if diff
  msg
end

#workspace(*paths) ⇒ Object Also known as: workspaces



106
107
108
# File 'lib/bundler/repository.rb', line 106

def workspace(*paths)
  Repository.path(*paths)
end