Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Faker::Educator, Fix #576 #803

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion doc/educator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ Faker::Educator.university #=> "Mallowtown Technical College"

Faker::Educator.secondary_school #=> "Iceborough Secondary College"

Faker::Educator.course #=> "Associate Degree in Criminology"
# [DEPRECATION] `course` is deprecated. Please use `degree` instead.
Faker::Educator.degree #=> "Associate Degree in Criminology"

Faker::Educator.course_name #=> "Criminology 101"

Faker::Educator.subject #=> "Criminology"

Faker::Educator.campus #=> "Vertapple Campus"
```
17 changes: 15 additions & 2 deletions lib/faker/educator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@ class Educator < Base
flexible :educator

class << self
extend Gem::Deprecate

def university
"#{parse('educator.name')} #{fetch('educator.tertiary.type')}"
end

def course
"#{fetch('educator.tertiary.course.type')} #{fetch('educator.tertiary.course.subject')}"
def degree
"#{fetch('educator.tertiary.degree.type')} #{fetch('educator.tertiary.degree.subject')}"
end

alias course degree
deprecate :course, :course_name, 2018, 10

def subject
fetch('educator.tertiary.degree.subject')
end

def course_name
"#{fetch('educator.tertiary.degree.subject')} #{numerify(fetch('educator.tertiary.degree.course_number'))}"
end

def secondary_school
Expand Down
3 changes: 2 additions & 1 deletion lib/locales/en/educator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ en:
secondary: ['High School', 'Secondary College', 'High']
tertiary:
type: ['College', 'University', 'Technical College', 'TAFE']
course:
degree:
subject: ['Arts', 'Business', 'Education', 'Applied Science (Psychology)', 'Architectural Technology', 'Biological Science', 'Biomedical Science', 'Commerce', 'Communications', 'Creative Arts', 'Criminology', 'Design', 'Engineering', 'Forensic Science', 'Health Science', 'Information Systems', 'Computer Science', 'Law', 'Nursing', 'Medicine', 'Psychology', 'Teaching']
type: ['Associate Degree in', 'Bachelor of', 'Master of']
course_number: ['1##', '2##', '3##', '4##', '5##']
12 changes: 10 additions & 2 deletions test/test_faker_educator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ def test_university
assert @tester.university.match(/(\w+\.? ?){2,3}/)
end

def test_course
assert @tester.university.match(/(\w+\.? ?){3,6}/)
def test_degree
assert @tester.degree.match(/(\w+\.? ?\(?\)?){3,6}/)
end

def test_subject
assert @tester.subject.match(/(\w+\.? ?\(?\)?){1,3}/)
end

def test_course_name
assert @tester.course_name.match(/(\w+\.? ?\(?\)?){1,3} \d{3}/)
end

def test_secondary_school
Expand Down