-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Faker::ElectricalComponents (#799)
* test setup added for electrical components, test is included in test utput when running rake task, all tests pass * add require path to faker.rb, add elec component file in faker/, test assertion for active class added, implementation in progress * test passes for active method, more additions to come * add Electrical Components - active to docs * passive test passing, add passive components to en.yml * add docs for passive * add test and functionality for electromechanical components, all tests pass * add docs for electromechanical * remove unnecessary class << self code * fix spacing and indentation * Update changelog.md * Update readme.md * Minor change
- Loading branch information
Showing
6 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Faker::ElectricalComponents | ||
|
||
It might be available in the next version. | ||
|
||
```ruby | ||
Faker::ElectricalComponents.active #=> "Transistor" | ||
|
||
Faker::ElectricalComponents.passive #=> "Resistor" | ||
|
||
Faker::ElectricalComponents.electromechanical #=> "Toggle Switch" | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Faker | ||
class ElectricalComponents < Base | ||
flexible :electrical_components | ||
|
||
class << self | ||
def active | ||
fetch('electrical_components.active') | ||
end | ||
|
||
def passive | ||
fetch('electrical_components.passive') | ||
end | ||
|
||
def electromechanical | ||
fetch('electrical_components.electromechanical') | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
en: | ||
faker: | ||
electrical_components: | ||
active: ["Diode", "LED", "Rectifier", "Transistor", "JFET", "MOSFET", "Integrated Circuit", "LCD", "Cathode Ray Tube", "Vacuum Tube", "Battery", "Fuel Cell", "Power Supply"] | ||
passive: ["Resistor", "Potentiometer", "Trim Pot", "Varistor", "Capacitor", "Varicap Diode", "Inductor", "Transformer", "Generator", "Motor", "Solenoid", "Magnetic Amplifier", "Speaker", "Motion Sensor", "Accelerometer", "Thermocouple", "Antenna", "Oscillator", "Breadboard"] | ||
electromechanical: ["Piezoelectric device", "crystal", "Ultrasonic Motor", "Terminal", "Socket", "Power Cord", "Toggle Switch", "Slide Switch", "DIP Switch", "Footswitch", "Keypad", "Circuit Breaker", "Fuse", "Printed Circuit Board"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb') | ||
|
||
class TestFakerElectricalComponents < Test::Unit::TestCase | ||
def setup | ||
@tester = Faker::ElectricalComponents | ||
end | ||
|
||
def test_active | ||
assert @tester.active.match(/\w+/) | ||
end | ||
|
||
def test_passive | ||
assert @tester.passive.match(/\w+/) | ||
end | ||
|
||
def test_electromechanical | ||
assert @tester.electromechanical.match(/\w+/) | ||
end | ||
end |