Module: Decidim::ComponentTestHelpers

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

Overview

Helpers that get automatically included in component specs.

Instance Method Summary collapse

Instance Method Details



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

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

#expect_user_loggedObject



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

def expect_user_logged
  expect(page).to have_css(".topbar__user__logged")
end

#have_admin_callout(text) ⇒ Object



39
40
41
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 39

def have_admin_callout(text)
  have_selector(".callout--full", text: text)
end

#stripped(text) ⇒ Object



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

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

#stub_get_request_with_format(rq_url, rs_format) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 43

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_flash_messagesObject



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

def within_flash_messages
  within ".flash" do
    yield
  end
end

#within_language_menuObject



18
19
20
21
22
23
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 18

def within_language_menu
  within ".topbar__dropmenu.language-choose" do
    find("ul.dropdown.menu").click
    yield
  end
end

#within_user_menuObject



11
12
13
14
15
16
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 11

def within_user_menu
  within ".topbar__user__logged" do
    find("a", text: user.name).click
    yield
  end
end