Closed vumanhcuongit closed 8 years ago
Trong khi test với RSpec, có lẽ bạn đã từng làm như thế này.
it "returns the current user" do # ... expect(current_user).to include( "email" => be_a(String), "first_name" => be_a(String), "last_name" => be_a(String), "age" => be_an(Integer), "phone_number" => be_a(String), "address" => { "street" => be_a(String), "state" => be_a(String) } ) expect(current_user["email"]).to match(/^regular-expression$/) expect(current_user["phone_number"]).to match(/^regular-expression$/) end
Mình nghĩ code sẽ đẹp hơn nếu trở nên như thế này
it "returns the current user" do # ... expect(current_user).to match_schema("user") end
Mình hy vọng có bài nói 5' để giới thiệu cách sử dụng JSON Schema trong RSpec.
Slides: https://goo.gl/Al12ex
:+1:
hi mọi người, mình đã cập nhật slides trong phần description :dancers:
Trong khi test với RSpec, có lẽ bạn đã từng làm như thế này.
Mình nghĩ code sẽ đẹp hơn nếu trở nên như thế này
Mình hy vọng có bài nói 5' để giới thiệu cách sử dụng JSON Schema trong RSpec.
Slides: https://goo.gl/Al12ex