Defining custom RSpec matchers

Posted Over 13 years ago by Henning Koch.
github.com

There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define

Spec correct routing of custom URLs

Posted Over 13 years ago by Henning Koch.

When you roll custom URLs with hacks like routing-filter, you can put a spec like this into spec/routing/routing_spec.rb:

Test e-mail dispatch in Cucumber

Posted Over 13 years ago by Henning Koch.

Spreewald has steps that let you test that e-mails have been sent, using arbitrary conditions in any combination.

Testing validates_format_of with Shoulda matchers

Posted Over 13 years ago by Henning Koch.

Don't use should validate_format_of(...) because that matcher works in weird ways. Use the allow_value matcher instead...

Regular Expressions - Cheat Sheet

Posted Over 13 years ago.
regular-expressions.info

You can write regular expressions some different ways, e.g. /regex/ and %r{regex}. For examples, look here. Remember that it...

Multi-line step arguments in Cucumber

Posted Over 13 years ago by Henning Koch.
wiki.github.com

The following example is from the Cucumber wiki: Given a blog post named "Random" with Markdown body """ Some Title, Eh...

rspec_candy is now a gem

Posted Almost 12 years ago by Henning Koch.
github.com

Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is...

Faking and testing the network with WebMock

Posted Over 13 years ago by Henning Koch.
github.com

An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you...

Forward HTTP through an intermediary server (Local Port Forwarding)

Posted Over 13 years ago by Henning Koch.

This will tunnel HTTP requests to one given domain and port through an intermediary SSH server: ssh -L 8080:targethost...

Submit a form with Prototype

Posted Over 13 years ago by Tobias Kraze.
prototypejs.org

For example, to send a form and populate a preview div with the response. $('content_form').request({ parameters: { 'preview': "1...

Fixing Webrat after following an external link

Posted Over 13 years ago by Arne Hartherz.

When a Cucumber feature leaves your page through an external Link, Webrat has problems like "Could not find field: "E...

MySQL replication how-to

Posted Over 13 years ago by Arne Hartherz.

This may be awkward to set up, but will work once you're done. Fun facts:

Cucumber Webrat steps

Posted Over 13 years ago by Lexy.

Most of these will not work in newer projects because these use the Capybara/Rack::Test combo in lieu of Webrat...

Aggregated RSpec/Cucumber test coverage with RCov

Posted Over 13 years ago.

With defaults, RCov doesn't work the way you how you would like it to. To create a nice test...

Test concurrent Ruby code

Posted Over 13 years ago by Tobias Kraze.

To test concurrent code, you will need to run multiple threads. Unfortunately, when you use blocking system calls (e.g. locks...

Better Output for RSpec

Posted Over 13 years ago by Tobias Kraze.

rspec_spinner is a progress bar for RSpec which outputs failing examples as they happen (instead of all at the...

Concurrent Tests

Posted Over 13 years ago by Lexy.

Install gem and plugin sudo gem install parallel script/plugin install git://github.com/grosser/parallel_tests.git Adapt config/database.yml test: database: xxx_test<%= ENV...

Rails - Multi Language with Fast_Gettext

Posted Over 13 years ago.

sudo gem install gettext --no-ri --no-rdoc sudo gem install fast_gettext --no-ri --no-rdoc script/plugin install git://...

Freeze (vendor, unpack) a single Ruby gem with and without Bundler

Posted About 13 years ago by Henning Koch.

When you need to patch an existing gem, one way is to "vendor" the gem by copying it into the...

Squashing several Git commits into a single commit

Posted Over 13 years ago by Lexy.
de.gitready.com

This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as...

Run a single test in Test::Unit

Posted Over 13 years ago by Henning Koch.

To run a single test file: rake test:units TEST=test/unit/post_test.rb rake test:functionals TEST=test/functional/posts_controller_test.rb rake test:integration TEST...

Configuring Git with .gitconfig

Posted Over 13 years ago by Dominik Schöler.

Basic configuration Please keep this config simple. It should be a starting point for new developers learning Git. [user]

Basic git commands

Posted Over 13 years ago.

This is for people recovering from Subversion. Get an existing from the server for the first time git clone git@example.com...

Test if a checkbox is checked in jQuery

Posted Over 13 years ago by Henning Koch.

jqueryElement.is(':checked')