capybara-user_agent 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +1 -0
- data/capybara-user_agent.gemspec +20 -0
- data/lib/capybara-user_agent.rb +6 -0
- data/lib/capybara/user_agent.rb +33 -0
- data/lib/capybara/user_agent/dsl.rb +13 -0
- data/lib/capybara/user_agent/version.rb +5 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 mururu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Capybara::UserAgent
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'capybara-user_agent'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install capybara-user_agent
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Rspec
|
20
|
+
|
21
|
+
in your `spec_helper`
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'capybara/user_agent'
|
25
|
+
|
26
|
+
Capybara::UserAgent.add_user_agents(your_browser: 'your_user_agent/1.0')
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.include Capybara::UserAgent::DSL
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
Example:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
feature 'your_feature' do
|
37
|
+
context 'iphone' do
|
38
|
+
background do
|
39
|
+
set_user_agent(:iphone)
|
40
|
+
end
|
41
|
+
|
42
|
+
scenario 'your_scenario' do
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'your_browser' do
|
47
|
+
background do
|
48
|
+
set_user_agent(:your_browser)
|
49
|
+
end
|
50
|
+
|
51
|
+
scenario 'your_scenario' do
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'your_browser' do
|
56
|
+
background do
|
57
|
+
set_custom_user_agent('your_user_agent/2.0')
|
58
|
+
end
|
59
|
+
|
60
|
+
scenario 'your_scenario' do
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
### Now Available UserAgents
|
67
|
+
|
68
|
+
* iphone
|
69
|
+
* ipod
|
70
|
+
* ipad
|
71
|
+
* android
|
72
|
+
* android_tablet
|
73
|
+
* windows_phone
|
74
|
+
* black_berry
|
75
|
+
* ie7
|
76
|
+
* ie8
|
77
|
+
* ie9
|
78
|
+
* ie10
|
79
|
+
* chrome
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
1. Fork it
|
84
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'capybara/user_agent/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "capybara-user_agent"
|
7
|
+
gem.version = Capybara::UserAgent::VERSION
|
8
|
+
gem.authors = ["Yuki Ito"]
|
9
|
+
gem.email = ["yuki@gnnk.net"]
|
10
|
+
gem.description = %q{UserAgent DSL on Capybara}
|
11
|
+
gem.summary = %q{UserAgent DSL on Capybara}
|
12
|
+
gem.homepage = "https://github.com/mururu/capybara-user_agent"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_runtime_dependency("capybara", "~> 2.0", ">= 2.0.2")
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Capybara
|
2
|
+
module UserAgent
|
3
|
+
class << self
|
4
|
+
def user_agents
|
5
|
+
@user_agents ||= default_user_agents
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_user_agents(agents)
|
9
|
+
user_agents.merge! agents
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_user_agents
|
13
|
+
{
|
14
|
+
iphone: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334 Safari/7534.48.3',
|
15
|
+
ipod: 'Mozilla/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3',
|
16
|
+
ipad: 'Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3',
|
17
|
+
android: 'Mozilla/5.0 (Linux; U; Android 2.3.3; ja-jp; SonyEricssonX10i Build/3.0.1.G.0.75) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
|
18
|
+
android_tablet: 'Mozilla/5.0 (Linux; U; Android 3.1; ja-jp; Sony Tablet S Build/THMAS10000) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13',
|
19
|
+
windows_phone: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; KDDI-TS01; Windows Phone 6.5.3.5)',
|
20
|
+
black_berry: 'BlackBerry9700/5.0.0.1014 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/220',
|
21
|
+
ie7: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)',
|
22
|
+
ie8: 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)',
|
23
|
+
ie9: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
24
|
+
ie10: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)',
|
25
|
+
chrome: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7',
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
autoload :DSL, 'capybara/user_agent/dsl'
|
31
|
+
autoload :Version, 'capybara/user_agent/version'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Capybara
|
2
|
+
module UserAgent
|
3
|
+
module DSL
|
4
|
+
def set_user_agent(type)
|
5
|
+
set_custom_user_agent(Capybara::UserAgent.user_agents[type])
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_custom_user_agent(user_agent)
|
9
|
+
Capybara.current_session.driver.header('User-Agent', user_agent)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capybara-user_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yuki Ito
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capybara
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.0.2
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.0.2
|
36
|
+
description: UserAgent DSL on Capybara
|
37
|
+
email:
|
38
|
+
- yuki@gnnk.net
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE.txt
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- capybara-user_agent.gemspec
|
49
|
+
- lib/capybara-user_agent.rb
|
50
|
+
- lib/capybara/user_agent.rb
|
51
|
+
- lib/capybara/user_agent/dsl.rb
|
52
|
+
- lib/capybara/user_agent/version.rb
|
53
|
+
homepage: https://github.com/mururu/capybara-user_agent
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.23
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: UserAgent DSL on Capybara
|
77
|
+
test_files: []
|
78
|
+
has_rdoc:
|