module Gaku::Testing::FeatureHelpers
Public Instance Methods
accept_alert()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 79 def accept_alert page.driver.browser.switch_to.alert.accept if Capybara.javascript_driver == :selenium end
cancel_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 31 def cancel_link "#cancel-#{@@resource}-link" end
check_path(current_url, expected_path)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 132 def check_path(current_url, expected_path) uri = URI.parse(current_url) "#{uri.path}?#{uri.query}".should == expected_path end
click(selector)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 95 def click(selector) if Capybara.javascript_driver == :selenium find(selector).click else find(selector).trigger('click') end end
click_option(resource)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 103 def click_option(resource) find("option[value='#{resource.id}']").click end
close()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 75 def close '.close' end
count?(count)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 128 def count?(count) within(count_div) { page.has_content? count } end
count_div()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 39 def count_div ".#{@@resource_plural}-count" end
delete_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 71 def delete_link '.delete-link' end
edit_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 51 def edit_link '.edit-link' end
ensure_delete_is_working()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 107 def ensure_delete_is_working within(table) { click delete_link } accept_alert end
form()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 19 def form "#new-#{@@resource}" end
get_resource()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 11 def get_resource @@resource end
has_validations?()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 123 def has_validations? click submit page.has_content? "can't be blank" end
invisible?(selector)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 91 def invisible?(selector) page.has_no_selector?(selector) end
js_edit_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 55 def js_edit_link '.js-edit-link' end
modal()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 35 def modal '.modal' end
modal_delete_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 63 def modal_delete_link '.modal-delete-link' end
new_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 23 def new_link "#new-#{@@resource}-link" end
picture_path()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 137 def picture_path Rails.root + '../../../core/spec/support/120x120.jpg' end
recovery_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 59 def recovery_link '.recovery-link' end
set_resource(x)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 6 def set_resource(x) @@resource = x @@resource_plural = plural(x) end
show_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 67 def show_link '.show-link' end
size_of(selector)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 83 def size_of(selector) page.all(selector).size end
submit()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 27 def submit "#submit-#{@@resource}-button" end
tab_link()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 15 def tab_link "##{@@resource_plural}-tab-link" end
table()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 43 def table "##{@@resource_plural}-index" end
table_rows()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 47 def table_rows "##{@@resource_plural}-index tr" end
visible?(selector)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 87 def visible?(selector) find(selector).visible? end
wait_for_ajax(timeout = Capybara.default_wait_time)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 116 def wait_for_ajax(timeout = Capybara.default_wait_time) Timeout.timeout(timeout) do active = page.evaluate_script('jQuery.active') active = page.evaluate_script('jQuery.active') until active == 0 end end
wait_for_ready()
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 112 def wait_for_ready page.has_no_selector?('.nprogress-busy') end
Private Instance Methods
plural(text)
click to toggle source
# File lib/gaku/testing/feature_helpers.rb, line 143 def plural(text) # a = [] a = text.split('-') p = a.last.pluralize result = a[0..-2] << p result * '-' end