RSpec Expectation Matchers

04/02/15  Public, Testing / TDD

RSpec list of available Expectation Matchers. From the Lynda.com course RSpec Testing Framework with Ruby

1 vote - harrylevine

Command line keyboard shortcuts

04/02/15  Public, Shortcuts

control + a = Move to the start of the line
control + e = Move to the end of the line
esc + f = Move forward a word
esc + b = Move backward a word
control + b = Move back one character
control + f = Move forward one character
`co...

1 vote - harrylevine

Command to access your Rails sqlite3 database from the command line

03/28/15  Public, Databases

$ sqlite3 db/development.sqlite3

Run .tables to get a list of database tables, to confirm you are in the right place

Then run .help for list of available commands

Reference site: https://www.sqlite.org/cli.html

1 vote - harrylevine

rbenv common commands

04/04/15  Public, Other Languages

From the rbenv GitHub site

rbenv versions lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version.

$ rbenv versions
  1.8.7-p352
  1.9.2-p290
*...

1 vote - harrylevine

Ideal code description

03/14/15  Public, Ruby General

In most cases, our idea of ideal code is simple, readable, maintainable, and modular.

-Exercisim.io

1 vote - harrylevine

RSpec - Composing Matchers

03/05/15  Public, Testing / TDD

describe 'composing matchers' do
  # some matchers accept matchers as arguments. (new in rspec3)

  it 'will match all collection elements using a matcher' do
    array = [1,2,3]
    expect(array).to all( be < 5 )
  end

  it ...

1 vote - harrylevine

RSpec - Compound Matchers

03/05/15  Public, Testing / TDD

describe 'compound expectations' do

  it 'will match using: and, or, &, |' do
    expect([1,2,3,4]).to start_with(1).and end_with(4)

    expect([1,2,3,4]).to start_with(1) & include(2)

    expect(10 * 10).to be_odd.or be >...

1 vote - harrylevine

RSpec - Observation Matchers

03/05/15  Public, Testing / TDD

describe 'observation matchers' do
  # Note that all of these use "expect {}", not "expect()".
  # It is a special block format that allows a 
  # process to take place inside of the expectation.

  it 'will match when events chang...

1 vote - harrylevine

RSpec - Predicate Matchers

03/05/15  Public, Testing / TDD

describe 'predicate matchers' do

    it 'will match be_* to custom methods ending in ?' do
      # drops "be_", adds "?" to end, calls method on object
      # Can use these when methods end in "?", require no arguments, 
      ...

1 vote - harrylevine

RSpec - Other Useful Matchers

03/05/15  Public, Testing / TDD

describe 'other useful matchers' do

  it 'will match strings with a regex' do
    # This matcher is a good way to "spot check" strings
    string = 'The order has been received.'
    expect(string).to match(/order(.+)received/)

 ...

1 vote - harrylevine