The Frontier Group - Blog

Using RSpec Example Groups for Common Functionality

January 13th, 2010, by aaron

I’m currently getting into using RSpec for testing our controllers on what is turning into a large project. It’s been more than handy because we have a lot of complex scoping to take into account whenever retrieving data. People don’t like to see other peoples’ financial data, mostly because it implies that someone is probably looking at theirs. With this in mind it’s more than important that we know the right data is going to the right places and hence the need for controller testing.

Now most of our controllers require the user to be logged in so writing tests to check this for every controller is annoying and time consuming, more than that it feels dirty. I think this is what some people call a code smell though I’m not up to speed on buzz words. There are also other tasks that are done quite often such as setting up the various types of users we’d like to test as, it would be nice if this were easily put in one place and could be easily pulled in. I guess I was looking for a template of tests that I could share.

It seems that the solution to it is found in Shared Example Groups which I hadn’t heard very much discussion about and it kind of leaves working out how they work to you rather than documenting it too much.

So far I’ve used it simply to make sure that controllers that require are redirecting users appropriately and also for setting up a specific type of user for our system before testing.

I created a directory under /spec/support called example_groups and in there I have a file called login_groups.rb. In that file I have something like the following :

shared_examples_for "customer is logged in" do
  before(:all) do
    @user = Factory(:customer_user)
    @user.customers.push Factory(:customer)
  end

  before(:each) do
    activate_authlogic
    OperatorSession.create(@operator)
  end
end

Now in my spec files when I have a bunch of tests requiring a logged in customer I will include this little snippet :

  it_should_behave_like "customer is logged in"

I get a logged in customer to start playing around with. I have the spec/support/example_groups directory in my include paths for Rspec and so it just all works.

My tests can then start to look like :

describe MerchantsController do
  it_should_behave_like "areas requiring login"

  context "customer logged in" do
    it_should_behave_like "customer is logged in"

    ... insert other tests here ...
  end
end

It means I can swap in another authentication gem/plugin pretty easily and also encapsulates the logic about creating customers, or whatever type of item you want to use, so that if that changes you can swap things in and out with a minimum of fuss.

Just to be clear, example groups aren’t limited to setup tasks or connecting to before/after hooks, you can also include a bunch of tests as well. This allows me to have a bunch of tests to run to make sure that a user does have to be logged in for various controllers and include these tests in on line.

I hope this helps someone, it took a bit of searching and trial and error myself this morning to get it working and find the uses for it that I’ve found. I’m definitely open to better solutions to this sort of issue though.

We are a web development company and this is our blog. We specialize in building web applications with the Ruby on Rails framework. You can read more about our Ruby on Rails development or contact us.


Making use of professional photography to create amazing websites that stand the test of time

December 3rd, 2009, by fitzy

One of the bigger factors to consider when designing a website is whether or not to incorporate photographs into the design. You have the choice of no photography at all, utilising stock photography, or using a professional to capture photographs specifically for the website.

Certain industries and business niches really thrive with the inclusion of professional photography in a website design. Whether to convey to the customer or shareholder the true nature of the business, or to show professionalism, or perhaps to make something instantly recognisable to the website viewer.

We try to use professional photographs as much as possible where the client will allow it, as it can really bring a website to life.

An oldie but a goodie

This website for Caudo Group has been around for a few years now, but the inclusion of high quality photography (taken by one of our team members), really helps this design stand the test of time. We captured photographs of their brand new office at the time, and some of their equipment.

Supplied photography

These photographs really emphasize the nature of Helix Resources, and the industry they are involved in. These photographs were supplied by their team, but are still of a high enough quality to really bring the website to life. This website is about 18 months old now, but once again retains a fresh feel thanks to some high quality images.

When stock is best

Some websites and industries work better with stock photography. Either the service is disconnected from the place of business, or there might be no images to work with. For a professional feel that still reaches out to particular demographics, stock photography can be used to great effect. In the case of Ironmonger Financial it is used to connect with the website visitor to show them that the content they are reading is relevant to them.

As you can see, using high quality images in a design can really work wonders.

It’s certainly not the rule, however an attractive, professional website goes a long way to showing your customers the care and professionalism that you apply to the business. An integral part of how you represent yourself to clients, customers and the world at large!

A business missing out on this, or having a low quality website is positioning themselves behind the eight ball, giving their competitors an easy ride to market share.

We are a web development company and this is our blog. We specialize in building web applications with the Ruby on Rails framework. You can read more about our Ruby on Rails development or contact us.


Why Your Clients Should Upgrade Their Web Browsers

December 3rd, 2009, by aaron

I think the IT industry has a tendency to push our clients and users to upgrade, or change things to suit our requirements or desires. Often times the reasons may be rooted in practicality, but as good IT workers tend to develop heuristics for problem solving they can sometimes find it hard to explain their reasoning.

A good example is browser upgrades. We all know it’s a worthwhile suggestion, and having the latest browser is the best option in most cases, but explaining that to a user or client can be difficult. It can be especially difficult if you don’t have face time with a user; the most common situation in the web environment.

Telling a user that the site works better in Firefox 3 or Safari 4 will, perhaps, just lead to the user finding a site that works better with their browser instead. It would be nice if we tried a different tact, and in doing so helped not only ourselves, but the wider community of developers. After all we want the same outcome : to have our work viewed the way we intended, for the minimum amount of work. Cross browser development sucks!

I was thinking the other day that I don’t think I’ve ever heard from a developer that users should switch browsers for security reasons, or any other reason the user would care about. Users don’t care about ACID compliance, or Javascript optimisations or any other technicalities. What they do care about though is security, especially now that mainstream operating systems, manufacturers and financal institutions have gotten the word out about phishing and other vulnerabilities.

  • All the latest browsers support some form of malware protection and anti-phishing protection. This increases user security.
  • All the latest browsers concentrate on process isolation and run time optimisations. This decreases crashes and increases browsing speed.
  • All the latest browsers have been improving standards compliance. This increases the likelihood that more sites will work for the user.
  • All the latest browsers manage their own update process. The user isn’t required to remember to stay up to date in the future.
  • All the latest browsers have the latest patches and updates and latest features. This gives the user the most secure, fastest, and feature packed experience.

We all know that unless you have a very good reason, it’s silly to be running an old browser. However when was the last time you explained the benefits for them personally? Increased security, increased stability, increased speed, more compatibility with other sites and the latest features available.

If you find a better way to sell your clients on spending 5 minutes to upgrade their browser then make sure you spread the word. Every user you convert is a win for the web community and the internet in general!

We are a web development company and this is our blog. We specialize in building web applications with the Ruby on Rails framework. You can read more about our Ruby on Rails development or contact us.


How Much Can You Save on Coffee?

October 28th, 2009, by aaron

I just finished making a coffee with our office coffee machine, a Breville ES400 Espresso machine (it does the job!) and it got me thinking about how much of a work horse this little thing has been.

At The Frontier Group, everyone loves coffee. Some people love it more than others, and some people more specifically love the caffeine more than the coffee itself. In any case, everyone at The Frontier Group drinks coffee.

When I started here almost three years ago, we used to go to the local coffee shop a few times a day. It was lucky that they produce some of the best coffee in Perth, and at least at that time, were probably the making the best coffeee in Perth.

However three or four coffees a day can quite easily eat into your weekly budget, not to mention the inconvenience of having to walk up the road to get it.

So we bought a coffee machine. Nothing fancy, but not completely entry level. We figured that it’ll be put through it’s paces, we enjoy our coffee and so we wanted a machine that could cope, and cope it has. After two years of use only the gasket on the group head needs replacing, and that’s really only been noticeable in the last month or so! It’s literally been trouble free.

However, down to the post topic, how much money have we saved? I thought the following sums were pretty interesting.

Coffees Made: 2 years x 48 weeks x 5 days x (approx) 8 coffees/day ~ 3800 coffees
Coffee Used: 3800 coffees * 16g/coffee ~ 62kg of coffee
Milk Used: 3800 coffees * 250mL/coffee ~ 950L of milk
Coffee Cost: 62kg @ $50/kg = $3100
Milk Cost: 950L @ $2.20/L = $2100

So we’ve gone through 62Kg of coffee in the last two years, and 950L of milk. I think that’s pretty crazy!!

Now to the costings.

Equivalent Cost at Cafe: 3800 coffees @ $4.40/coffee ~$16,500
Our Cost for Coffees: $3100 + $2100 = $5,200
Saving:$16,500 – $5,200 = $11,300

The machine itself cost $400, and there’s sugar and that sort of thing I guess, but all in all we’re looking at a solid $10,000 saving over the last two years. That’s not even including the saved time in not having to walk down the road and that sort of thing.

Our little workhorse is a silver box that sits in the corner and saves us money :)

We are a web development company and this is our blog. We specialize in building web applications with the Ruby on Rails framework. You can read more about our Ruby on Rails development or contact us.


Extending the Dojox Datagrid with Formatters

October 22nd, 2009, by aaron

I’m currently trying to create a Dojo widget that extends dojox.grid.DataGrid and has sub grids inside it. It’ll likely expand over time to be somewhat of a complex beast so there wasn’t really any other way than going the self contained widget. Having a bunch of global functions and DOM manipulation would be disgusting.

I’m building this widget in an incremental way so after getting the layout and hooking it up to a data source I moved on to creating a column with an expand/contract link that would trigger the sub grid to expand and contract as required. I ran into a problem when trying to keep my formatting functions contained within the widget definition.

I setup my layout in the following way :

 _mainGridLayout : [
      { type : "dojox.grid._RowSelector" },
      {
        cells : [[
          { name : '', get : this._getBlank, formatter : this._formatExpander },
          { field : "customer_id", name: "Cust ID" },
          { field : "customer_name", name : "Customer" },
          { field : "job_number", name : "Job No." },
            ...
        ]]
      }
    ],

I had defined the get function and formatter function in my widget, but whenever I loaded the widget I’d get a blank column as if neither function had been run.

After some poking and prodding it seemed that whatever context this view was being built in, the ‘this’ object was not my widget as I originally expected. The ‘this’ object was actually an instance of dojox.grid.cell. That was okay as a cell has a reference to it’s grid, so what I needed to do was access this.grid._formatExpander and this.grid._getBlank.

I did it in the following way :

          { name : '', get : function() {return this.grid._getBlank(arguments);}, formatter : function() {return this.grid._formatExpander(arguments);} },

It worked perfectly, I’d like to say just as I expected, but alas I’m not that smart :)

It feels to me like there should be a cleaner way to do it, but at least for the time being it works fine and doesn’t required me to move my formatting functions out into some global namespace and outside of my widget’s nice pieces of logic.

We are a web development company and this is our blog. We specialize in building web applications with the Ruby on Rails framework. You can read more about our Ruby on Rails development or contact us.


Follow Us

Stay in the Loop

  • Enter your email address to subscribe to our mailing list. You'll get updates about our products, specials and bonus offers, and general behind the scenes news from our team.

Twitter

Newsletters

Alexa Rank

Testimonial

The boys at The Frontier Group are amazing! For such a relaxed and personable organisation, they have phenomenal technical ability and a rampant professionalism. They have customisable solutions for all of my IT needs and they always deliver, on time and beyond expectation.

They fix problems other service providers can't and they helped me get a critical section of my web site up and running 10 minutes after I emailed the request!

Alex Hyndman, Nexus Car Share.

Featured Project

Case Study - Caudo Group - www.caudo.com.au

Website

www.caudo.com.au

Caudo Machinery

Caudo Group engaged our services to redesign their outdated website. We sent our photographer on-site to capture the essence of their business and turned it into a stunning web design.