Sign in

Currently concentrating on Ruby!

Recently I came across an interesting problem that involved using the to_f method and the problems it can bring, especially when dealing with monetary values.

My problem involved the inexact arithmetic used in to_f in Ruby, adding three numbers together, and comparing them against a single total number. If the two totals were the same then returning true (which continued the process) or false if they did not match and returning an error. All numbers were manually added in as floats.

The issue:

A total was put in (x). The three numbers to be summed were put in. The three…


This is aimed at anyone recently taking up RSpec testing for Ruby.

I am always looking for ways to refactor my code, a standard rule for programmers. But you can stare at code for so long and sometimes not see what you can change without potentially being exposed to a certain gem in someone else’s project or a commercial setting. Having self-taught myself RSpec I had no real guidance in what to learn, luckily there was one good Udemy course that is fairly basic but covers good practice, the core RSpec methods and the basic fundamentals of RSpec called: Testing…


So in my last blog, I built the basics of creating a database, dropping a database, creating an instance of your class, and saving that instance to the database. Now I want to move on to some more methods. I ended the last blog talking about how the data we get back from a database query is an array so now I want to show you how to build methods such as:

  • Building an instance from the data you receive from the database.
  • Update an instance method
  • Tweak the save method to include the ability to update an instance.
  • Find…


I decided that although I loved Rails and Ruby, you could build a perfectly simple API or Rails application without understanding too much of what is going on in the background. For instance, after doing my Bootcamp, I knew that the Create action from CRUD essentially bundled the new and create actions together. I knew that a method like User.create (if valid) would create a new instance of a user. Could I tell you the SQL that was used, probably not, I just knew that it was running the query for me in the background and could check it out…


During a final stage interview recently, I was asked towards the end of my technical test if I knew FizzBuzz and if I could please implement some code to write a successful FizzBuzz script! The review of my take-home showed that I could write tests, but didn’t show my thinking, logic, and understanding of how to write tests. Now, I didn’t have long left in my test so they were more looking to see how I would tackle this particular exercise.

The concept of FizzBuzz is:

  1. You are given a number (n). This number will be your last number in…


Recently I have been looking more and more into plain old Ruby, no Rails framework, just trying to better understand the language behind it. Having built projects using pure Ruby and Rails, I have come to find I have some questions about what goes where. Which is good. Curiosity makes you want to dig deeper, which means you are intrigued by what you are finding / not finding and want to better understand what you are building.

Recently playing around with some Ruby, I found I was repeating certain methods. Let’s take a trivial example. …


I have taken a bit of a step back on blogs for front-end and React-based projects/skills to also focus on Ruby. After doing a take-home exam a week ago, I realised I was adept enough at making my own RoR project but creating a Regex, plain Ruby setup from nothing… I was not. It felt weird knowing the workings of Rails and yet in a plain Regex file, forgetting to use require ‘path_name’. I think that’s one thing that is good and bad about Ruby. So much of the work is done automatically for you in the background thanks to…


I almost felt guilty not doing camel casing for the title!

Having based my last blog around the basics of setting up a redux project, I wanted to build a simple app with this blog to showcase a full example of Redux, including the use of Redux Thunk. Building simple projects is a great way to learn, writing about them is a great way to test your memory and knowledge and feedback is a great way to see errors / learn some more!

I decided to build this Counter app because writing my blog last week made me realize my…


This is a slight diversion on what my next blog was meant to be about. Context API and testing it with Jest + Enzyme. Why? Because I have done some more reading around Redux and wanted to aim something potentially at Bootcamp students who were getting into their final projects, or having some trouble managing their state and props in a project.

This is something that I definitely struggled with in my final project and since wish, I had the confidence to have implemented Redux. My project involved a lot of components with plenty of different level components. This meant…


My last blog was all about context API and how to set it up plus some benefits to it, as well as a couple of good links to comparisons between Context and Redux.

Now in this blog, I want to talk about setting up Enzyme, the use of it and a couple of tests. THEN I will do a blog on testing Context API in React.

Now Jest is a Javascript testing framework that was created by the developers of React. But, Jest is not actually limited to React, however, Enzyme is specifically designed to test React components.

To setup…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store