Module: Decidim::ComponentTestHelpers
- Defined in:
- lib/decidim/dev/test/rspec_support/helpers.rb
Instance Method Summary collapse
- #click_submenu_link(text) ⇒ Object
- #expect_user_logged ⇒ Object
- #have_admin_callout(text) ⇒ Object
- #stripped(text) ⇒ Object
- #stub_get_request_with_format(rq_url, rs_format) ⇒ Object
- #within_admin_menu ⇒ Object
- #within_admin_sidebar_menu ⇒ Object
- #within_flash_messages ⇒ Object
- #within_language_menu(options = {}) ⇒ Object
- #within_user_menu ⇒ Object
Instance Method Details
#click_submenu_link(text) ⇒ Object
6 7 8 9 10 |
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 6 def (text) within ".secondary-nav--subnav" do click_on text end end |
#expect_user_logged ⇒ Object
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) 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_menu ⇒ Object
28 29 30 31 32 33 |
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 28 def click_on "Manage" within("[id*='dropdown-menu-settings']") do yield end end |
#within_admin_sidebar_menu ⇒ Object
22 23 24 25 26 |
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 22 def within("[id='admin-sidebar-menu-settings']") do yield end end |
#within_flash_messages ⇒ Object
46 47 48 49 50 |
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 46 def 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([:admin] ? ".language-choose" : "footer") do find([:admin] ? "#admin-menu-trigger" : "#trigger-dropdown-language-chooser").click yield end end |
#within_user_menu ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 12 def = ".main-bar" within do find_by_id("trigger-dropdown-account").click yield end end |