Checking form submissions with Cucumber-Nagios

Posted in Inside TFG

We use Cucumber-Nagios at The Frontier Group to monitor live web applications and web sites. It’s the natural extension to the integration testing we conduct on our applicaitons as we develop them, and it gives us a deeper insight into an applications real-time availability and responsiveness… or so I thought.

Due to an oversight on my part, the Cucumber feature that we use to search this blog was failing “in real life” but passing according to Cucumber-Nagios. I was searching for a text string that should have appeared only after conducting a successful search of the articles, however it was also appearing in the list of popular articles on the sidebar. Whoops!

After the test started failing for real, because the blog post was no longer referenced in the sidebar, I dug deeper in an attempt to find the problem.

In the end Aaron did most of the hard work, and tracked the problem down to webrat not submitting the form properly. As such the response data that was being parsed was incorrect.

Here’s the feature file:

Can’t see this Gist? View it on Github!

The trick that we used (and it is a nasty hack, to be sure) is to fool webrat into operating in “Rails mode”, whereby it POSTs the form properly. I added the last four lines to features/support/env.rb and it’s done the trick.

Can’t see this Gist? View it on Github!

So if you’re having a problem with webrat posting data, maybe this will help you. Alternatively, if you have a suggestion on how this could be fixed in a cleaner way, please leave a comment.

Simple Database Export and Import With Character Encoding Conversion

Posted in Code, Ruby on Rails

There is a gem called ydd that offers really simple import and export of smallish databases. It exports to YAML and then imports to whatever database Rails can connect to. After using YDD a few times I’ve found it easier to pinpoint the cause of problems that occur using taps.

It doesn’t handle character encodings though so I went about adding that. With the handy rchardet gem and IConv, detecting the character encoding of the incoming string and converting it to UTF-8 was pretty simple. I’ve created a pull request for the gem that will hopefully be accepted.

The essential code is below, and revolves mainly around the detection and conversion. Using //TRANSLIT causes IConv to try and convert the incoming character code to something that exists in the UTF8 character set, and then //IGNORE will ignore any characters that don’t exist in the UTF8 character set. Chaining //TRANSLIT and then //IGNORE will make IConv try a conversion first and then ignore anything it cannot convert.

I used this gem after the above changes to convert about 400,000 records of text data with ASCII, windows-1252, IBM866 and other character encodings from an old SQLite installation to a new postgres database without any issues.

RSpec 2.6.0 and RCov

Posted in Code, Ruby on Rails, Tips and Tricks

Just upgraded to the newest RSpec (2.6.0) and found that RCov has stopped working completely? That’s what happened to me after running a bundle update. RCov refused to run, no error messages, just blank output.

After looking around for a little while I found this: https://github.com/rspec/rspec-core/issues/370

In short: the new RSpec has been broken up into modules a tad more, the one that we require for rspec to run correctly ‘autorun’ is not included by default, so to solve this simply add require ‘rspec/autorun’ to the top of your spec_helper.

Can’t see this Gist? View it on Github!

Training To Win

Posted in Inside TFG

Every organisation has to continuously solve a set of legal, financial, technical and social problems in order to survive. Small businesses have limited resources and prioritise problem solving in their main fields of endeavour. For example, software development companies like The Frontier Group constantly buy programming books, refine development practices, research new technologies and send their employees to technical training and conferences to expand their skill sets.

However, quite frequently it’s the social problems that businesses face that can make or break them. Many employees lack the skills to communicate, to work effectively in teams and to manage others. Fresh graduates may not know how to work at all. The failure to address and solve these social problems results in reduced operational efficiency, inadequate management and poor employee morale.

The stereotypical programmer is an introvert with plenty of technical skills, but few social skills. How often do you hear about software development companies conducting training in non-technical fields such as leadership, team management, project management, dispute resolution and sales? It’s rare. When it comes to employee skill sets, most companies, especially small ones, focus on improving strengths instead of addressing weaknesses.

The Frontier Group recognises that its employees can’t cut code all the time, no matter how much we love doing it. Our team leaders and project managers require excellent skills to ensure every project hits its targets. We’ve partnered with local company Alive and Kicking for management and sales training for our staff, and look forward to learning from them.

Improvements in management skills are difficult to quantify, and spending cash on training when budgets are tight is difficult to justify. As always, the adage “you have to spend money to make money” applies. Small businesses can only grow as fast as their employees will let them, and The Frontier Group is grooming its employees for success.

Catch mail and serve it through a dream with MailCatcher

Posted in Ruby on Rails, Websites or Tools

Here at The Frontier Group we were having trouble finding a simple, extensible way to look at email sent out by our web applications during development. After trying quite a few alternatives, one of our developers Sam Cochran sat down in some spare time and forced slender man into skinny jeans strapped to a mailbox to create MailCatcher.

MailCatcher is a ruby mashup to catch mail sent via SMTP to a local port and serve it in your web browser for easy testing. It lets you check out the plain text and HTML versions of the email, as well as inspecting any attachments. Thanks to WebSockets (in Google Chrome, at least) you’ll see new mail instantly as it arrives.

MailCatcher v0.3.0 displaying a message

Installation and usage instructions can be found on the project home page. Over the coming weeks I look forward to sharing some more of our open source contributions from within TFG.

Twitter

Great web stats at @petrescue , the driving force behind the rebuild of their systems by @frontiergroup . http://t.co/MTvfoxnU

@frontiergroup about 2 weeks ago #

Search Posts

Featured Posts

Categories

Archives

View more archives