When let is called in Rspec

May 12, 2015

Reading time ~1 minute

Outline

When let / let! syntax is called in Rspec. ?

let

Use let to define a memoized helper method and you can execute it when you want to do. But it can be called once in example.

let!

It is similar to let. It force the method’s invocation before each example. (let! is similar to before)

Example

require 'rails_helper'

describe "let spec example" do

  let(:let_sample_1) { p "let sample 1" }

  it "" do
    let_sample_1 # print "let sample 1"
    let_sample_1 # dose not print "let sample 1"
  end

  context "" do
    count = []
    let!(:let_sample_2) { count.push(1) }
    it "" do
      p count # [1]
      p count # [1]
    end
    it "" do
      p count # [1, 1]
      p count # [1, 1]
    end
    context "" do
      it "" do
        p count # [1, 1, 1]
      end
    end
  end

end

add ticket number to git commit automatically

Most of ticket tracker like Github, pivotal tracker have function to connect your commit to ticket(story).But every time when you commit ...… Continue reading

I will build frontend and backend separately

Published on September 28, 2016

order of angular controller's initialisation

Published on October 05, 2015