Skip to content

mmmpa/rspec_method_grouping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSpecMethodGrouping

This gem manages supporting methods that are used in rspec example.

Installation

gem 'rspec_method_grouping'

then

require 'rspec'
require 'rspec_method_grouping'

Usage

before

In defining methods, we need long different names. They are not readable.

def registration_page_submit_button
  find('button', text: 'Register Now!')
end

def mail_page_submit_button
  find('button', text: 'Send Now!')
end

describe 'registration' do
  it do
    visit '/resistration'
    
    # input data to some form
    
    registration_page_submit_button.click

    visit '/contact'
    
    # input data to some form
    
    mail_page_submit_button.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 submit_button
   find('button', text: 'Register Now!')
  end
end

class ContactPage < RSpecMethodGrouping::Base
  def submit_button
   find('button', text: 'Send Now!')
  end
end

describe 'registration' do
  it do
    visit '/resistration'
    
    # input data to some form
    
    RegistrationPage.submit_button.click
    
    visit '/contact'
    
    # input data to some form
    
    ContactPage.submit_button.click
  end
end

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published