FactoryBot build_stubbed, build, and create

- Speed `build_stubbed` > `build` > `ceate` - `build` is not persistent object, `build_stubbed` make object looks like persistent - `buil...

Wayne

該寫哪些 test?

https://www.codewithjason.com/kinds-rails-tests-write-kinds-dont/ TL;DR: 1. 每個人對 test 的名稱定義不一樣,有些人叫 acceptance, 有些人叫 end to end, integr...

Wayne

Faking External Services in Tests with Adapters

Faking External Services in Tests with Adapters https://thoughtbot.com/blog/faking-external-services-in-tests-with-adapters

Wayne

rspec 3 composable matchers

http://rspec.info/blog/2014/01/new-in-rspec-3-composable-matchers/

Wayne

How to test ActionMailer with RSpec

This blog post will demostrate how to test ActionMailer in Rails using RSpec. ## Configuration ```rb # config/environments/test.rb # T...

Wayne

How to test Stripe webhook's singature with Rspec

This post shows how to test Stripe webhook's singature ```rb # spec/support/stripe_test_helper.rb module StripeTestHelper def stripe_...

Wayne

rspec test protocal (interface) - part 1 - define what's interface and find it

通常我們會希望繼承於 Base class 底下的 class 會有相同的 interface,for example, 每個 service 都要有一個 #call 的 instance method,應該要有個很簡單的方法來對這些 services 測試是否有 imp...

Wayne

Rspec aggregate_failures syntax

意思就是在 aggregate_failures block 底下任一個的 expectation 有 error 時會針對每個 expectation 顯示 error 的 message example ```ruby it "returns false ...

Wayne

great feature spec example

```rb feature 'User views all books' do scenario 'list all books' do create(:book, title: 'Practical Vim') create(:book, titl...

Wayne

看到一個不錯的 mock example (RSpec)

之前一篇文章提到 RSpec 盡量不用 let, 那要用啥?可以用 method。 另外看到一個不錯的 mock example, 用 tap 來 return double 但是 yield Authentictor ```rb def stub_authentica...

Wayne

RSpec best practice

https://github.com/thoughtbot/guides/tree/dee16052f49cb4b41fb8d090ffdb75942512ddb1/best-practices#testing https://robots.thoughtbot.c...

Wayne

FactoryGirl 原來還可以在 factory 下面再用 factory

FactoryGirl 原來還可以在 factory 下面再用 factory 這樣就可以用 ``` create(:tiny_btc_account) ``` ``` FactoryGirl.define do factory :account do l...

Wayne