rails testing decisions

October 2, 2009

There are a lot of options out there for Rails testing. Options are great, but they lead to pesky decisions.

Options:

Discussions:

So, have I made my decision yet? Nope, I feel like I can’t till I’ve given them a try and see how they fit into my process. I’m going to start off taking Shoulda for a spin.

tidbits on text

October 1, 2009

Apparently the theme of the last two days has been how to manipulate text more efficiently, here are some solutions to problems I have run into recently.

  • Rails default labels are all proper case, the design standards for a current project I was working on called for them to be all lower case, instead of customize all the labels, i set the text-transform css property to lowercase.
      label
        :text-transform lowercase
    
  • I have been converting a large Photoshop file with many layers on content to HTML and found it annoying (especially cuz I didn’t have the font) to click on each layer to copy and paste the text. Set out looking for a way to convert the psd to a text file and found this: PSD2TXT, works like a charm.

I started the switch over to haml / sass on some of our projects this week and I’m still getting my feet wet, but here are few resources that have helped the transition.

  • I was confused at first on how the css file was created, but no worries, rails handles it automatically.
  • article – SASS: The Better, More Powerful CSS
  • the nifty_generator gem includes nifty_layout that has an option to create all layout and views in haml / sass.
  • Texmate bundles – haml & sass
  • Indenting is very important in both haml and sass so make sure to switch indenting to soft tabs – 2
  • #haml.docs and sass docs – links to full documenation, faq, and more

This week I have been spending a lot of time on a Rails project where I have been focusing on account set up and custom subdomains. Since this is the first large project I have had a back-end focus I have been learning a lot. Here is some of the stuff I picked up this week.

songs in code

August 20, 2009

most of the time I try and avoid silly twitter trends, but #songsincode … I mean, sometimes I write love letters to my fiance in code, so how was i to resist.

Here are some of my favorites so far:

Chronotron: function destroy(my_sweater:Sweater):void{this.thread.pull(); walkAway();}

kevinjohngomez: <code> .rain { color: #6600cc }</code>

bullines: (you.CanTouchThis()) ? false : false;

mattcasto: public void SongThatNeverEnds() { SongThatNeverEnds; } 

admast: if($tickets_to_paradise == "2"){ $packyourbags=true; $leave='tonight' } 

liquidgecka: for (i = 0; i &lt; 30; i++) { print RandomHistoricalReference() } !StartFire(); 

myotive: jennys_no = string.Format(&quot;{0:###-####}&quot;, &quot;8675309&quot;);

BrianPeek: while(true) { getKnockedDown(); getUpAgain(); }

tpflomm: if (you == likedIt) {you.shouldaPutARingOnIt();}

@chockenberry .rain { color: #6600cc }

Select Count(*) as Problems, Sum(CASE WHEN Problem = 'Bitch' THEN 1 ELSE 0 END) as Bitches From tblProblemsIGot

function timberlake() { return $sexy; } 

while (miles &lt; 500) do {walk (miles++)}else miles=0while (miles &lt; 500) do{walk (miles++}else if (door) then fall(down

DateTime end = DateTime.Now.AddHours(24); while(DateTime.Now &lt; end) this.Sedate();

typodactyl: for miles in range(0,1000): if miles == 500: walk()

I’m pissed off at Poll Daddy right now. Earlier today I had a very simple task to complete: go to polldaddy.com, create a new poll, replace the old poll on one of my client sites with the new poll. Simple enough, right? I log in and create the poll, when i get down to pick the ’skin’ I realize that they are updated and the old boring design is no longer an option, although the new ones are pretty (we all love gradients), my client is looking for consistency. Luckily off to the side I see a new Custom CSS feature, good, I think, I’ll just write up some CSS and take care of this issue. I spend the next few minutes attempting to click on this radio button, like someone who has never used a computer. Disabled? Not an option under my free account? Who knows? It’s just not working.

I decide to turn to my good friend the internet to see what the deal is. I find an article about the feature updates from last week, New poll style editor – Start creating beautiful styles with ease!, but no real clues as to what the issue is. I even had to swallow my pride and send a feedback email regarding the issue. Still no answer.

So what’s the lesson? Feature updates are great, but be sure to remember the importance of a smooth transition and backwards compatibility. Always keep in mind what the core goal of your users are, if they are unable to complete their core goal using your tool, no matter how sexy the features may be, they will get pissed.

Now, this isn’t to say that their will never be unforeseen glitches in a roll out. I recall about a month ago 37signals had some complicated issues with an enhancement and had to roll back, this post: What we’re doing to address File Upload problems in Basecamp, is a great example of how to deal with these situations.

I needed to a quick way to limit the quantity of items a user could purchase at a time in a shopify store. I didn’t want to make too many changes, cuz we weren’t sure if this was an edit they were to want to keep. So, using liquid I wrote the following code :


{% assign name = quantity_with_limit %}
{% if item.quantity > 2 %}
alert('Note - You may only purchase two of each item per order.');
{% assign quantity_with_limit = 2 %}
{% else %}
{% assign quantity_with_limit = item.quantity %}
{% endif %}

< input type="text" style="text-align:right" size="4" name="updates[{{item.variant.id}}]" id="updates_{{item.variant.id}}" value="{{quantity_with_limit}}" onfocus="this.select();"/>

Sprites you’re aiight

August 4, 2009

So today was the first time I have used sprites in my front end development. It’s not that I just heard of them I just haven’t had the need, as most of my buildouts have lean use of graphics. This design on the otherhand was an optimization of an exsisting design on probably the slowest server known to man. So anyways, I thought I would give this method a try and it was super easy. I used this tutorial to guide me, and it kept it simple. http://www.ehousestudio.com/blog/2008/06/27/css-sprite-navigation-tutorial/

I have been working on front-end stuff on Rails apps for a few years now, but before today I had never created anything from scratch.
I followed this tutorial on Six Revisions and it was awesome.

A few small things confused me

  • I used postgresql instead of mysql and didn’t know that I had to create the login roles in the pgadmin before running db:create
  • Routing confused me, still does, but here is some additional information – Routing the Rails Way

Next up creating one of those many apps sitting in my head…