Skip to content

Commit

Permalink
Modify Faker::Educator, Fix faker-ruby#576 (faker-ruby#803)
Browse files Browse the repository at this point in the history
* Add subject, course_name, degree method for Faker::Educator (Fix faker-ruby#576)

* Update educator.rb

* Update educator.rb
  • Loading branch information
ghbooth12 authored and vbrazo committed Aug 20, 2018
1 parent d927b51 commit be8033b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
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 @@ -5,12 +5,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 @@ -11,8 +11,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

0 comments on commit be8033b

Please sign in to comment.