appium_rspec_setup 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/setup_android +5 -0
- data/bin/setup_ios +5 -0
- data/lib/appium_rspec_setup.rb +9 -0
- data/lib/appium_rspec_setup/gemfile.rb +27 -0
- data/lib/appium_rspec_setup/rspec.rb +7 -0
- data/lib/appium_rspec_setup/setup_android.rb +72 -0
- data/lib/appium_rspec_setup/setup_ios.rb +73 -0
- data/lib/appium_rspec_setup/version.rb +3 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 615f4c195724ce179d82e3d97dc7e8bb16200d82
|
4
|
+
data.tar.gz: 357b34328722935d312e0769e4cdae51cdb82259
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7b4483c6adbac9bb2382adae0bbe16e3d69f9f5cef83a3cfb23c7900147e7461a8af622a4028d36b1a1cc5a87fdd1c851dd8a2a0b08abae5e96e18f46430050
|
7
|
+
data.tar.gz: f294559a698671c06c700a4e31449701dea9c2053b5a2001278138ca698ad123559418c0a1a03a703ea744aefee8dab6a7094b813ab277897b9e199604f99b0c
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Appium RSpec Setup
|
2
|
+
|
3
|
+
Appium Rspec Setup provides a quick way to include both Rspec as a framework to define your tests against and an Appium-compatible library to let it reach through and drive the virtual device of your choice.
|
4
|
+
|
5
|
+
## Setup and Installation
|
6
|
+
This gem only sets up Rspec for use with Appium on your app. In addition to this gem, you will need to have installed and set up the Appium application available here: http://appium.io/
|
7
|
+
|
8
|
+
Create a GemFile in your app's main directory and add the following line:
|
9
|
+
```ruby
|
10
|
+
gem 'appium_rspec_setup'
|
11
|
+
```
|
12
|
+
Run ```bundle```.
|
13
|
+
|
14
|
+
### Android
|
15
|
+
From the command-line, navigate to the main directory for your app and run the following command:
|
16
|
+
```sh
|
17
|
+
setup_android
|
18
|
+
```
|
19
|
+
When prompted, enter your app's name and the platform (Android).
|
20
|
+
|
21
|
+
### iOS
|
22
|
+
From the command-line, navigate to the main directory for your app and run the following command:
|
23
|
+
```sh
|
24
|
+
setup_ios
|
25
|
+
```
|
26
|
+
When prompted, enter your app's name.
|
27
|
+
|
28
|
+
---
|
29
|
+
The setup process should complete within a few seconds, adding the following files to your app's main directory:
|
30
|
+
* app_config.yml
|
31
|
+
* spec/spec_helper.rb
|
32
|
+
|
33
|
+
Do NOT delete these files.
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
Add test files within your spec/ folder
|
37
|
+
|
38
|
+
Run tests from the command-line with the ```rspec``` command.
|
39
|
+
|
40
|
+
Below is a sample file login_spec.rb for an Android app:
|
41
|
+
```ruby
|
42
|
+
describe 'App Login' do
|
43
|
+
before(:all) do
|
44
|
+
Appium::Driver.new(desired_caps).start_driver
|
45
|
+
Appium.promote_appium_methods RSpec::Core::ExampleGroup
|
46
|
+
end
|
47
|
+
|
48
|
+
after(:all) do
|
49
|
+
driver_quit
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'user login' do
|
53
|
+
it 'should have two text fields' do
|
54
|
+
expect(id('login_email_address').nil?).to eq false
|
55
|
+
expect(id('login_password').nil?).to eq false
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have a button' do
|
59
|
+
expect(id('login_button').nil?).to eq false
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should go to splash screen' do
|
63
|
+
id('login_email_address').send_keys('email')
|
64
|
+
id('login_password').send_keys('password')
|
65
|
+
id('login_button').click
|
66
|
+
expect(id('splash_layout').nil?).to eq false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
### Recommended Reading
|
73
|
+
* [Appium Ruby Library](http://www.rubydoc.info/github/appium/ruby_lib/)
|
74
|
+
* [RSpec documentation](https://www.relishapp.com/rspec)
|
75
|
+
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
80
|
+
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "appium_rspec_setup"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/setup_android
ADDED
data/bin/setup_ios
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module AppiumRspecSetup
|
2
|
+
class Gemfile
|
3
|
+
def self.configure_gemfile_and_bundle!
|
4
|
+
file_array = File.readlines('GemFile')
|
5
|
+
|
6
|
+
insert_hash = {
|
7
|
+
'appium_lib' => "gem 'appium_lib'",
|
8
|
+
'rspec' => "gem 'rspec', require: 'spec'",
|
9
|
+
'pry' => "gem 'pry'"
|
10
|
+
}
|
11
|
+
|
12
|
+
offset = -1
|
13
|
+
|
14
|
+
insert_hash.each do |substring_key, line_for_file_value|
|
15
|
+
file_array.insert(offset, line_for_file_value) unless file_array.any? do |line|
|
16
|
+
line.include? substring_key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
File.open('GemFile', 'w') do |file|
|
21
|
+
file.puts file_array
|
22
|
+
end
|
23
|
+
|
24
|
+
%x{bundle}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module AppiumRspecSetup
|
2
|
+
class SetupAndroid
|
3
|
+
def self.setup_android!
|
4
|
+
AppiumRspecSetup::Gemfile.configure_gemfile_and_bundle!
|
5
|
+
AppiumRspecSetup::Rspec.initialize_rspec
|
6
|
+
|
7
|
+
puts 'What is the name of the app?'
|
8
|
+
app_name = gets.chomp
|
9
|
+
|
10
|
+
puts 'What is the name of the platform?'
|
11
|
+
platform_name = gets.chomp
|
12
|
+
|
13
|
+
File.open('app_config.yml', 'w') do |file|
|
14
|
+
file.write %Q{
|
15
|
+
rspec:
|
16
|
+
app_name: #{app_name}
|
17
|
+
platform_name: #{platform_name}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
spec_helper = File.readlines('spec/spec_helper.rb')
|
22
|
+
|
23
|
+
require_hash = {
|
24
|
+
'appium_lib' => "require 'appium_lib'",
|
25
|
+
'pry' => "require 'pry'",
|
26
|
+
'yaml' => "require 'yaml'"
|
27
|
+
}
|
28
|
+
|
29
|
+
require_hash.each do |substring_key, line_for_spec_helper|
|
30
|
+
spec_helper.insert(-1, line_for_spec_helper) unless spec_helper.any? do |line|
|
31
|
+
line.include? substring_key
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
yaml_definitions_hash = {
|
36
|
+
'APP_CONFIG' => "::APP_CONFIG = YAML.load(File.read('./app_config.yml'))",
|
37
|
+
'APP_NAME' => "::APP_NAME = APP_CONFIG['rspec']['app_name']",
|
38
|
+
'PLATFORM_NAME' => "::PLATFORM_NAME = APP_CONFIG['rspec']['platform_name']",
|
39
|
+
'APP_PATH' => "::APP_PATH = \"../\#{APP_NAME}/app/build/outputs/apk/app-debug.apk\""
|
40
|
+
}
|
41
|
+
|
42
|
+
yaml_definitions_hash.each do |substring_key, line_for_spec_helper|
|
43
|
+
spec_helper.insert(-2, line_for_spec_helper) unless spec_helper.any? do |line|
|
44
|
+
line.include? substring_key
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
unless spec_helper.any? { |line| line.include? 'def desired_caps' }
|
49
|
+
spec_helper.insert(-2, %Q{
|
50
|
+
def desired_caps
|
51
|
+
{
|
52
|
+
caps: {
|
53
|
+
:'appium-version' => '1.0',
|
54
|
+
platformName: PLATFORM_NAME,
|
55
|
+
deviceName: 'DJVis',
|
56
|
+
app: APP_PATH,
|
57
|
+
name: APP_NAME
|
58
|
+
},
|
59
|
+
appium_lib: {
|
60
|
+
wait: 60
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
} )
|
65
|
+
end
|
66
|
+
|
67
|
+
File.open('spec/spec_helper.rb', 'w') do |file|
|
68
|
+
file.puts spec_helper
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module AppiumRspecSetup
|
2
|
+
class SetupIos
|
3
|
+
def self.setup_ios!
|
4
|
+
AppiumRspecSetup::Gemfile.configure_gemfile_and_bundle!
|
5
|
+
AppiumRspecSetup::Rspec.initialize_rspec
|
6
|
+
|
7
|
+
puts 'What is the name of the app?'
|
8
|
+
app_name = gets.chomp
|
9
|
+
|
10
|
+
File.open('app_config.yml', 'w') do |file|
|
11
|
+
file.write(%Q{
|
12
|
+
rspec:
|
13
|
+
app_name: #{app_name}
|
14
|
+
device_name: 'iPhone 6'
|
15
|
+
version_number: '8.4'
|
16
|
+
})
|
17
|
+
end
|
18
|
+
|
19
|
+
file_array = File.readlines('spec/spec_helper.rb')
|
20
|
+
|
21
|
+
insert_hash = {
|
22
|
+
'appium_lib' => "require 'appium_lib'",
|
23
|
+
'pry' => "require 'pry'",
|
24
|
+
'yaml' => "require 'yaml'\n"
|
25
|
+
}
|
26
|
+
|
27
|
+
offset = 0
|
28
|
+
|
29
|
+
insert_hash.each do |substring_key, line_for_file_value|
|
30
|
+
file_array.insert(offset, line_for_file_value) unless file_array.any? do |line|
|
31
|
+
line.include? substring_key
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
unless file_array.any? {|line| line.include? '::APP_CONFIG' }
|
36
|
+
file_array.insert(-2, %Q{
|
37
|
+
::APP_CONFIG = YAML.load(File.read("./app_config.yml"))
|
38
|
+
::APP_NAME = APP_CONFIG['rspec']['app_name']
|
39
|
+
::BUILD_FOLDER = Dir["\#{ENV['HOME']}/Library/Developer/Xcode/DerivedData/*"].select{|path|path.include? APP_NAME}.first
|
40
|
+
::APP_PATH = Dir["\#{BUILD_FOLDER}/**/\#{APP_NAME}.app"].first
|
41
|
+
::DEVICE_NAME = APP_CONFIG['rspec']['device_name']
|
42
|
+
::VERSION_NUMBER = APP_CONFIG['rspec']['version_number']
|
43
|
+
}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless file_array.any? {|line| line.include? 'def desired_caps' }
|
48
|
+
file_array.insert(-2, %Q{
|
49
|
+
def desired_caps
|
50
|
+
{
|
51
|
+
caps: {
|
52
|
+
platformName: 'iOS',
|
53
|
+
deviceName: DEVICE_NAME,
|
54
|
+
versionNumber: VERSION_NUMBER,
|
55
|
+
app: APP_PATH
|
56
|
+
},
|
57
|
+
appium_lib: {
|
58
|
+
sauce_username: nil, # don't run on sauce
|
59
|
+
sauce_access_key: nil,
|
60
|
+
wait: 10,
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
}
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
File.open('spec/spec_helper.rb', 'w') do |file|
|
69
|
+
file.puts file_array
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appium_rspec_setup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Lee
|
8
|
+
- Andrew Neely
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.10'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.10'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
description: Makes Appium Rspec set up a snap!
|
43
|
+
email:
|
44
|
+
- jacob.lee@agapered.com
|
45
|
+
- andrew.neely@agapered.com
|
46
|
+
executables:
|
47
|
+
- setup_ios
|
48
|
+
- setup_android
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- README.md
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- bin/setup_android
|
56
|
+
- bin/setup_ios
|
57
|
+
- lib/appium_rspec_setup.rb
|
58
|
+
- lib/appium_rspec_setup/gemfile.rb
|
59
|
+
- lib/appium_rspec_setup/rspec.rb
|
60
|
+
- lib/appium_rspec_setup/setup_android.rb
|
61
|
+
- lib/appium_rspec_setup/setup_ios.rb
|
62
|
+
- lib/appium_rspec_setup/version.rb
|
63
|
+
homepage: ''
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
allowed_push_host: https://rubygems.org
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.2.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Makes Appium Rspec set up a snap!
|
88
|
+
test_files: []
|