Skip to content

Instantly share code, notes, and snippets.

View pierrax's full-sized avatar

Maxime Pierrot pierrax

View GitHub Profile
@pierrax
pierrax / ===.md
Last active July 27, 2016 12:47
=== operator

=== Operator

How it works ?

x === y checks if y belongs to x group.

  String === "hello" # true
  String === 1 # false
  
 (1..10) === 3 # true
@pierrax
pierrax / improve_rails_perf.md
Last active May 31, 2016 16:05
Improve Rails perf

Use pluck instead of map

Celebrity.all.map(&:id)

=> Time: 3.925s

Celebrity.select(:id).map(&:id)

=> Time: 0.098s

@pierrax
pierrax / mock_tests.md
Last active May 24, 2016 15:50
Mock tests

Problem

How to test complex controller method with chained method ?

Example

  
  def update
    # ...
 user.propositions.call
@pierrax
pierrax / spy_pattern.md
Last active May 24, 2016 14:55
Spy pattern

Use spy

Spies are an alternate type of test double that support this pattern by allowing you to expect that a message has been received after the fact, using have_received.

RSpec.describe "have_received" do
  it "passes when the message has been received" do
 invitation = spy('invitation')
@pierrax
pierrax / rubymine.mk
Created May 12, 2016 07:33
<3 RubyMine <3
#Easy search
#Running test internaly
Shortcut to run a specific test
Link in the console on the errors
Step by step debugging
#Jump to function def
#Refactor
@pierrax
pierrax / squash_merge_release.md
Last active June 8, 2016 07:02
How to merge a release branch before deploying

#Go to the release branch

git checkout RELEASE_date

#Pull the last changes

git pull origin RELEASE_date