Question

I am required to automate software tests for my job and I currently use groovy to do this. However, I am thinking about adding Ruby to my repertoire. Mainly because I can see myself working on a rails project in the future.

How long do you think it would take to become relatively proficient at scripting with Ruby? I am talking mainly navigating around a DOM with webdriver/webrat and programatically doing text/file changing work.

Was it helpful?

Solution

One weekend of intense dedication.

Seriously, it's a matter of how much time you have got on your hands and what's your previous experience. If you've dabbled in Perl or Python, you'll probably have an easier time picking up Ruby than if you had just used Java before.

OTHER TIPS

Depends on how much experience you have with other programming languages. You should be able to learn the basic ruby syntax in an afternoon. And then work on learning the testing libraries might take another couple of days of playing around with them. You certainly wont be a ruby expert but you should be able to hack together some test scripts pretty quickly.

You could start here - Ruby in Twenty Minutes

Then maybe go here - 17 Videos Covering Basic Ruby Techiques

If you have programming experience I would say 2 weeks of intense focus on ruby will get you 99% of way....the major features of ruby that distinguish it from other scripting languages are its intrinsic use of iterators (you almost never code for or while loops) and associated code blocks. Once you become familar with these the rest of it falls into place.

A minute to learn ... a lifetime to master.

With no previous technical experience I started learning ruby, html, css etc at the same time and it took me 2 years before I could get something up and know what was actually going on. Rails of course makes all of this faster and if you already know other programming languages you could tackle the basics and be functional in 6 months.

Ruby has Nokogiri, which is an excellent HTML/XML parser. It supports both CSS and XPath accessors, making it very easy to navigate through a parsed HTML file's DOM.

Building on top of Nokogiri is Mechanize, which was based on Perl's WWW::Mechanize. It makes it easy to navigate through a website's pages, extracting fields, filling out forms and submitting them, tracking cookies and sessions, etc. Because Mechanize is built on top of Nokogiri, you can get at the underlying DOM and use the same CSS and XPath accessors.

Ruby has several different testing environments. Test::Unit comes with Ruby and is easy to use. There's also Autotest, RSpec, Shoulda and Cucumber to name a couple others. Autotest is nice because it will watch your directory and run tests as you modify the files, so you're instantly aware if you break something.

I came to Ruby from a Perl and Java background, with C/C++ before those. To me, Ruby is like a child of Java and Perl because it has some similarities to both, but at the same time the things that were annoying with both those languages are nicely sidestepped on Ruby. It's almost as if Ruby was the logical growth, or next generation, of the other two. I think that's partly the benefit of hindsight, and of Matz' intention to make Ruby be a language for programmers, not machines.

I tried learning Rails in parallel with Ruby, but caught Rails as it changed from v1 to v2. All the books were out of date and wrong, most websites were wrong, and finding good information was tough. Eventually I realized the confusion was in the documentation and backed away from Rails for six months and concentrated on Ruby, using it daily at work. I began using it almost exclusively because I was able to more succinctly express ideas in it than I could in Perl. I could write more tersely in Perl, but it wasn't as readable, which is important to me because that helps make code maintainable.

Now, a few years later, I prefer Ruby over any language I've ever used. I still program in Perl but evangelize Ruby at work, and use it any time I need to write something that touches a database, because of Sequel, or to write web front ends to the databases using Rails, Sinatra or Padrino, combined with HAML.

Depends, are you using any other scripting languages? Ruby is pretty straight-forward to some people. I found it easy to remember most of the common method names. If you've worked with other languages to any decent extent then it shouldn't be more than a week to be deeply enjoying the language. If it's your first time programming, you need to get a good solid grip on Object Oriented Programming to truly appreciate it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top