Module: HandyFeatureHelpers::MainHelpers
- Included in:
- AllHelpers
- Defined in:
- lib/handy_feature_helpers/main_helpers.rb
Constant Summary collapse
- @@resource =
''
- @@resource_plural =
''
Instance Method Summary collapse
- #accept_alert ⇒ Object
- #cancel_link ⇒ Object
- #click(selector) ⇒ Object
- #click_option(resource) ⇒ Object
- #click_text(text) ⇒ Object
- #close ⇒ Object
- #count?(count) ⇒ Boolean
- #count_div ⇒ Object
- #current_path?(path) ⇒ Boolean
- #delete_link ⇒ Object
- #edit_link ⇒ Object
- #ensure_cancel_creating_is_working ⇒ Object
- #ensure_cancel_modal_is_working ⇒ Object
- #ensure_delete_is_working ⇒ Object
- #form ⇒ Object
- #get_resource ⇒ Object
- #has_content?(text) ⇒ Boolean
- #has_no_content?(text) ⇒ Boolean
- #has_validations? ⇒ Boolean
- #invisible?(selector) ⇒ Boolean
- #js_edit_link ⇒ Object
- #modal ⇒ Object
- #new_link ⇒ Object
- #set_resource(x) ⇒ Object
- #show_link ⇒ Object
- #size_of(selector) ⇒ Object
- #submit ⇒ Object
- #tab_link ⇒ Object
- #table ⇒ Object
- #table_has_content?(text) ⇒ Boolean
- #table_has_no_content?(text) ⇒ Boolean
- #table_rows ⇒ Object
- #visible?(selector) ⇒ Boolean
Instance Method Details
#accept_alert ⇒ Object
74 75 76 77 78 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 74 def accept_alert if Capybara.javascript_driver == 'selenium' page.driver.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertOpenError end end |
#cancel_link ⇒ Object
34 35 36 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 34 def cancel_link "#cancel-#{@@resource}-link" end |
#click(selector) ⇒ Object
92 93 94 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 92 def click(selector) find(selector).click end |
#click_option(resource) ⇒ Object
100 101 102 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 100 def click_option(resource) find("option[value='#{resource.id}']").click end |
#click_text(text) ⇒ Object
96 97 98 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 96 def click_text(text) find('a',:text => text).click end |
#close ⇒ Object
70 71 72 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 70 def close '.close' end |
#count?(count) ⇒ Boolean
147 148 149 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 147 def count?(count) within(count_div) { has_content? count } end |
#count_div ⇒ Object
42 43 44 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 42 def count_div ".#{@@resource_plural}-count" end |
#current_path?(path) ⇒ Boolean
151 152 153 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 151 def current_path?(path) expect(current_path).to eq path end |
#delete_link ⇒ Object
66 67 68 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 66 def delete_link '.delete-link' end |
#edit_link ⇒ Object
54 55 56 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 54 def edit_link '.edit-link' end |
#ensure_cancel_creating_is_working ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 127 def ensure_cancel_creating_is_working click cancel_link invisible? form click new_link visible? submit invisible? new_link end |
#ensure_cancel_modal_is_working ⇒ Object
137 138 139 140 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 137 def ensure_cancel_modal_is_working click cancel_link invisible? modal end |
#ensure_delete_is_working ⇒ Object
120 121 122 123 124 125 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 120 def ensure_delete_is_working tr_count = size_of table_rows within(table) { click delete_link } accept_alert size_of(table_rows) == tr_count - 1 end |
#form ⇒ Object
22 23 24 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 22 def form "#new-#{@@resource}" end |
#get_resource ⇒ Object
14 15 16 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 14 def get_resource @@resource end |
#has_content?(text) ⇒ Boolean
104 105 106 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 104 def has_content?(text) expect(page).to have_content(text) end |
#has_no_content?(text) ⇒ Boolean
108 109 110 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 108 def has_no_content?(text) expect(page).to have_no_content(text) end |
#has_validations? ⇒ Boolean
142 143 144 145 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 142 def has_validations? click submit page.should have_content "can't be blank" end |
#invisible?(selector) ⇒ Boolean
88 89 90 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 88 def invisible?(selector) !page.find(selector).visible? end |
#js_edit_link ⇒ Object
58 59 60 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 58 def js_edit_link '.js-edit-link' end |
#modal ⇒ Object
38 39 40 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 38 def modal '.modal' end |
#new_link ⇒ Object
26 27 28 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 26 def new_link "#new-#{@@resource}-link" end |
#set_resource(x) ⇒ Object
9 10 11 12 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 9 def set_resource(x) @@resource = x @@resource_plural = plural(x) end |
#show_link ⇒ Object
62 63 64 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 62 def show_link '.show-link' end |
#size_of(selector) ⇒ Object
80 81 82 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 80 def size_of(selector) page.all(selector).size end |
#submit ⇒ Object
30 31 32 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 30 def submit "#submit-#{@@resource}-button" end |
#tab_link ⇒ Object
18 19 20 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 18 def tab_link "##{@@resource_plural}-tab-link" end |
#table ⇒ Object
46 47 48 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 46 def table "##{@@resource_plural}-index" end |
#table_has_content?(text) ⇒ Boolean
112 113 114 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 112 def table_has_content?(text) within(table) { has_content?(text) } end |
#table_has_no_content?(text) ⇒ Boolean
116 117 118 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 116 def table_has_no_content?(text) within(table) { has_no_content?(text) } end |
#table_rows ⇒ Object
50 51 52 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 50 def table_rows "##{@@resource_plural}-index tr" end |
#visible?(selector) ⇒ Boolean
84 85 86 |
# File 'lib/handy_feature_helpers/main_helpers.rb', line 84 def visible?(selector) find(selector).visible? end |