frameworks-capybara 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,69 +0,0 @@
1
- module SendKeys
2
- def allowed_keys
3
- @allowed_keys ||= %w(
4
- option
5
- null
6
- cancel
7
- help
8
- backspace
9
- tab
10
- clear
11
- return
12
- enter
13
- shift
14
- left_shift
15
- control
16
- left_control
17
- alt
18
- left_alt
19
- pause
20
- escape
21
- space
22
- page_up
23
- page_down
24
- end
25
- home
26
- left
27
- arrow_left
28
- arrow_up
29
- right
30
- arrow_rightdown
31
- arrow_down
32
- insert
33
- delete
34
- semicolon
35
- equals
36
- numpad0 numpad1 numpad2 numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9
37
- multiplyadd
38
- separator
39
- subtract
40
- decimal
41
- divide
42
- f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
43
- )
44
- end
45
-
46
- def send_string_of_keys(key)
47
- send_key = []
48
-
49
- if matches = key.match(%r{^\[(.*)\]$})
50
- key = matches[1].split(',').map(&:strip)
51
- else
52
- key = [key]
53
- end
54
-
55
- key.each do |k|
56
- if matches = k.match(%r{^['"](.*)['"]$})
57
- send_key << matches[1]
58
- elsif allowed_keys.include?(k)
59
- send_key << k.to_sym
60
- else
61
- send_key << k.to_s
62
- end
63
- end
64
-
65
- native.send_keys(send_key)
66
- end
67
- end
68
- #adds methods in this module to the Capybara Element class
69
- Capybara::Node::Element.send :include, SendKeys
@@ -1,61 +0,0 @@
1
- require 'selenium-webdriver'
2
-
3
- #Monkey Patch's - Use with care!
4
- #Path to allow true custom capabilities
5
- #e.g. job name for sauce labs
6
- module Selenium
7
- module WebDriver
8
- module Remote
9
- class Capabilities
10
- def custom_capabilities(opts)
11
- @custom_capabilities = opts
12
- end
13
-
14
- #hopefuly this alias approach will mean we capture changes in the webdriver method
15
- alias_method :old_as_json, :as_json
16
- def as_json(opts = nil)
17
- hash = old_as_json
18
- if @custom_capabilities
19
- @custom_capabilities.each do |key, value|
20
- hash[key] = value
21
- end
22
- end
23
- hash
24
- end
25
- end
26
- end
27
-
28
- class Options
29
- def delete_cookies_in_domain(domain)
30
- delete_all_cookies #proxy to this method as WebDriver only deletes
31
- #by domain
32
- end
33
- end
34
- end
35
- end
36
-
37
- #Workaround for http://code.google.com/p/selenium/issues/detail?id=4007
38
- module Selenium
39
- module WebDriver
40
- module Remote
41
- module Http
42
- class Default
43
- def new_http_client
44
- if @proxy
45
- unless @proxy.respond_to?(:http) && url = @proxy.http
46
- raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
47
- end
48
-
49
- proxy = URI.parse(url)
50
-
51
- clazz = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)
52
- clazz.new(server_url.host, server_url.port)
53
- else
54
- Net::HTTP.new server_url.host, server_url.port
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,124 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/mocks/mock'
3
- require 'uri'
4
-
5
- describe Capybara::Mechanize::Browser do
6
-
7
- RSpec::Mocks::setup(self)
8
-
9
- it "shouldn't send referer if unknown" do
10
-
11
- agent = double()
12
- agent.stub('get' => true)
13
- agent.should_receive('get').with(
14
- "http://example.bbc.co.uk/test",
15
- {},
16
- nil,
17
- {}
18
- )
19
-
20
- driver = double("Capybara::Mechanize::Driver")
21
-
22
- browser = Capybara::Mechanize::Browser.new(driver)
23
- browser.stub('current_url' => "")
24
- browser.stub('agent' => agent)
25
-
26
- browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
27
- end
28
-
29
- it "should not change behaviour for POST requests" do
30
-
31
- agent = double()
32
- agent.stub('post' => true)
33
- agent.should_receive('post').with("http://example.bbc.co.uk/test")
34
-
35
- driver = double("Capybara::Mechanize::Driver")
36
-
37
- browser = Capybara::Mechanize::Browser.new(driver)
38
- browser.stub('current_url' => "http://example.bbc.co.uk/blah")
39
- browser.stub('agent' => agent)
40
-
41
- browser.process_remote_request(:post, 'http://example.bbc.co.uk/test', {}, {})
42
- end
43
-
44
- it "should not send referer for requests from HTTPs to HTTP" do
45
-
46
- agent = double()
47
- agent.stub('get' => true)
48
- agent.should_receive('get').with(
49
- "http://example.bbc.co.uk/test",
50
- {},
51
- nil,
52
- {}
53
- )
54
-
55
- driver = double("Capybara::Mechanize::Driver")
56
-
57
- browser = Capybara::Mechanize::Browser.new(driver)
58
- browser.stub('current_url' => "https://example.bbc.co.uk/blah")
59
- browser.stub('agent' => agent)
60
-
61
- browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
62
- end
63
-
64
- it "should send referer for requests from HTTP to HTTPs" do
65
-
66
- agent = double()
67
- agent.stub('get' => true)
68
- agent.should_receive('get').with(
69
- "https://example.bbc.co.uk/test",
70
- {},
71
- "http://example.bbc.co.uk/blah",
72
- {}
73
- )
74
-
75
- driver = double("Capybara::Mechanize::Driver")
76
-
77
- browser = Capybara::Mechanize::Browser.new(driver)
78
- browser.stub('current_url' => "http://example.bbc.co.uk/blah")
79
- browser.stub('agent' => agent)
80
-
81
- browser.process_remote_request(:get, 'https://example.bbc.co.uk/test', {}, {})
82
- end
83
-
84
- it "should send referer for requests from HTTP to HTTP" do
85
-
86
- agent = double()
87
- agent.stub('get' => true)
88
- agent.should_receive('get').with(
89
- "http://example.bbc.co.uk/test",
90
- {},
91
- "http://example.bbc.co.uk/blah",
92
- {}
93
- )
94
-
95
- driver = double("Capybara::Mechanize::Driver")
96
-
97
- browser = Capybara::Mechanize::Browser.new(driver)
98
- browser.stub('current_url' => "http://example.bbc.co.uk/blah")
99
- browser.stub('agent' => agent)
100
-
101
- browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
102
- end
103
-
104
- it "should send referer for requests from HTTPs to HTTPs" do
105
-
106
- agent = double()
107
- agent.stub('get' => true)
108
- agent.should_receive('get').with(
109
- "https://example.bbc.co.uk/test",
110
- {},
111
- "https://example.bbc.co.uk/blah",
112
- {}
113
- )
114
-
115
- driver = double("Capybara::Mechanize::Driver")
116
-
117
- browser = Capybara::Mechanize::Browser.new(driver)
118
- browser.stub('current_url' => "https://example.bbc.co.uk/blah")
119
- browser.stub('agent' => agent)
120
-
121
- browser.process_remote_request(:get, 'https://example.bbc.co.uk/test', {}, {})
122
- end
123
-
124
- end