magneton 0.1.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.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +115 -0
- data/Rakefile +1 -0
- data/bin/magneton +137 -0
- data/bin/magneton-helpers.rb +59 -0
- data/lib/magneton/locales/en.yml +6 -0
- data/lib/magneton/locales/pt.yml +6 -0
- data/lib/magneton/magneton.rb +6 -0
- data/lib/magneton/version.rb +3 -0
- data/lib/skeleton/.gitignore +4 -0
- data/lib/skeleton/Gemfile +12 -0
- data/lib/skeleton/README.md +127 -0
- data/lib/skeleton/cucumber.yml +11 -0
- data/lib/skeleton/features/pages/.gitkeep +0 -0
- data/lib/skeleton/features/specifications/.gitkeep +0 -0
- data/lib/skeleton/features/steps_definitions/.gitkeep +0 -0
- data/lib/skeleton/features/support/config/dev.yaml +0 -0
- data/lib/skeleton/features/support/config/hmg.yaml +0 -0
- data/lib/skeleton/features/support/env.rb +33 -0
- data/lib/skeleton/features/support/helper.rb +19 -0
- data/lib/skeleton/features/support/hooks.rb +29 -0
- data/lib/skeleton/features/support/matchers/custom.rb +13 -0
- data/lib/skeleton/readme_img/step_1.png +0 -0
- data/lib/skeleton/readme_img/step_2.png +0 -0
- data/lib/templates/feature.tt +8 -0
- data/lib/templates/page.tt +6 -0
- data/lib/templates/steps.tt +5 -0
- data/magneton.gemspec +26 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0a171d1a1cbde409853b71baa46ba6769b125b6
|
4
|
+
data.tar.gz: ee16018ba5b51b6f085f6893f3c745ceb20a1dd7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2fc6a89f42afb1969387bc1fc241ff8ab17c562223f1ecb130e0f6c3cb746036a19df911511fe2e66b2353088f2d800a76931d330f11beccd65502306a80fffc
|
7
|
+
data.tar.gz: 08cece00a1c35b055b9a34c495df5c1460a0ed53fa62266b3b11e3dabdcc578a02e11b12124c35541124c949bbb094a7a9ab8ae474660446e70e8d9fb2fd3439
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 CSOscarTanner
|
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,115 @@
|
|
1
|
+
# MAGNETON
|
2
|
+
|
3
|
+
A simple gem to generate web automation project with:
|
4
|
+
|
5
|
+
> Cucumber [(link)](https://cucumber.io/)
|
6
|
+
|
7
|
+
> Capybara [(link)](https://github.com/jnicklas/capybara)
|
8
|
+
|
9
|
+
> SitePrism [(link)](https://github.com/natritmeyer/site_prism)
|
10
|
+
|
11
|
+
> Selenium Webdriver [(link)](http://www.seleniumhq.org/)
|
12
|
+
|
13
|
+
The structure is based on three layers: features, steps and pages.
|
14
|
+
|
15
|
+
1. Features: Contains all the features of the project;
|
16
|
+
2. Steps: Contains all the steps implementations;
|
17
|
+
3. Pages: Contains all the pages in the website. A page must contain the declaration of all the elements of the page and the declaration of its actions.
|
18
|
+
|
19
|
+
## Instalation
|
20
|
+
|
21
|
+
Install it as:
|
22
|
+
|
23
|
+
$ gem install magneton
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
In the terminal, type for help:
|
28
|
+
|
29
|
+
```
|
30
|
+
magneton
|
31
|
+
magneton generate
|
32
|
+
```
|
33
|
+
|
34
|
+
To see the gem version type:
|
35
|
+
|
36
|
+
```
|
37
|
+
magneton version
|
38
|
+
```
|
39
|
+
|
40
|
+
To generate a project type:
|
41
|
+
|
42
|
+
```
|
43
|
+
magneton new ProjectName
|
44
|
+
```
|
45
|
+
|
46
|
+
### Windows Caveats
|
47
|
+
|
48
|
+
##### If you face encoding problems, type: #####
|
49
|
+
```
|
50
|
+
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "AutoRun"="chcp 65001"
|
51
|
+
```
|
52
|
+
This command will ensure your terminal is always using Unicode.
|
53
|
+
|
54
|
+
#### Localized Project Generation
|
55
|
+
This command will create a folder named ProjectName in the current directory and will create all the needed files. This gem support localizations. To create a localized project, in Portuguese, type:
|
56
|
+
|
57
|
+
```
|
58
|
+
magneton new ProjectName --lang=pt
|
59
|
+
```
|
60
|
+
|
61
|
+
> The default language is English ('en'). The elements of Gherkin such as Given, When, Then, And, Scenario will be translated to all Gherkin supported languages, but this gem has just a few translation files (see that in folder: `lib/magneton/locales`).
|
62
|
+
|
63
|
+
> **MAGNETON doesn't support your mother language?** No problem. Fork it, create your yml translation file, uses the en.yml file as a template. Translate it and make a pull request. There are only 15 lines to be translated, this will take no time.
|
64
|
+
|
65
|
+
> **Want to know how to name your translation yml file?** See the Gherkin supported languages [here](https://github.com/cucumber/gherkin/blob/master/lib/gherkin/i18n.json) for reference.
|
66
|
+
|
67
|
+
Once the project is created, open its folder (`cd ProjectName`) and run `bundle install`
|
68
|
+
|
69
|
+
There are three generators that are responsible to create the templates for Features, Step definitions and Pages.
|
70
|
+
|
71
|
+
**The generators commands ONLY WORK in the ROOT FOLDER of the project.**
|
72
|
+
|
73
|
+
#### Features
|
74
|
+
|
75
|
+
```
|
76
|
+
magneton generate feature FeatureName
|
77
|
+
```
|
78
|
+
The feature generator will create a feature and its files. So this command will create the FeatureName.feature file inside the folder `features/specifications`, the file FeatureName_steps.rb inside the folder `features/step_definitions`, the files FeatureName_page.rb inside the folder `features/pages`.
|
79
|
+
|
80
|
+
#### Steps
|
81
|
+
|
82
|
+
```
|
83
|
+
magneton generate step StepName
|
84
|
+
```
|
85
|
+
The step generator will create a step file named StepName_steps.rb in the folder `features/step_definitions`
|
86
|
+
|
87
|
+
|
88
|
+
#### Pages
|
89
|
+
|
90
|
+
```
|
91
|
+
magneton generate page PageName
|
92
|
+
```
|
93
|
+
|
94
|
+
The page generator will create a page file named PageName_page.rb in the folder `features/pages`
|
95
|
+
|
96
|
+
#### Helpers
|
97
|
+
|
98
|
+
In the file `features/support/helper.rb` you will find utilities to help your tests.
|
99
|
+
|
100
|
+
Implemented so far:
|
101
|
+
- take_screenshot
|
102
|
+
- mouse_over
|
103
|
+
|
104
|
+
## TODO
|
105
|
+
|
106
|
+
1. Run tests in Remote Server
|
107
|
+
2. Add more base methods using Selenium
|
108
|
+
|
109
|
+
## Contributing
|
110
|
+
|
111
|
+
1. Fork it ( https://github.com/concretesolutions/magneton )
|
112
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
113
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
114
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
115
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/magneton
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
require 'thor/group'
|
6
|
+
require 'i18n'
|
7
|
+
require 'gherkin' # Used here as a translation source
|
8
|
+
require 'json'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
require File.join(File.dirname(__FILE__), 'magneton-helpers')
|
12
|
+
require_relative '../lib/magneton/version'
|
13
|
+
|
14
|
+
module MAGNETON
|
15
|
+
# Definition of all gem generators
|
16
|
+
class Generate < Thor
|
17
|
+
include Thor::Actions
|
18
|
+
|
19
|
+
desc 'feature [RESOURCE_NAME]', 'Generates a feature'
|
20
|
+
option :lang,
|
21
|
+
banner: 'any of the gherkin supported languages',
|
22
|
+
default: :en
|
23
|
+
def feature(name)
|
24
|
+
I18n.config.default_locale = options[:lang]
|
25
|
+
in_root_project_folder?
|
26
|
+
|
27
|
+
create_feature_file(name)
|
28
|
+
create_steps_file name
|
29
|
+
create_page_file name
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'step [RESOURCE_NAME]', 'Generates a step'
|
33
|
+
option :lang,
|
34
|
+
banner: 'any of the gherkin supported languages',
|
35
|
+
default: :en
|
36
|
+
def step(name)
|
37
|
+
I18n.config.default_locale = options[:lang]
|
38
|
+
in_root_project_folder?
|
39
|
+
create_steps_file name
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'page [RESOURCE_NAME]',
|
43
|
+
'Generates pages'
|
44
|
+
option :lang,
|
45
|
+
banner: 'any of the gherkin supported languages',
|
46
|
+
default: :en
|
47
|
+
def page(name)
|
48
|
+
I18n.config.default_locale = options[:lang]
|
49
|
+
in_root_project_folder?
|
50
|
+
create_page_file name
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.source_root
|
54
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'templates')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module MAGNETON
|
60
|
+
# Definition of the generators groups
|
61
|
+
class MagnetonRunner < Thor
|
62
|
+
include Thor::Actions
|
63
|
+
|
64
|
+
map '-v' => :version
|
65
|
+
map '--version' => :version
|
66
|
+
|
67
|
+
default_task :help
|
68
|
+
|
69
|
+
register MAGNETON::Generate, 'generate',
|
70
|
+
'generate [GENERATOR] [RESOURCE_NAME]',
|
71
|
+
'Generates various resources'
|
72
|
+
register MAGNETON::Generate, 'g',
|
73
|
+
'g [GENERATOR] [RESOURCE_NAME]',
|
74
|
+
'Generates various resources'
|
75
|
+
|
76
|
+
desc 'new PROJECT_NAME',
|
77
|
+
'Generates the structure of a new project that uses '\
|
78
|
+
'Capybara, SitePrism, Selenium and Cucumber'
|
79
|
+
option :lang,
|
80
|
+
banner: 'any of the gherkin supported languages',
|
81
|
+
default: :en
|
82
|
+
def new(name)
|
83
|
+
I18n.config.default_locale = options[:lang]
|
84
|
+
# Thor will be responsible to look for identical
|
85
|
+
# files and possibles conflicts
|
86
|
+
directory File.join(File.dirname(__FILE__),
|
87
|
+
'..', 'lib', 'skeleton'), name
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'version', 'Shows the gem version'
|
92
|
+
def version
|
93
|
+
puts "magneton Version #{MAGNETON::VERSION}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.source_root
|
97
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'templates')
|
98
|
+
end
|
99
|
+
|
100
|
+
# Overriding the initialize method to load all the
|
101
|
+
# translations supported by the gem gherkin
|
102
|
+
def initialize(*args)
|
103
|
+
super
|
104
|
+
# Loading gherkin accepted translations
|
105
|
+
translations_file_path = File.join(
|
106
|
+
Gem.loaded_specs['gherkin'].full_gem_path,
|
107
|
+
'lib',
|
108
|
+
'gherkin',
|
109
|
+
'i18n.json'
|
110
|
+
)
|
111
|
+
# Parsing the JSON file
|
112
|
+
# Removing the sequence *| and all the alternative
|
113
|
+
# options for the gherkin translations
|
114
|
+
translations_json = JSON.parse(
|
115
|
+
File.read(translations_file_path)
|
116
|
+
.gsub(/\*\|/, '')
|
117
|
+
.gsub(/\|.*\"/, '"'))
|
118
|
+
# Converting the translations to YAML and storing in a temp file
|
119
|
+
translations_temp_file = Tempfile.new(['translations', '.yml'])
|
120
|
+
File.write(translations_temp_file, translations_json.to_yaml)
|
121
|
+
# Loading the translations from gherkin and from the
|
122
|
+
# locales folder of this gem
|
123
|
+
locales_folder_path = File.join(
|
124
|
+
File.dirname(__FILE__),
|
125
|
+
'..', 'lib', 'magneton', 'locales'
|
126
|
+
)
|
127
|
+
I18n.load_path = Dir[
|
128
|
+
translations_temp_file,
|
129
|
+
File.join(locales_folder_path, '*.yml')
|
130
|
+
]
|
131
|
+
I18n.backend.load_translations
|
132
|
+
I18n.config.enforce_available_locales = true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
MAGNETON::MagnetonRunner.start
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
def create_feature_file(name)
|
5
|
+
# options used to generate the file in the template function
|
6
|
+
opts = { name: camelize(name) }
|
7
|
+
|
8
|
+
# Feature
|
9
|
+
file_path = File.join(FileUtils.pwd, 'features', 'specifications', "#{name.downcase}.feature")
|
10
|
+
|
11
|
+
# Thor creates a file based on the templates/feature.tt template
|
12
|
+
template('feature', file_path, opts)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_steps_file(name)
|
16
|
+
# options used to generate the file in the template function
|
17
|
+
opts = { name: camelize(name) }
|
18
|
+
|
19
|
+
# Step
|
20
|
+
file_path = File.join(
|
21
|
+
FileUtils.pwd, 'features', 'steps_definitions',
|
22
|
+
"#{name.downcase}_steps.rb"
|
23
|
+
)
|
24
|
+
|
25
|
+
# Thor creates a file based on the templates/steps.tt template
|
26
|
+
template('steps', file_path, opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_page_file(name)
|
30
|
+
# options used to generate the file in the template function
|
31
|
+
opts = { name: camelize(name) }
|
32
|
+
|
33
|
+
# Thor creates a file based on the templates/page.tt template
|
34
|
+
template('page',
|
35
|
+
File.join(
|
36
|
+
FileUtils.pwd, 'features', 'pages',
|
37
|
+
"#{name.downcase}_page.rb"),
|
38
|
+
opts)
|
39
|
+
end
|
40
|
+
|
41
|
+
def camelize(string)
|
42
|
+
camelized = ''
|
43
|
+
|
44
|
+
string.split('_').each do |s|
|
45
|
+
camelized += s.capitalize
|
46
|
+
end
|
47
|
+
|
48
|
+
camelized
|
49
|
+
end
|
50
|
+
|
51
|
+
def in_root_project_folder?
|
52
|
+
# Looks if the user is in the root folder of the project
|
53
|
+
if !Dir.exist?(File.join(FileUtils.pwd, 'features', 'specifications'))
|
54
|
+
puts 'Please run this command on the root folder of the project'
|
55
|
+
exit 1
|
56
|
+
end
|
57
|
+
|
58
|
+
true
|
59
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
## Getting Started ##
|
2
|
+
|
3
|
+
### Installing rbenv ###
|
4
|
+
To install rbenv type:
|
5
|
+
```shell
|
6
|
+
brew install rbenv
|
7
|
+
```
|
8
|
+
|
9
|
+
Add to ~/.bash_profile:
|
10
|
+
```shell
|
11
|
+
eval "$(rbenv init -)"
|
12
|
+
```
|
13
|
+
|
14
|
+
List all available versions:
|
15
|
+
```shell
|
16
|
+
rbenv install -l
|
17
|
+
```
|
18
|
+
|
19
|
+
Install a Ruby version:
|
20
|
+
```shell
|
21
|
+
rbenv install 2.3.1
|
22
|
+
```
|
23
|
+
|
24
|
+
Sets a local application-specific Ruby 2.3.1:
|
25
|
+
```shell
|
26
|
+
rbenv local 2.3.1
|
27
|
+
```
|
28
|
+
|
29
|
+
### Installing bundler ###
|
30
|
+
To install bundler type:
|
31
|
+
```shell
|
32
|
+
gem install bundler
|
33
|
+
```
|
34
|
+
|
35
|
+
### Windows Caveats ###
|
36
|
+
|
37
|
+
##### Preparing Internet Explorer #####
|
38
|
+
|
39
|
+
1. Check zoom level. It must be configured to 100%:
|
40
|
+
|
41
|
+

|
42
|
+
|
43
|
+
2. Disable 'Protected Mode' for all zones on Internet Options > Security:
|
44
|
+
|
45
|
+

|
46
|
+
|
47
|
+
##### Install FFI #####
|
48
|
+
|
49
|
+
To install FFI package type:
|
50
|
+
```shell
|
51
|
+
bundle install ffi --platform ruby
|
52
|
+
```
|
53
|
+
|
54
|
+
### Installing gems ###
|
55
|
+
To install gems type:
|
56
|
+
```shell
|
57
|
+
bundle install
|
58
|
+
```
|
59
|
+
|
60
|
+
### Drivers: ###
|
61
|
+
Install and include in PATH
|
62
|
+
- [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
|
63
|
+
- [phantomjs](http://phantomjs.org/)
|
64
|
+
- [internetExplorerDriver](http://www.seleniumhq.org/download/)
|
65
|
+
|
66
|
+
Install [Webdriver Safari extension](http://selenium-release.storage.googleapis.com/2.48/SafariDriver.safariextz).
|
67
|
+
|
68
|
+
|
69
|
+
### Run tests in DEV with Chrome###
|
70
|
+
Type this in the tests folder:
|
71
|
+
```shell
|
72
|
+
bundle exec cucumber
|
73
|
+
```
|
74
|
+
|
75
|
+
### Run tests in DEV with Firefox###
|
76
|
+
Type this in the tests folder:
|
77
|
+
```shell
|
78
|
+
bundle exec cucumber -p firefox -p dev
|
79
|
+
```
|
80
|
+
|
81
|
+
### Run tests in DEV with Safari###
|
82
|
+
Type this in the tests folder:
|
83
|
+
```shell
|
84
|
+
bundle exec cucumber -p safari -p dev
|
85
|
+
```
|
86
|
+
|
87
|
+
### Run tests in DEV with Poltergeist###
|
88
|
+
Type this in the tests folder:
|
89
|
+
```shell
|
90
|
+
bundle exec cucumber -p poltergeist -p dev
|
91
|
+
```
|
92
|
+
|
93
|
+
### Run tests in HMG with Chrome###
|
94
|
+
Type this in the tests folder:
|
95
|
+
```shell
|
96
|
+
bundle exec cucumber -p chrome -p hmg
|
97
|
+
```
|
98
|
+
|
99
|
+
### Run tests in HMG with Firefox###
|
100
|
+
Type this in the tests folder:
|
101
|
+
```shell
|
102
|
+
bundle exec cucumber -p firefox -p hmg
|
103
|
+
```
|
104
|
+
|
105
|
+
### Run tests in HMG with Safari###
|
106
|
+
Type this in the tests folder:
|
107
|
+
```shell
|
108
|
+
bundle exec cucumber -p safari -p hmg
|
109
|
+
```
|
110
|
+
|
111
|
+
### Run tests in HMG with Poltergeist###
|
112
|
+
Type this in the tests folder:
|
113
|
+
```shell
|
114
|
+
bundle exec cucumber -p poltergeist -p hmg
|
115
|
+
```
|
116
|
+
|
117
|
+
### HTML Report###
|
118
|
+
Type this in the tests folder:
|
119
|
+
```shell
|
120
|
+
bundle exec cucumber -p html_report
|
121
|
+
```
|
122
|
+
|
123
|
+
### Run with tags###
|
124
|
+
Type this in the tests folder:
|
125
|
+
```shell
|
126
|
+
bundle exec cucumber --tags @run
|
127
|
+
```
|
@@ -0,0 +1,11 @@
|
|
1
|
+
##YAML Template
|
2
|
+
---
|
3
|
+
default: -p html_report -p chrome -p dev
|
4
|
+
html_report: --format progress --format html --out=features_report.html
|
5
|
+
firefox: BROWSER=firefox
|
6
|
+
chrome: BROWSER=chrome
|
7
|
+
poltergeist: BROWSER=poltergeist
|
8
|
+
internet_explorer: BROWSER=internet_explorer
|
9
|
+
safari: BROWSER=safari
|
10
|
+
dev: ENVIRONMENT_TYPE=dev
|
11
|
+
hmg: ENVIRONMENT_TYPE=hmg
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
require 'capybara/cucumber'
|
3
|
+
require 'selenium-webdriver'
|
4
|
+
require 'site_prism'
|
5
|
+
require 'rspec'
|
6
|
+
require 'yaml'
|
7
|
+
require 'capybara/poltergeist'
|
8
|
+
|
9
|
+
BROWSER = ENV['BROWSER']
|
10
|
+
ENVIRONMENT_TYPE = ENV['ENVIRONMENT_TYPE']
|
11
|
+
|
12
|
+
## register driver according with browser chosen
|
13
|
+
Capybara.register_driver :selenium do |app|
|
14
|
+
if BROWSER.eql?('chrome')
|
15
|
+
Capybara::Selenium::Driver.new(app,
|
16
|
+
:browser => :chrome,
|
17
|
+
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(
|
18
|
+
'chromeOptions' => {
|
19
|
+
'args' => [ "--start-maximized" ]
|
20
|
+
}
|
21
|
+
)
|
22
|
+
)
|
23
|
+
elsif BROWSER.eql?('firefox')
|
24
|
+
Capybara::Selenium::Driver.new(app, :browser => :firefox)
|
25
|
+
elsif BROWSER.eql?('internet_explorer')
|
26
|
+
Capybara::Selenium::Driver.new(app, :browser => :internet_explorer)
|
27
|
+
elsif BROWSER.eql?('safari')
|
28
|
+
Capybara::Selenium::Driver.new(app, :browser => :safari)
|
29
|
+
elsif BROWSER.eql?('poltergeist')
|
30
|
+
options = { js_errors: false }
|
31
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# !/usr/bin/env ruby
|
3
|
+
require 'fileutils'
|
4
|
+
class Helper
|
5
|
+
def mouse_over(element_selector)
|
6
|
+
element = Capybara.page.driver.browser.find_element(:css, element_selector)
|
7
|
+
Capybara.page.driver.browser.mouse.move_to element
|
8
|
+
end
|
9
|
+
|
10
|
+
def take_screenshot(name_file, folder='screenshots/test_screens')
|
11
|
+
file = "#{folder}/#{name_file}.png"
|
12
|
+
FileUtils.mkdir_p(folder) unless File.exists?(folder)
|
13
|
+
if BROWSER.eql?('poltergeist')
|
14
|
+
Capybara.page.save_screenshot(file)
|
15
|
+
else
|
16
|
+
Capybara.page.driver.browser.save_screenshot(file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'helper.rb'
|
2
|
+
|
3
|
+
Before do |feature|
|
4
|
+
## variable which loads the data file according to the environment
|
5
|
+
CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config/#{ENVIRONMENT_TYPE}.yaml")
|
6
|
+
|
7
|
+
## configure the chosen browser
|
8
|
+
Capybara.configure do |config|
|
9
|
+
config.default_driver = :selenium
|
10
|
+
end
|
11
|
+
|
12
|
+
## set default max wait and maximize browser
|
13
|
+
Capybara.default_max_wait_time = 60
|
14
|
+
unless BROWSER.eql?('poltergeist')
|
15
|
+
Capybara.current_session.driver.browser.manage.window.maximize
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
After do |scenario|
|
20
|
+
@helper = Helper.new
|
21
|
+
## take screenshot if scenario fail
|
22
|
+
if scenario.failed?
|
23
|
+
@helper.take_screenshot(scenario.name, 'screenshots/test_failed')
|
24
|
+
end
|
25
|
+
## if the browser is different from poltergeist, kills instance
|
26
|
+
unless BROWSER.eql?('poltergeist')
|
27
|
+
Capybara.current_session.driver.quit
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
## matcher to validate if all elements in list are equals
|
4
|
+
RSpec::Matchers.define :all_list_elements_eq do |expected|
|
5
|
+
match do |actual|
|
6
|
+
actual.each do |i|
|
7
|
+
expect(i).to eq(expected)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
failure_message_for_should do |actual|
|
11
|
+
"expected that all elements in #{actual} list would be equals #{expected}"
|
12
|
+
end
|
13
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= "# language: #{options[:lang]}" %>
|
2
|
+
<%= I18n.translate( :feature ) %>: <%= config[:name] %>
|
3
|
+
|
4
|
+
<%= I18n.translate( :background ) %>:
|
5
|
+
# <%= I18n.translate( "comments.insert_steps" ) %>
|
6
|
+
|
7
|
+
<%= I18n.translate( :scenario ) %>: <%= I18n.translate( :first_scenario ) %>
|
8
|
+
# <%= I18n.translate( "comments.insert_steps" ) %>
|
data/magneton.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'magneton/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'magneton'
|
8
|
+
spec.version = MAGNETON::VERSION
|
9
|
+
spec.authors = ['Samanta Cicilia']
|
10
|
+
spec.email = ['samycici@gmail.com']
|
11
|
+
spec.summary = 'Generates an Web Test Automation project with Cucumber, SitePrism, Capybara and Selenium.'
|
12
|
+
spec.description = %q{A simple gem to generate all files needed in a project that will support Cucumber, SitePrism, Capybara and Selenium.}
|
13
|
+
spec.homepage = 'https://github.com/concretesolutions/magneton'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ['magneton']
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'bundler', '>= 1.7'
|
22
|
+
spec.add_runtime_dependency 'rake', '>= 10.0'
|
23
|
+
spec.add_runtime_dependency 'thor', '>= 0.19.1'
|
24
|
+
spec.add_runtime_dependency 'i18n', '>= 0.6.11'
|
25
|
+
spec.add_runtime_dependency 'gherkin', '2.12.2'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magneton
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samanta Cicilia
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.19.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.19.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.6.11
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.6.11
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gherkin
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.12.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.12.2
|
83
|
+
description: A simple gem to generate all files needed in a project that will support
|
84
|
+
Cucumber, SitePrism, Capybara and Selenium.
|
85
|
+
email:
|
86
|
+
- samycici@gmail.com
|
87
|
+
executables:
|
88
|
+
- magneton
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/magneton
|
97
|
+
- bin/magneton-helpers.rb
|
98
|
+
- lib/magneton/locales/en.yml
|
99
|
+
- lib/magneton/locales/pt.yml
|
100
|
+
- lib/magneton/magneton.rb
|
101
|
+
- lib/magneton/version.rb
|
102
|
+
- lib/skeleton/.gitignore
|
103
|
+
- lib/skeleton/Gemfile
|
104
|
+
- lib/skeleton/README.md
|
105
|
+
- lib/skeleton/cucumber.yml
|
106
|
+
- lib/skeleton/features/pages/.gitkeep
|
107
|
+
- lib/skeleton/features/specifications/.gitkeep
|
108
|
+
- lib/skeleton/features/steps_definitions/.gitkeep
|
109
|
+
- lib/skeleton/features/support/config/dev.yaml
|
110
|
+
- lib/skeleton/features/support/config/hmg.yaml
|
111
|
+
- lib/skeleton/features/support/env.rb
|
112
|
+
- lib/skeleton/features/support/helper.rb
|
113
|
+
- lib/skeleton/features/support/hooks.rb
|
114
|
+
- lib/skeleton/features/support/matchers/custom.rb
|
115
|
+
- lib/skeleton/readme_img/step_1.png
|
116
|
+
- lib/skeleton/readme_img/step_2.png
|
117
|
+
- lib/templates/feature.tt
|
118
|
+
- lib/templates/page.tt
|
119
|
+
- lib/templates/steps.tt
|
120
|
+
- magneton.gemspec
|
121
|
+
homepage: https://github.com/concretesolutions/magneton
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Generates an Web Test Automation project with Cucumber, SitePrism, Capybara
|
145
|
+
and Selenium.
|
146
|
+
test_files: []
|