selenium-webdriver-rails-support-via-monkeypatch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
|
|
1
|
+
module SeleniumWebDriverRemoteRailsSupportMonkeyPathOfDoom
|
2
|
+
def self.included base
|
3
|
+
base.class_eval do
|
4
|
+
if respond_to? :alias_method_chain
|
5
|
+
alias_method_chain :request, :rails_support_that_fixes_crappy_json
|
6
|
+
else
|
7
|
+
raise "alias_method_chain isn't defined ... are you in a Rails app? If now, why are you using this evil monkeypatch?"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# This is what we *SHOULD* get
|
13
|
+
#
|
14
|
+
# "{\"desiredCapabilities\":{\"javascriptEnabled\":false,\"version\":\"\",\"browserName\":\"htmlunit\",\"platform\":\"ANY\"}}"
|
15
|
+
#
|
16
|
+
# But this is what we get instead
|
17
|
+
#
|
18
|
+
# "{\"desiredCapabilities\":{\"browser_name\":\"htmlunit\",\"javascript_enabled\":false,\"version\":\"\",\"platform\":\"any\"}}"
|
19
|
+
#
|
20
|
+
# To get this fixed *immediately*, we simply rewrite the payload to camelcase key names and upcase the platform.
|
21
|
+
#
|
22
|
+
# We'll find a better way to do this later and submit a patch to selenium. It's ActiveSupport's #to_json that is killing us!
|
23
|
+
#
|
24
|
+
def request_with_rails_support_that_fixes_crappy_json(verb, url, headers, payload, redirects = 0)
|
25
|
+
if payload
|
26
|
+
payload.sub!('browser_name', 'browserName')
|
27
|
+
payload.sub!('javascript_enabled', 'javascriptEnabled')
|
28
|
+
payload.sub!(/"platform":"(\w+)"/){|x| %{"platform":"#{$1.upcase}"} }
|
29
|
+
end
|
30
|
+
request_without_rails_support_that_fixes_crappy_json(verb, url, headers, payload, redirects)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
unless defined? SeleniumWebDriverRemoteRailsSupportMonkeyPathOfDoom
|
35
|
+
require 'selenium-webdriver'
|
36
|
+
end
|
37
|
+
|
38
|
+
# MONKEYPATCH
|
39
|
+
Selenium::WebDriver::Remote::Http::Default.send :include, SeleniumWebDriverRemoteRailsSupportMonkeyPathOfDoom
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: selenium-webdriver-rails-support-via-monkeypatch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- remi
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-25 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Quick monkeypatch to add support for Rails to selenium-webdriver (0.0.28) ... should be fixed soon!
|
22
|
+
email: remi@remitaylor.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/selenium-webdriver-rails-support-via-monkeypatch.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/remi/project-name
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Quick monkeypatch to add support for Rails to selenium-webdriver (0.0.28) ... should be fixed soon!
|
61
|
+
test_files: []
|
62
|
+
|