Fix timestamp precision problem in CI

用 Timecop freeze 時間時,會因為作業系統不同的關係導致 RSpec test 在 compare timestamp 時出現誤差值,導致在 local 能 pass 的 test case 在 CI 卻會 failed,以下提供看似正常但會出錯的 Test ...

Wayne

Readable feature test with RSpec

可以用更語意的 method 來寫 spec,with `given`, `when`, `and`, `then` keywords Example: ```rb feature 'Enrolment' do scenario 'Enrolling in a c...

Wayne

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

How to test with Salesforce Heroku Connect - Part 2

In my previous post [How to test with Salesforce Heroku Connect ](https://waynechu.cc/posts/290-how-to-test-with-salesforce-heroku-conne...

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

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

How to test with Salesforce Heroku Connect

## What is Heroku Connect? This is a tool provided by Salesforce and Heroku, it will automatically sync all your salesforce tables int...

Wayne

Rspec aggregate_failures syntax

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

Wayne

釐清 DatabaseCleaner strategy 跟 clean_with

```rb config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end ``` ### 釐清...

Wayne

Test 4 phases

Setup -> Exercise -> Verify -> Teardown Setup: 準備資料 Exercise: 做事情 Verify: 確認事情正確執行 Teardown: 還原成 setup 前的狀態 好的 test 是依序執行這四個步驟 An...

Wayne

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

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

Wayne

About testing

unit test, integration test, acceptance test 有什麼不同呢? unit test 就是 test 最基本的東西,例如一個 function ,藉由確定每個 function 的正確性來確保程式正常運作 integration t...

Wayne