Top Level Namespace
Defined Under Namespace
Modules: Capybara, OmniAuth, RSpectacular
Class Method Summary
collapse
Instance Method Summary
collapse
included
Class Method Details
.feature(*args, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/rspectacular/plugins/features.rb', line 28
def self.feature(*args, &block)
options = if args.last.is_a?(Hash) then args.pop else {} end
options[:capybara_feature] = true
options[:type] = :feature
options[:caller] ||= caller
args.push(options)
describe(*args, &block)
end
|
Instance Method Details
#authenticate_with_facebook ⇒ Object
34
35
36
|
# File 'lib/rspectacular/helpers/facebook.rb', line 34
def authenticate_with_facebook
visit '/users/auth/facebook'
end
|
#click_facebook_tab(tab_name) ⇒ Object
38
39
40
|
# File 'lib/rspectacular/helpers/facebook.rb', line 38
def click_facebook_tab(tab_name)
find(:xpath, %Q{.//span[starts-with(., '#{tab_name}')]/../..}).click()
end
|
1
2
3
4
5
6
7
8
9
10
11
|
# File 'lib/rspectacular/helpers/facebook.rb', line 1
def fill_in_facebook_login_form(options = {})
facebook_user = options[:with]
sleep 1
within sf('the Facebook login form') do
fill_in 'Email', :with => facebook_user['email']
fill_in 'Password', :with => facebook_user['password']
click_link_or_button 'Log In'
end
end
|
23
24
25
26
27
28
29
30
|
# File 'lib/rspectacular/helpers/paypal.rb', line 23
def fill_in_paypal_login_form(email, password)
fill_in 'Email', :with => email
fill_in 'PayPal password', :with => password
click_link_or_button 'Log In'
check 'esignOpt'
click_link_or_button 'Agree and Continue'
end
|
#flash_alert ⇒ Object
5
6
7
|
# File 'lib/rspectacular/helpers/rails_flashes.rb', line 5
def flash_alert
fsf('the flash alert').text
end
|
#flash_message ⇒ Object
1
2
3
|
# File 'lib/rspectacular/helpers/rails_flashes.rb', line 1
def flash_message
fsf('the flash').text
end
|
#flash_notice ⇒ Object
13
14
15
|
# File 'lib/rspectacular/helpers/rails_flashes.rb', line 13
def flash_notice
fsf('the flash notice').text
end
|
#flash_warning ⇒ Object
9
10
11
|
# File 'lib/rspectacular/helpers/rails_flashes.rb', line 9
def flash_warning
fsf('the flash warning').text
end
|
#fsf(*args) ⇒ Object
1
2
3
4
5
6
|
# File 'lib/rspectacular/selectors.rb', line 1
def fsf(*args)
selector = sf(*args)
selector_format = selector.starts_with?('.//') ? :xpath : :css
page.find(selector_format, selector)
end
|
#idsf(*args) ⇒ Object
8
9
10
11
|
# File 'lib/rspectacular/selectors.rb', line 8
def idsf(*args)
id_selector = sf(*args)
id_selector.starts_with?('#') ? id_selector[1..-1] : id_selector
end
|
#log_in(user, options = {}) ⇒ Object
2
3
4
5
|
# File 'lib/rspectacular/helpers/session_helpers.rb', line 2
def log_in(user, options = {})
initial_path = options.fetch(:initial_path, :root_path)
visit send(initial_path, :auth_token => user.authentication_token)
end
|
#log_in_to_facebook(user) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rspectacular/helpers/facebook.rb', line 13
def log_in_to_facebook(user)
visit 'https://www.facebook.com/login.php'
sleep 3
fill_in 'Email', :with => user['email']
fill_in 'Password', :with => user['password']
click_link_or_button 'Log In'
end
|
#log_in_to_paypal_sandbox(email, password) ⇒ Object
1
2
3
4
5
6
7
8
9
|
# File 'lib/rspectacular/helpers/paypal.rb', line 1
def log_in_to_paypal_sandbox(email, password)
visit 'https://developer.paypal.com'
if page.has_button? 'Log In'
fill_in 'Email', :with => email
fill_in 'Password', :with => password
click_link_or_button 'Log In'
end
end
|
#log_out ⇒ Object
7
8
9
|
# File 'lib/rspectacular/helpers/session_helpers.rb', line 7
def log_out
visit destroy_user_session_path
end
|
#log_out_of_facebook ⇒ Object
29
30
31
32
|
# File 'lib/rspectacular/helpers/facebook.rb', line 29
def log_out_of_facebook
click_link idsf('the Facebook account menu')
click_button 'Log Out'
end
|
#log_out_of_paypal ⇒ Object
11
12
13
|
# File 'lib/rspectacular/helpers/paypal.rb', line 11
def log_out_of_paypal
visit 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_logout'
end
|
#log_out_of_paypal_sandbox ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/rspectacular/helpers/paypal.rb', line 15
def log_out_of_paypal_sandbox
visit 'https://developer.paypal.com'
if page.has_link? 'Log Out'
click_link 'Log Out'
end
end
|
#remove_app_from_authorized_apps_at_facebook(app_name) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/rspectacular/helpers/facebook.rb', line 42
def remove_app_from_authorized_apps_at_facebook(app_name)
visit 'http://www.facebook.com/settings?tab=applications'
page.should_not have_content 'You have not authorized any apps to interact with your Facebook account.'
page.should have_content app_name
find("input[type='button'][title='Remove']").click()
sleep 1
click_link_or_button 'Remove'
sleep 1
page.should_not have_content app_name
log_out_of_facebook
end
|
#select_date(date, options = {}) ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/rspectacular/helpers/date_time_select.rb', line 4
def select_date(date, options = {})
date = Time.parse(date)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])
page.execute_script %Q{$("##{base_dom_id}_1i").val("#{date.strftime('%Y')}")}
page.execute_script %Q{$("##{base_dom_id}_2i").val("#{date.strftime('%m')}")}
page.execute_script %Q{$("##{base_dom_id}_3i").val("#{date.strftime('%d')}")}
page.execute_script %Q{$("##{base_dom_id}_datepicker").val("#{date.strftime('%m/%d/%Y')}")}
page.execute_script %Q{$("##{base_dom_id}_datepicker").change()}
end
|
#select_datetime(datetime, options = {}) ⇒ Object
25
26
27
28
|
# File 'lib/rspectacular/helpers/date_time_select.rb', line 25
def select_datetime(datetime, options = {})
select_date(datetime, options)
select_time(datetime, options)
end
|
#select_time(time, options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/rspectacular/helpers/date_time_select.rb', line 15
def select_time(time, options = {})
time = Time.zone.parse(time)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])
find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.strftime '%I %p')
find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
page.execute_script %Q{$("##{base_dom_id}_datepicker").change()}
end
|
#sf(*args) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/rspectacular/selectors.rb', line 13
def sf(*args)
string = args.shift
selector = RSpectacular::Selectors.find { |regex, selector| string.match regex }
if selector.present?
if selector.respond_to? :call
selector.call(*args)
else
selector
end
end
end
|