-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Faker::ElectricalComponents #799
Merged
vbrazo
merged 14 commits into
faker-ruby:master
from
bheim6:bheim6_electrical_component_spike
Jun 11, 2018
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dcf008c
test setup added for electrical components, test is included in test …
bheim6 6380b03
add require path to faker.rb, add elec component file in faker/, test…
bheim6 415b682
test passes for active method, more additions to come
bheim6 da11324
add Electrical Components - active to docs
bheim6 5d8a2bc
passive test passing, add passive components to en.yml
bheim6 3c04e3a
add docs for passive
bheim6 c54e4ae
add test and functionality for electromechanical components, all test…
bheim6 37aa348
add docs for electromechanical
bheim6 81ddfc9
remove unnecessary class << self code
bheim6 6953e8d
fix spacing and indentation
bheim6 3b7e996
Merge with master and fix electrical components locale
vbrazo 922db80
Update changelog.md
vbrazo 5d850a5
Update readme.md
vbrazo bfc508b
Minor change
vbrazo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Faker::ElectricalComponents | ||
|
||
```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
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,16 @@ | ||
module Faker | ||
class ElectricalComponents < Base | ||
flexible :electrical_components | ||
def active | ||
fetch('electrical_components.active') | ||
end | ||
|
||
def passive | ||
fetch('electrical_components.passive') | ||
end | ||
|
||
def electromechanical | ||
fetch('electrical_components.electromechanical') | ||
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
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the flexible key above, can these methods be removed and the tests still pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they can not, I get
NoMethodError: undefined method
[]' for nil:NilClass`` errors for each method if they are not present. I included this code because an error message from the test suite prompted me to:warning: instance variable @flexible_key not initialized
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍