Module: ActiveScaffold::Testing::AssertEmbeddedLoad

Defined in:
lib/active_scaffold/testing/assert_embedded_load.rb

Instance Method Summary collapse

Instance Method Details

#assert_embedded_load(selector = nil, **options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_scaffold/testing/assert_embedded_load.rb', line 6

def assert_embedded_load(selector = nil, **options)
  elements = []
  full_selector = [selector, '.active-scaffold-component a.load-embedded[href]'].compact.join(' ')

  # Collect elements without failing if none found, unless user wanted with options
  assert_select(full_selector, **options) do |matches|
    elements = matches
  end

  # Run GET on each href
  elements.each do |el|
    get el['href']
    assert_successful_response!
  end
end

#assert_successful_response!Object



22
23
24
25
26
27
28
29
30
# File 'lib/active_scaffold/testing/assert_embedded_load.rb', line 22

def assert_successful_response!
  if respond_to?(:assert_response)
    assert_response :success
  elsif defined?(RSpec)
    expect(response).to have_http_status(:ok)
  else
    raise 'No known assertion method for response'
  end
end