Module: Decidim::ComponentTestHelpers

Defined in:
lib/decidim/dev/test/rspec_support/helpers.rb

Instance Method Summary collapse

Instance Method Details



6
7
8
9
10
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 6

def click_submenu_link(text)
  within ".secondary-nav--subnav" do
    click_on text
  end
end

#expect_user_loggedObject



52
53
54
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 52

def expect_user_logged
  expect(page).to have_css(".main-bar #trigger-dropdown-account")
end

#have_admin_callout(text) ⇒ Object



56
57
58
59
60
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 56

def have_admin_callout(text)
  within_flash_messages do
    have_content text
  end
end

#stripped(text) ⇒ Object



42
43
44
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 42

def stripped(text)
  text.gsub(/^<p>/, "").gsub(%r{</p>$}, "")
end

#stub_get_request_with_format(rq_url, rs_format) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 62

def stub_get_request_with_format(rq_url, rs_format)
  stub_request(:get, rq_url)
    .with(
      headers: {
        "Accept" => "*/*",
        "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
        "User-Agent" => "Ruby"
      }
    )
    .to_return(status: 200, body: "", headers: { content_type: rs_format })
end

#within_admin_menuObject



28
29
30
31
32
33
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 28

def within_admin_menu
  click_on "Manage"
  within("[id*='dropdown-menu-settings']") do
    yield
  end
end

#within_admin_sidebar_menuObject



22
23
24
25
26
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 22

def within_admin_sidebar_menu
  within("[id='admin-sidebar-menu-settings']") do
    yield
  end
end

#within_flash_messagesObject



46
47
48
49
50
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 46

def within_flash_messages
  within ".flash", match: :first do
    yield
  end
end

#within_language_menu(options = {}) ⇒ Object



35
36
37
38
39
40
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 35

def within_language_menu(options = {})
  within(options[:admin] ? ".language-choose" : "footer") do
    find(options[:admin] ? "#admin-menu-trigger" : "#trigger-dropdown-language-chooser").click
    yield
  end
end

#within_user_menuObject



12
13
14
15
16
17
18
19
20
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 12

def within_user_menu
  main_bar_selector = ".main-bar"

  within main_bar_selector do
    find_by_id("trigger-dropdown-account").click

    yield
  end
end