Spreewald 1.0.0 released

Spreewald now has a spreewald binary that lists all available steps, optionally filtering them. Example:

$> spreewald

# All Spreewald steps
Given I am on ...
... long list

$> spreewald check

# All Spreewald steps containing 'check'
When I check "..."
When I uncheck "..."
Then the "..." checkbox( within ...)? should be checked
Then the "..." checkbox( within ...)? should not be checked
Then the radio button "..." should( not)? be (checked|selected)

Sass function to set a color to an absolute hue

The adjust-hue function of Sass allows you to change a color's hue, but only relative to its current hue.

adjust-hue(#ffff00, 120)
// => #00ffff
adjust-hue(#444400, 120)
// => #004444

As you can see, we moved our yellow by 120° to cyan. \
But what if you want to move any color to a hue of 120° which is a nice shiny green?

Take this function:

@function set-hue($color, $target-hue)
  $current-hue: hue($color)
  $degree...

Working around OpenSSL::SSL::SSLErrors

If your requests blow up in Ruby or CURL, the server you're connecting to might only support requests with older SSL/TLS versions.

You might get an error like: OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=unknown state

SSL Server Test

This SSL Server Test can help finding out which SSL/TLS versions the server can handle.

Ruby

In Ruby, you can teach Net::HTTP to use a specific SSL/TLS version.

uri = URI.parse(url)

ssl_options = {
   use_ssl: true,
   ssl_version...

whenever: Make runner commands use bundle exec

In whenever you can schedule Ruby code directly like so:

every 1.day, :at => '4:30 am' do
  runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end

Combined with the best practice to hide background tasks behind a single static methods you can test, this is probably preferable to defining additional Rake tasks.

Unfortunately when whenever register a runner command, it doesn't use bundle exec in the resulting crontab. This gets you errors like this:

`gem_original_require': no suc...

shoulda-matcher methods not found in Rails 4.1

So you're getting an error message like the following, although your Gemfile lists shoulda-matchers and it has always worked:

NoMethodError:
  undefined method `allow_value' for #<RSpec::ExampleGroups::Person::Age:0x007feb239fa6a8>

This is due to Rails 4.1 (specifically, Spring) revealing a weak point of shoulda-matchers -- jonleighton explains why.

Solution

The solution is to follow [the gem's installation guide](https://github.com/thoughtbot/sh...

Telling Spring to watch certain directories/files

If you have some file or directory that should trigger a Spring reboot, tell Spring e.g. in config/spring.rb:

Spring.watch 'file.rb'
Spring.watch 'lib/templates'

However, Spring will silently drop paths that do not exist at the time calling #watch. Unless you restart Spring (thereby reloading the watch commands), it won't even watch them once they do exist.

Make sure the watchable paths exist before telling Spring to watch, e.g. with

FileUtils.touch 'file.rb'
FileUtils.mkdir_p 'lib/templates'
Spring.wa...

Device sizing and network throttling are coming to Chrome DevTools

See screenshot here.

This is great news because network throttling is very painful in Linux.

The features are already in Chrome Canary, so expect them to come to your Chrome sources soon.

How to test bundled applications using Aruba and Cucumber

Aruba is an extension to Cucumber that helps integration-testing command line tools.

When your tests involve a Rails test application, your tool's Bundler environment will shadow that of the test application. To fix this, just call unset_bundler_env_vars in a Cucumber Before block.

Previously suggested solution

Put the snippet below into your tool's features/support/env.rb -- now any command run through Aruba (e.g. via #run_simple) will have a clean Bundler envir...

Cucumber step to manually trigger javascript events in Selenium scenarios (using jQuery)

When you cannot make Selenium trigger events you rely on (e.g. a "change" event when filling in a form field), trigger it yourself using this step:

When /^I manually trigger a (".*?") event on (".*?")$/ do |event, selector|
  page.execute_script("jQuery(#{selector}).trigger(#{event})")
end

Note that this only triggers events that were registered through jQuery. Events registered through CSS or the native Javascript registry will not trigger.

Hover an element with Capybara < 2

You need this awkward command:

page.driver.browser.action.move_to(page.find(selector).native).perform

Note that there are better ways for newer Capybaras.

Ruby 2.1 returns a symbol when defining a method

Since Ruby 2.1, defining a method returns its name as a Symbol:

def foo() end             # => :foo
define_method :foo do end # => :foo

You can use this to do Python-like decorators like so:

private def foo; end 
memoize def foo; end