June 18, 2018

Intro to setting up a BDD framework with VS Code + Gauge + Ruby

With Integrated Development Environments (IDE), I am quick to adopt whatever the rest of the developers on the team use. For Java development, I like IntelliJ IDEA Ultimate Edition. For JavaScript, Atom.io. And for writing the Capybara + Ruby framework, I have also been using Atom. The problem is that the BDD framework we are using at work -- Gauge -- has plugins that help refactor Gauge tests written in Java, but hasn't had anything for refactoring Gauge tests written in Ruby... until now.

With this blog article, I will be investigating Visual Studio Code -- commonly known as VS Code -- and how it helps refactor tests.

Why am I currently using Ruby for my automation framework if the BDD Framework hasn't supported it? Both Chef.io -- what I use to spin up virtual environments -- and GitLab.com -- the code storage / continuous integration environment also uses Ruby.

I've written a bit about Gauge and drafted a quick-and-dirty Gauge + Ruby + Selenium project, on this blog. With this experiment, we will be editing Gauge's built in project, setting up everything on my Windows 10 machine at home.

If you want to view a summary what the gauge-vscode can do, view the official docs on GitHub.



Setting Up VS Code + Ruby + Gauge

Setting up Ruby:

  • To set up the Ruby programming language on a Windows environment, follow the directions on RubyInstaller.org.
  • Note, there are many ways of installing Ruby. Here are a few examples.
  • Make sure to install the bundler gem from Bundle.iogem install bundler

Using Windows? Install Chocolatey:

  • Open the Command Prompt as Administrator
  • Follow instructions for  Install Chocolatey.org, the Windows Package Manager, copying the command text, and pasting it in the Windows command shell. 
  • Close and reopen your command prompt, running, again, as an administrator. 
Install Gauge:
  • Follow the prompts for installing Gauge at https://gauge.org/get-started.html
  • Once you have Chocolatey installed, it is: choco install gauge
  • Is gauge working? Type: gauge -v
Create New Gauge-Ruby project:
  • Create the subfolder where you want to keep the project. For this project, I went to C:\Users\tmaher\ and created a new folder, gauge-ruby. Enter the subfolder.
  • Initialize a new Gauge-Ruby project: gauge init ruby. 
  • After all project dependencies are downloaded and installed from Rubygems.org, make sure you can run the test project: bundle exec gauge run specs/
  • Want to see exactly what is happening? Run the project in verbose mode with -v: bundle exec gauge run specs/ -v
  • Are updates available?: gauge-update ruby
As you can see below, the sample project tallies up vowels "aeiou" (leaving out 'y'), in words such as "Gauge", "Mingle", "Snap", etc.

Output of the Gauge Sample Project.
... If you want to see what the code is doing, and don't feel like setting up a project, you can check out the code produced in the Gauge 0.9.7 project on my GitHub site



Setting up VS Code:

  • Downloads for Windows, Mac, or Linux is on the Code.VisualStudio.com Downloads page. 
  • VS Code wanted me to immediately wanted me to Download Git. I had uninstalled it since I wanted to upgrade to the new version. It provided a handy link to download, and I could set up VS Code as an editor. 
Install the Ruby plugin:
  • The Welcome page displayed a Customize widget that I was able to click in order to see the Exentions: Marketplace. I was able to scroll down to "Ruby" and click to install it. This is from Rubyide's vscode-ruby project. Like Atom.io, VS Code seems fast, lightweight, and able to be customized with various plugins. 
Welcome to VS Code!
Install the VS Code Gauge Plugin:

  • See the square thingy on the bottom? Hover your cursor over it, and it should tell you that it is Extensions. Select that, and search for the keyword "gauge". Select to install it. 


VS Code Welcome Screen

Now that we have everything set up, let's give everything a whirl!


  • Open up VS Code
  • Select File -> Open Folder, and open up your project. Mine was in C:\Users\tmaher\gauge-ruby
What a nice touch, ThoughtWorks! To help get us started, we are presented with a new dashboard. 

The Gauge Dashboard
  • Apply & Reload recommended changes. Add a workspace folder by going to File -> Add Folder to Workspace
  • Open the Command Palette: In VS Code, select View -> Command Palette, type in "Gauge" then select Gauge: Welcome, to go back to the Welcome screen.   
On the Welcome Screen, it provides:
  • Ways to learn the Gauge toolset by providing links to help you learn the Gauge terminologies, and how Gauge uses Markdown.
  • "Run All Specifications" runs the tests from inside VS Code. 
  • How to Report an Issue, Ask a Qustion, Chat, or go the the Google Group forum. 

Running Gauge Tests in VS Code

  • From UI: Opening the Command Palette, typing in "Gauge" and selecting "Gauge: Run All Specifications". You may need to raise the output panel to see the results. By default it only showed one or two lines of output. 
  • From Terminal: On the panel at the bottom, listing Problems, Output, Debug Console, and Terminal, select the Terminal tab. This will show either the Windows PowerShell or the Mac Terminal. Enter: bundle exec gauge run specs/

View Reports
  • Want to see reports? Select where it says "Successfully generated html-report", and it will output the location to the command line. Go there, press the Enter key, and the reports will be entered into your browser. 

I highly advise you to get used to executing things through the Terminal in VS Code, especially if you are used to Windows environments, like I am. The main thing that had been holding me back in my automation development career had been my fear of using the command line. It's easier. It's quicker. And it will get you working in the same way the software developers on your team are working. 

Finding Previously Defined Steps

Let's say you defined a step:

step_implementations/step_implementations.rb 
 step 'Vowels in English language are <vowels>.' do |vowels|  
  @vowels = vowels.scan(/./)  
 end  

This readable step, full of detail, can be hard to remember, when trying to implement it in a spec file.

If we open up the spec file, specs/example.specs, from the very moment we type a bullet point to add a new step, a popup is displayed showing all the previously designed steps. Enter a few more words, such as "language" and it will filter down to the step "Vowels in English language are..." 

Previously defined specs are shown



Rephrase Test Steps

Gauge uses Markdown as a theme to write tests. Each specification has a heading. Each scenario has a subheading. And each step is captured as a bullet point, which corresponds to a step implementation. 

When a test is executing, the spec takes the language of the step and attempts to match it to a phrase in the step implementation. What happens if you want to make changes to the wording? If you do not find all areas in the specs that match the step definition, things will start failing. 

What if we wanted to rephrase the step definition "The word <word> has <count> vowels." to read as: "There are <count> vowels in the word <word>"?

We could easily do it through the command line! Just like on the command line, we could go to the Terminal and type in:

gauge refactor "The word <word> has <count> vowels." "There are <count> vowels in the word <word>"



... This is a really nice start on a much needed plugin. I hope they come up with one for IntelliJ IDEA + Ruby and RubyMine!


Happy Testing!

-T.J. Maher
Sr. QA Engineer, Software Engineer in Test
Meetup Organizer, Ministry of Testing - Boston

Twitter | YouTube | LinkedIn | Articles

250 comments:

«Oldest   ‹Older   201 – 250 of 250
James K. said...

Canon offers a type of printer including PIXMA, SELPHY, MAXIFY, etc. canon.com/ijsetup has some factors need to be in mind while choosing an inkjet printer for you. Later, you can easily set up your Canon printer through drivers from ij.start.cannon wireless connection, USB, and a few components. The setup process for every Canon model is almost similar, however the download through https //ij.start.cannon or http //ij.start.cannon and installation process may differ.

wireless n wifi repeater, said...

Connect to the wireless n wifi repeater have wifi system, then press the “Add Router” button, then follow the on-screen instructions until the green flash cue appears.

Nick said...

If you need help on how to fix tri five wifi extender So no need to worry, know our article on our website.

olivia said...

If you want to Login to dlink router, use the default gateway dlinkrouter.local for this. The Dlink router login web interface is a place where you can change the settings for your Dlink router. You will need to access the panel if you want to perform functions like changing your existing username and password. In addition to that, there are many other settings that you can navigate and alter as per your choice. Get more help on this by getting in touch with our experts if you have any issues.

olivia said...

Before starting the
Linksys RE6300 setup process, ensure you are connected to the correct network. Place the extender within the router's range and ensure that your login credentials are case-sensitive. Before you begin the configuration process, the light should turn orange. If you have any questions about the installation process, don't hesitate to contact us at the end.

Nick said...

If you need help on how to fix prescitech wifi extender setup So no need to worry, know our article on our website.

alone said...

mtgumc

traviswills said...

Connecting the Cricut machine to a PC is enough, but setting up the machine on a mobile device makes it portable and easy to craft. If you want a direct and easy way to craft through your Android or iOS phone, then go through the to Cricut.com/setup |Cricut com setup windows | cricut.com setup connect to Cricut.

Nick said...

Thanks for sharing the most important information. we provide technical support. If you need any issues regarding arlo pro 3 camera visit our website. Our technician 24 hours available.

Nick said...

Thanks for sharing the most important information. we provide technical support. If you need any issues regarding find.synology.nas visit our website. Our technician 24 hours available.

Cyberz Pc said...

like to retrieve it,looking ahead to more subsidiary update and that i Already read your current post its brilliant thanks. Free Quick Heal Product Key

olivia said...

To initiate the Netgear Router login, type your default gateway Routerlogin.net in the address bar of any browser compatible and then press enter. You may also sign in with an IP address. After logging in, users can set the router's wireless settings and alter them as needed. Contact us if you encounter issues with registration or setup procedure.

olivia said...

If you wish to access the administration page for Tp-Link routers, you can perform the tplinklogin process. Open any compatible browser, type in one of the gateways in the address bar and press enter. The login screen will appear, type in the default credentials and click login. The user will then be taken to the management website for the router. We have experts on call if you'd like to learn more about the procedure for logging into the router.
tplinklogin.net

oncasino said...

oncasino

edimaxext.setup said...

Thanks so much, for sharing the important information. we provide technical support. If you need any issues regarding edimaxext.setup visit our website. Our technician 24 hours available.

tplinkrepeater.net password said...

If you need help regarding how to fix tplinkrepeater.net password issue ? Then no need to worry, learn our article on our website.

Anonymous said...


Thanks so much for sharing this nice site.
tplinkrepeater password reset

Anonymous said...

Our team will provide you with a high-end solution for complex and irritating setup problems in
find my synology setup.

duoboost said...

Don't know how to set up a duoboost repeater ? We are here to help you. Just go through the website and complete your duoboost repeater login setup.

asus router setup said...

If you are searching for the asus router setup in an easy way ,then you can use the asus router app for the setup. The ASUS Router App scans automatically for nearby ASUS routers.So, you’ll enjoy fast, secure Wi-Fi without worrying about complex setup!

dlinkap said...

D-LINK N300 DAP-1330 comes with a smart signal indicator. Use it to find the best location to set it up. the Gigabit port will let you connect a wired device to it.You can easily set up your extender using the WPS button.

Anonymous said...

The Asus Lyra ac2200 tri-band whole-home wifi mesh system is simple looking and also easy to use.If you are looking for how to fix the issues of Asus Lyra ac2200 router During Setup, then no need to worry; go to our website or contact us. Our experts are experienced and can help to resolve your problems. We are available 24*7 hours for you.

Anonymous said...

Don't know how to set up a tplinkrepeater ? We are here to help you. Just go through the website and complete your tplinkrepeater login setup. We are available 24*7 hours for you.

Nick said...

If you are facing technical issues while accessing tecknet doorbell not working web address, then feel free to contact us.

Nick said...

If you are facing technical issues while accessing infant optics out of signal coverage web address, then feel free to contact us.

Anonymous said...

ij.start.canon is the manufacturer's site to download Canon printer drivers. You can easily download the driver according to your model as ij.start.canon is designed with a user-friendly interface . Cricut Design Space app is your gateway to getting familiar with various design templates you can pick for your upcoming craft projects.

pranaytc said...

Itechmanthra is a digital marketing firm that takes a creative approach to its work. Each business must take its own method to succeed in today's digital world. With the support of a global team of professionals, we design tailored digital solutions for each of our clients in order to assist them in achieving their business goals. It also provides SEO Services

ascrack.org said...

Amazing blog! I really like the way you explained such information about this post to us. And the blog is really helpful for us on this website.

Anonymous said...

If you want any information related to the setup of wifi blast repeater setup , then you can go to our website and setup and solve your problem.

Anonymous said...

If you are facing technical issues while accessing arlo pro 3 setup web address, then feel free to contact us.

Anonymous said...

Our team will provide you with a high-end solution to complex and annoying setup problems with victony wifi extender setup Full details related to setup and can solve your problem.

Extender Linksys said...

You can execute the Arris Router Login process with the help of the default IP address. After opening any compatible browser, fill in the default gateway in the browser's address bar and press enter. When the login window pops up, you will be prompted to key in the default login credentials and hit the Login button. If you have any doubts or confusion anywhere, chat with our experts at the end.
Arris Login

Extender Linksys said...

To begin with, the Netgear Orbi Login process, use the default gateway orbilogin.net. You can also take the help of the default IP address. You must use a compatible browser only and check if the devices are receiving a sufficient power supply. Got any doubts or confusion? Have a chat with our tech support team now.

Emma Adkins said...

Hello friends I am Emma Adkins and I have created a website where you can translate the Morsecode language into English language, you need to just click on translate morse code .

Anonymous said...

Our team will provide you with a high-end solution for complex and irritating setup problems in Bagotte BG800 Vacuum Cleaner setup

Anonymous said...

nextbox repeater

Anonymous said...

kodak esp c315 wireless printer setup

Pantum P2502W’s wifi system said...

If you want to setup the Pantum P2502W’s wifi system you will need to follow a few steps.

nexar dash cam said...

Thanks for great posting.

nexar dash cam troubleshooting

Anonymous said...

Here you get an easy guide of soft TCLsound bar .

Anonymous said...

Here are some asus zenwifi xt8 login steps, you can follow & hassle-free log in to this router.

Anonymous said...


If you want to eliminate the weak signal of the current wireless wi-fi router then you can install this powerline adapter.
dlinkrouter.local

192.168.10.1 wifi repeater login said...

In case you are having trouble locating the document or label containing the default log-in details of the router, search for the model and serial number on the router.
192.168.10.1 wifi repeater login

NEXTBOX wifi extender setup said...

NEXTBOX wifi extender setup can be easily done by by using the WPS button or by using a web browser.

pix-link wifi repeater said...

To access the extender login page, just type in the web browser URL pix-link wifi repeater ip address , if you are facing trouble , visite us.

Anonymous said...

Visite and learn about how to reset bestisan soundbar .

Anonymous said...

Great blog post.

how to reset throttle position sensor ford focus

Anonymous said...

pantum printer wireless setup

Anonymous said...

tplinkrepeater.net login password

Downloadpc.co said...

Very good article! We will be linking to this particularly great post on our website. Keep up the good writing.downloadpc.co
Auslogics BoostSpeed Crack
Wondershare Uniconverter Crack
CleanMyMac X Crack
CyberLink PowerDirector Crack

«Oldest ‹Older   201 – 250 of 250   Newer› Newest»