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
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
Filed under mac nas osx timemachine tips
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
Was tinkering around for the subject in the morning. That’s how I solved it:
Filed under tips resque
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
Filed under ruby tips
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
If you need to show up Order items with some descriptions, pricing, etc. in your custom cart, just add these items into setup_authorization/setup_purchase, like this:
Filed under activemerchant paypal