Skip to content

Instantly share code, notes, and snippets.

@JoaoGFarias
Last active December 18, 2015 21:00
Show Gist options
  • Select an option

  • Save JoaoGFarias/581159a3478ed4e8f65e to your computer and use it in GitHub Desktop.

Select an option

Save JoaoGFarias/581159a3478ed4e8f65e to your computer and use it in GitHub Desktop.
Example of Test-Driven testing in Ruby
admin1 = User.getUserInfo("admin1")
puts admin1["email"] # -> Prints admin1@email.com
user1 = User.getUserInfo("user_1")
puts user1["email"] # -> Prints user1@email.com
wrongPasswordForUser1 = user1["password"] + "Sufix to break password"
require 'yaml' #Gem used to parse YAML files
class User
def new() #Constructor
#Opens user.yml file, stored at the same directory of this class
@users = YAML.load_file(File.expand_path("users.yml", __FILE__))
end
def self.getUserInfo(user)
return @users[user]
#See client for example
end
end
admin_1:
email:
admin1@email.com
password:
adminPass
admin_2:
email:
admin2@email.com
password:
adminPass2
user_1:
email:
user1@email.com
password:
password_from_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment