Home > ruby > IRB Recipes

IRB Recipes

Yesterday we had an interesting Selenium Ruby session with Exist QA group. We were divided into 2 groups and my team was tasked to create IRB recipes for the following scenarios:

  • enable auto-indenting
  • enable auto-complete
  • add a clear screen method (clear or cls)

Auto indenting

- enables user to write clean and properly indented codes.

IRB auto-indent configuration

IRB auto-indent configuration

1. From your console fire up your IRB

2. Notice that if you type ‘conf’ and check for the default value of

conf.auto_indent_mode = false

3. To override this, type

conf.auto_indent_mode = true (see line 2)

Auto complete

- enables user to check the available methods within an object by clicking DOUBLE TAB

IRB auto-complete configuration

IRB auto-complete configuration

1. From your console fire up your IRB

2. Type below command inside your IRB

require ‘irb/completion’

Clear Screen

- enables user clear the screen inside the IRB

IRB clear screen method

IRB clear screen method

1. From your console fire up your IRB

2. Define a method to clear the system (see line 2-4)

3. Now you can call the method ‘cls’ inside IRB that will clear your screen

About these ads
Categories: ruby Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: