This actually works:
class Klass
def initialize
`hi world`
end
def `(message)
puts "Called with backticks: #{message}"
end
end
Klass.new # Prints "Called with backticks: hi world"
Hat tip to @jcoglan.
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)
The debugger
gem does not seem to be properly working on Ruby 2. Use byebug
instead!
Byebug is a simple to use, feature rich debugger for Ruby 2. It uses the new TracePoint API for execution control and the new Debug Inspector API for call stack navigation, so it doesn't depend on internal core sources. It's developed as a C extension, so it's fast. And it has a full test suite so it's reliable. Note that byebug works only for ruby 2.0.0 or newer. For...
The attached RSpec matcher allows for comfortably testing delegation.
describe Post do
it { should delegate(:name).to(:author).with_prefix } # post.author_name
it { should delegate(:month).to(:created_at) }
it { should delegate(:year).to(:created_at) }
end
Credits go to txus. See the attached link for an RSpec 2+ version.
The material design project for Angular is a complementary effort to the Polymer project's paper elements collection. Our goal is to provide a set of AngularJS-native UI elements that implement the material design system.
The Paper elements are a set of UI elements that implement the material design system.
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...
Skype has been updated to 4.3 on Linux. This fixes group chat issues with non-linux clients.
If you have previously installed skype via ubuntu packages, you need to remove those fist via
sudo apt-get remove skype skype-bin
Try to install the 32 bit version. In serveral cases this was the way that worked out.
Grab the installer here:
When connecting to multiple (i.e. > 4) servers to dive into logfiles or do security updates, terminator is what you want.
There are several keyboard shortcuts available:
Automatically builds gems from Bower packages (currently 1700 gems available). Packaged Javascript files are then automatically available in your asset pipeline manifests.
At makandra we made a choice to use bower-rails instead. While we believe Rubygems/Bundler to be superior to Javascript package managers, we wanted to use something with enough community momentum behind it that it won't go away in 10 years...
SudoSlider is a simple yet powerful content slider that makes no (or very few) assumptions about your markup and is very customizable.
You can basically embed any HTML into the slides, so you can mix images, videos, texts, and other stuff.
Check out the demos.
Please note:
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
This SSL Server Test can help finding out which SSL/TLS versions the server can handle.
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...
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...
Impressive set of design guidelines from Google.
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.
The solution is to follow [the gem's installation guide](https://github.com/thoughtbot/sh...
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...
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.
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.
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...
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.
An all-in-approach to fix the problem of pending AJAX requests dying in the browser when the server ends a test or switches scenarios.
We were able to work around this issue in most projects by doing this instead:
After '@javascript' do
step 'I wait for the page to load'
end
Provides a value container that guarantees atomic updates to this value in a multi-threaded Ruby program.
Originally linked to:
ruby-concurrency/atomic (Deprecated)
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.
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
"Keyword arguments" allow naming method arguments (optionally setting a default value). By using the double-splat operator, you can collect additional options. Default values for standard arguments still work (see adjective
).
def greet(name, adjective = 'happy', suffix: '!', count: 7, **options)
greeting = options[:letter] ? 'Dear' : 'Hello'
puts "#{greeting} #{adjective} #{name + suffix * count}"
end
Invoke the method like this:
greet('Otto', 'sad', suffix: '??', count: 9, include_blank: true)
In Ruby 2.1+,...