11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/generators/files/common_file_generator.rb', line 11
def self.readme_file
rake_file = ERB.new <<~EOF
What is Raider?
===========
Raider is a tool to make the setup and start of automation projects in ruby easier, with one command you are
ready to go
# Pre-requisites:
Install RVM:
https://rvm.io/rvm/install
# How to use the framework:
If you want to run all the tests from your terminal do:
*rspec spec/*
If you want to run all the tests in parallel do:
*parallel_rspec spec/*
# How are specs organized:
We use 'context' as the highest grouping level to indicate in which part of the application we are as an example:
*context 'On the login page'/*
We use 'describe' from the user perspective to describe an action that the user can or cannot take:
*describe 'A user can'/*
or
*describe 'A user cannot'/*
This saves us repetition and forces us into an structure
At last we use 'it' for the specific action the user can or cannot perform:
it 'login with right credentials'
If we group all of this together it will look like
```ruby
context 'On the login page' do
describe 'A user can' do
it 'login with the right credentials' do
end
#{' '}
end
#{' '}
describe 'A user cannot' do
it 'login with the wrong credentials' do
end
end
end
```
#{' '}
This is readed as 'On the login page a user can login with the right credentials' and 'On the login page a user cannot login with the wrong credentials'
# How pages are organized:
```ruby#{' '}
require_relative '../abstract/base_page'
class MainPage < BasePage
using Raider::WatirHelper
def url(_page)
'/'
end
# Actions
def change_currency(currency)
currency_dropdown.select currency
end
# Validations
def validate_currency(currency)
expect(currency_dropdown.include?(currency)).to be true
end
private
# Elements
def currency_dropdown
browser.select(class: %w[dropdown-menu currency])
end
end
```
Pages are organized in Actions (things a user can perform on the page), Validations (assertions), and Elements.
Each page has to have a url define, and each page is using the module WatirHelper to add methods on runtime to the Watir elements
EOF
rake_file.result(binding)
end
|