Skip to content

Commit

Permalink
Fix Faker::Source ruby language examples (#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
YumaInaura authored and stympy committed Jul 11, 2018
1 parent ff452db commit c601cc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
8 changes: 3 additions & 5 deletions lib/locales/en/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ en:
faker:
source:
hello_world:
ruby: "print 'Hello World!'"
ruby: "puts 'Hello World!'"
javascript: "alert('Hello World!');"
print:
ruby: "print 'faker_string_to_print'"
ruby: "puts 'faker_string_to_print'"
javascript: "console.log('faker_string_to_print');"
print_1_to_10:
ruby: "
10.times do |i|
print i
end"
(1..10).each { |i| puts i }"
javascript: "
for (let i=0; i<10; i++) {
console.log(i);
Expand Down
20 changes: 10 additions & 10 deletions test/test_faker_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ def setup
@tester = Faker::Source
end

def test_hello_world
def test_hello_world_instance
assert_instance_of String, @tester.hello_world
end

def test_print
def test_hello_world
assert_match "'Hello World!'", @tester.hello_world
end

def test_print_instance
assert_instance_of String, @tester.print
end

def test_print_javascript
assert_equal "console.log('some string');", @tester.print(lang: :javascript)
def test_print
assert_match "'some string'", @tester.print
end

def test_print_another_string
assert_equal "print 'another string'", @tester.print(str: 'another string')
assert_match "'another string'", @tester.print(str: 'another string')
end

def test_print_invalid_lang
assert_raise(I18n::MissingTranslationData) { @tester.print(lang: :js) }
end

def test_print_1_to_10
def test_print_1_to_10_instance
assert_instance_of String, @tester.print_1_to_10
end

def test_print_1_to_10_javascript
assert_match 'console.log(i);', @tester.print_1_to_10(:javascript)
end

def test_print_1_to_10_matches
assert_match 'print i', @tester.print_1_to_10
end
end

0 comments on commit c601cc6

Please sign in to comment.