RSpecMethodGrouping
This gem manages supporting methods that are used in rspec example.
Installation
gem 'rspec_method_grouping'
Usage
before
In defining methods, we need long different names. They are not readable.
def
find('button', text: 'Register Now!')
end
def
find('button', text: 'Send Now!')
end
describe 'registration' do
it do
visit '/resistration'
# input data to some form
.click
visit '/contact'
# input data to some form
.click
end
end
After
In defining methods, we need some steps. But, They are readable and easy to detect names.
class RegistrationPage < RSpecMethodGrouping::Base
def
find('button', text: 'Register Now!')
end
end
class ContactPage < RSpecMethodGrouping::Base
def
find('button', text: 'Send Now!')
end
end
describe 'registration' do
it do
visit '/resistration'
# input data to some form
RegistrationPage..click
visit '/contact'
# input data to some form
ContactPage..click
end
end