Last active
December 18, 2015 21:00
-
-
Save JoaoGFarias/581159a3478ed4e8f65e to your computer and use it in GitHub Desktop.
Example of Test-Driven testing in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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