ruby-vietnam / meetup

The official meet-up schedule of Ruby Vietnam Group
39 stars 0 forks source link

Meetup tháng 9 - Cuong Vu - Sử dụng JSON Schema trong RSpec #65

Closed vumanhcuongit closed 8 years ago

vumanhcuongit commented 9 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

rebyn commented 9 years ago

:+1:

qcam commented 9 years ago

:+1:

runlevel5 commented 9 years ago

:+1:

rauxalach commented 9 years ago

:+1:

baothi commented 9 years ago

:+1:

luan-phamhuu commented 9 years ago

:+1:

anitviec commented 9 years ago

:+1:

billytran1222 commented 9 years ago

:+1:

thanhcuong1990 commented 9 years ago

:+1:

vumanhcuongit commented 8 years ago

hi mọi người, mình đã cập nhật slides trong phần description :dancers:

runlevel5 commented 8 years ago

:+1: