For test automation engineers: in Ruby, you don’t need to worry about data types as you would with static type checking in compiled languages.
Let me illustrate with an example. Below is an API test script. As we know, a significant portion of API test scripting involves generating test data.
def generate_customer(email) result = Customer.new(email: email, first_name: Faker::Name.first_name, last_name: Faker::Name.last_name) return result end
it "API Testing: create customer" do customer_json = generate_customer("a@agileway.com.au").to_json # invoke API with the above payload end
The generate_customer function can generate a random customer, using the “Faker” library.