If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it. To get the grand-parent element, call find(:xpath, '../..'). Example

...href]).to eq("http://twitter.com/") About XPath There is a good overview on XPath syntax on w3schools. But as XPath expressions can get quite complex and hard to understand for...

...center an icon (or any "blockish" inline element, really) with the capital letters of surrounding text. This works well with our modern approach to SVG icons, or e.g. for custom...

...list icons. Note that it won't work with "text" icons that scale with font-size. Technical background All text has a "baseline". It is the bottom edge of most...

To work with other type of nodes (like text, comment or CDATA sections) you need to: Retrieve child nodes contents() (which behaves like children() except that it returns...

...element and returns an array of all child nodes that are text nodes: function selectTextNodes($container) { return $container.contents().filter(function() { return this.nodeType === 3; }); } Also check out this list of existing...

Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of three things can happen: The browser shows a "Save as...

...dialog. Since it is a modal dialog, we can no longer communicate with the browser through Selenium. The browser automatically downloads the file without prompting the user. For the test...

...much faster than the configured up.form.config.observeDelay. Therefore, it may happen that you already entered something into the next field before unpoly updates that field with a server response, discarding your...

The steps I wait for active ajax requests to complete (if configured) and capybara-lockstep can catch some of these cases, but not all. Both of these only wait...

We use foreman to start all necessary processes for an application, which are declared in a Procfile. This is very convenient, but the outputs of all processes get merged together...

...Especially while debugging you might not want other processes to flood your screen with their log messages. The following setup allows you to start Terminator in a split view with...

...ZIP archive, you basically have two options: Write a ZIP file to disk and send it as a download to the user. Generate a ZIP archive on the fly while...

...streaming it in chunks to the user. This card is about option 2, and it is actually fairly easy to set up. We are using this to generate ZIP archives...

By activating strict_loading you force developers to address n+1 queries by preloading all associations used in the index view. Using an association that is not preloaded will raise...

...an ActiveRecord::StrictLoadingViolationError. I think it's a good default to activate strict_loading in your controllers' #index actions. This way, when a change introduces an n+1 query, your...

PostgreSQL uses the C library's locale facilities for sorting strings: First, all the letters are compared, ignoring spaces and punctuation. It sorts upper and lower case letters together. So...

...the order will be something like a A b B c C Then, spaces and punctuation are compared to break ties. Example: Ruby PostgreSQL IMAGE3.jpg image2.jpg image.jpg image3.jpg image2.jpg

jetbrains.com

RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to work together. This is nicer to the eyes and much...

...more powerful than sharing code through some video chat. How to Getting started is really simple: Click the "add person" icon in the top-right editor corner (or hit Ctrl...

Ask the admins to turn on SSL (they will set an HSTS header for SSL-only sites) Make cookies secure and http_only Never hard-code the http protocol...

...into URLs that point to your application, which makes you vulnerable to SSL-stripping. When linking to internal resources, just use the path without protocol or URL When linking to...

...on a Rails record is converted to UTC using to_s(:db) to be stored, and converted back into the correct time zone when the record is loaded from the...

...This is now UTC Problem That will blow up in your face when you send times to attributes that expect dates, just because those times will also be converted using...

...PATH << File.expand_path('../../lib', __FILE__) require 'my_cli' MyCli.run! However, if you create a symlink to this file, this will no longer work. __FILE__ will resolve to the path of...

...the symlink, not to its target. One solution is to use File.realpath(__FILE__). In Ruby 2+ you can also use this: $LOAD_PATH << File.expand_path('../lib', __dir__) __dir__ is simply...

makandra dev

...instead of using the UI or creating records in the Rails console. This approach saves time and gives you useful defaults and associations right out of the box.

When your site is on HTTPS and you are linking or redirecting to a HTTP site, the browser will not send a referrer. This means the target site will see...

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

...yml files. You may override those application-wide error messages using model or attribute scope like this: en: activerecord: errors: messages: invalid: is invalid # used for any invalid attribute in...

makandra dev

If you need a sample video with certain properties for a test you can create one using ffmpeg. You might want a very low bitrate file to speed up processing...

...ffmpeg -t 21 -s 10x10 -r 1 -f rawvideo -pix_fmt rgb24 -i /dev/zero sample_21_seconds.mp4 Option Explanation -t 21 set the length to 21s -s 10x10

...index do |person, index| person.award_trophy(index + 1) end Ruby's map with index Similarly, you may need an index when using other methods, like map, flat_map, detect (when...

...you need the index for detection), or similar. Here is an example for map: people.map.with_index do |person, index| person.at_rank(index + 1)

In interactive commands, Git allows the user to provide one-letter input with a single key without hitting enter (docs). # Enabled this feature globally git config --global interactive.singlekey true

...enable this feature locally for a single repository git config interactive.singlekey true This allows you to hit "y" instead of "y + ENTER" to move to the next hunk.

Running rails server will start a local server that you can access via http://localhost:3000. When you are working on multiple web apps, they will likely set cookies with...

...generic names on localhost. This is annoying, since you will sign out your current user whenever you switch to another app. A better way is to use our own daho.im...

web.archive.org

When you have a Cucumber step like Then I should see "Did you see those \"quotation marks\" over there?" you'll run into trouble. Cucumber won't take your...

...escaped quotation marks. Workarounds One workaround is to write the step as regex (since there is a step taking a regex): Then I should see /Did you see those "quotation...

...binary file. This method might be telling the truth most of the time. But sometimes it doesn't, and that's what causes pain. The method is defined as follows...

...not guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true # File.binary?('somefile.txt') # => false #--

When you send automated emails from a noreply@-address, and the recipient has an out of office enabled, the autoreply bounces and they get an additional email with an error...

...To prevent the recipient's auto-response and the following error message you can set the email header Auto-Submitted: auto-generated in your mailer, for example like this:

geordi cucumber path/to/features -r2 Background and how to rerun manually Cucumber will save a file tmp/parallel_cucumber_failures.log containing the filenames and line number of the failed scenarios after a...

...full test run. Normally you can say cucumber -p rerun (rerun is a profile defined by default in config/cucumber.yml) to rerun all failed scenarios. Here are a few alternative ways...