Den Markin's stream

making ideas work

3 notes &

factory_girl/step_definitions vs. pickle

Given: 

    And the following promo codes exists:

      | Code  | Expire At  | Percentage Off |

      | 10OFF | 2011-10-10 | 10             |

      | 50OFF | 2012-10-10 | 50             |

When Cucumber’s env.rb contains:

require ‘factory_girl/step_definitions’

it conflicts with pickle which has the same step definition. One solution is to use —guess when running your test, but this is ugly.

Instead, get rid of these factory_girl’s step definitions and go with pickle. One small caveat:

    And the following promo codes exists:

      | code  | expire_at  | percentage_off |

      | 10OFF | 2011-10-10 | 10             |

      | 50OFF | 2012-10-10 | 50             |

Note the columns naming (pickle doesn’t recognize them so smart as factory_girl does).

Filed under testing pickle cucumber factory_girl

9 notes &

Compare Cucumber-expected table with HTML table

Idea was shown by @rbates in http://railscasts.com/episodes/186-pickle-with-cucumber.

Capybara is here to replace Webrat, table_at method is not longer available out of the box.

I published a gist which works fine for me at the moment:

As you can see, I additionally strip out meta characters such as “\n” and include TH cells within the table (I use them often).

Filed under cucumber tips testing capybara

23 notes &

OSX Lion + NAS as TimeMachine storage

I use WD MyBook World 1,5Tb as my home media storage and for TimeMachine.

After update to Lion a couple of days ago (someone might say I’m late, but I did this too early considering known-not-fixed-yet issues) I had a problem with TimeMachine.

http://wdc.custhelp.com/app/answers/detail/a_id/7081/related/1/session/L2F2LzEvdGltZS8xMzE5MTIxMzczL3NpZC9xR29VTzFIaw%3D%3D, http://wdc.custhelp.com/app/answers/detail/a_id/8422 explains the problem fully.

I was happy to upgrade (even more, they made Twonky server more stable and I don’t need to “rm -f” it’s init.d script anymore. At least for now :).

Once upgraded, I got:

I found the following article: http://www.cultofgary.com/2009/01/08/time-machine-netatalk-and-error-code-6602/

So, I connected via SSH, did “rm -f /DataVolume/.timemachine/.AppleDB”, then “/etc/init.d/S91atalk restart”.

After such “cleanup” I was able to do backups from Lion.

Hope that could be pof help.

Filed under mac nas osx timemachine tips

0 notes &

Simple yet usable shared errors rendering approach

If you have a form in Rails you draw validation error messages anywhere inside it. Most common approach looks like:

      = form_for @somwthing do |f|

        = render “shared/error_messages”, :target => @something

But what if you have nested or custom objects rather than your :target? In some cases nested errors would be drawn (depends on specifics of implementation). But sometimes you just want to do

@something.errors[:base] « “Custom error message” inside your controller

OR simply

errors[:base] « “Custom error message” in your model

One way - unify look of the error_messages partial and render it for each specific target like: 

        = render “shared/error_messages”, :target => @something

        = render “shared/error_messages”, :target => @something.else

        = render “shared/error_messages”, :target => @whatever

Ugly.

Solution I found:

Of course could be cleaned up in some ways, but it serves my needs well.

Filed under rails tips

1 note &

Missing SASS mixins when generating on production

Quick note:

ALWAYS include mixins used in particular sass file right into it, not in the main application.sass, like this:

@import ‘mixins/clearfix’

@import ‘forms’

When compiling for production environment, sass parser will complain about missing mixin ‘clearfix’ if it used in forms. Just do 

@import ‘mixins/clearfix’

right inside the forms.sass. The reason - different order of parsing for different environments.

Filed under sass

0 notes &

WD World Edition NAS + Time Machine = “Making backup disk available”

I believe it worth sharing.

Had a problem last week - cannot continue backing up to Western Digital World Edition NAS 1,5Tb. TIme Machine simply says “Making backup disk available”, then silently stops doing anything.

TimeMachine Buddy widget showed error “-43”, so I spent a few hrs on wdc.com and apple.com discussions and finally found working solution:

It is caused by a broken database for the timemachine share,

SSH into the box and issue the command: rm -rf /DataVolume/.timemachine/.AppleDB

This will clear the database and a new one will be created once you setup the network share again from your mac.

This way you won’t have to re-format your whole drive and no files will be deleted other than the backup.

Source

Then I repaired verified/repaired sparsebundles, as described here.

Now it simply works again.

Filed under mac tips osx timemachine nas