Update Faker to 2.1.0 (#3652)

* Upgrade Faker to 2.1.0

* Transition Faker calls to the new API
This commit is contained in:
rhymes 2019-08-07 21:59:23 +02:00 committed by Ben Halpern
parent 4dd90c5dd1
commit ac7ef66726
21 changed files with 36 additions and 36 deletions

View file

@ -122,7 +122,7 @@ group :development, :test do
gem "awesome_print", "~> 1.8" # Great Ruby dubugging companion: pretty print Ruby objects to visualize their structure
gem "bullet", "~> 6.0" # help to kill N+1 queries and unused eager loading
gem "capybara", "~> 3.27" # Capybara is an integration testing tool for rack based web applications
gem "faker", "~> 1.9" # A library for generating fake data such as names, addresses, and phone numbers
gem "faker", "~> 2.1" # A library for generating fake data such as names, addresses, and phone numbers
gem "parallel_tests", "~> 2.29" # Run Test::Unit / RSpec / Cucumber / Spinach in parallel
gem "pry-byebug", "~> 3.7" # Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish', 'continue' and 'break' commands to control execution
gem "rspec-rails", "~> 3.8" # rspec-rails is a testing framework for Rails 3+

View file

@ -314,7 +314,7 @@ GEM
factory_bot_rails (4.11.1)
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faker (1.9.6)
faker (2.1.0)
i18n (>= 0.7)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
@ -874,7 +874,7 @@ DEPENDENCIES
envied (~> 0.9)
erb_lint (~> 0.0)
factory_bot_rails (~> 4.11)
faker (~> 1.9)
faker (~> 2.1)
fastly (~> 1.15)
fastly-rails (~> 0.8)
feedjira (~> 3.0)

View file

@ -24,13 +24,13 @@ User.clear_index!
10.times do |i|
user = User.create!(
name: name = Faker::Name.unique.name,
summary: Faker::Lorem.paragraph_by_chars(199, false),
summary: Faker::Lorem.paragraph_by_chars(number: 199, supplemental: false),
profile_image: File.open(Rails.root.join("app", "assets", "images", "#{rand(1..40)}.png")),
website_url: Faker::Internet.url,
twitter_username: Faker::Internet.username(name),
twitter_username: Faker::Internet.username(specifier: name),
email_comment_notifications: false,
email_follower_notifications: false,
email: Faker::Internet.email(name, "+"),
email: Faker::Internet.email(name: name, separators: "+"),
confirmed_at: Time.current,
password: "password",
)
@ -86,9 +86,9 @@ Article.clear_index!
tags: #{tags.join(', ')}
---
#{Faker::Hipster.paragraph(2)}
#{Faker::Hipster.paragraph(sentence_count: 2)}
#{Faker::Markdown.random}
#{Faker::Hipster.paragraph(2)}
#{Faker::Hipster.paragraph(sentence_count: 2)}
MARKDOWN
Article.create!(
@ -106,7 +106,7 @@ Rails.logger.info "5. Creating Comments"
Comment.clear_index!
30.times do
attributes = {
body_markdown: Faker::Hipster.paragraph(1),
body_markdown: Faker::Hipster.paragraph(sentence_count: 1),
user_id: User.order(Arel.sql("RANDOM()")).first.id,
commentable_id: Article.order(Arel.sql("RANDOM()")).first.id,
commentable_type: "Article"

View file

@ -4,7 +4,7 @@ FactoryBot.define do
title { Faker::Book.title + rand(100).to_s }
published { true }
date { "01/01/2015" }
tags { Faker::Hipster.words(4).join(", ") }
tags { Faker::Hipster.words(number: 4).join(", ") }
canonical_url { Faker::Internet.url }
with_canonical_url { false }
with_date { false }
@ -15,7 +15,7 @@ FactoryBot.define do
with_collection { nil }
end
association :user, factory: :user, strategy: :create
description { Faker::Hipster.paragraph(1)[0..100] }
description { Faker::Hipster.paragraph(sentence_count: 1)[0..100] }
main_image { Faker::Avatar.image }
language { "en" }
experience_level_rating { rand(4..6) }
@ -30,9 +30,9 @@ FactoryBot.define do
canonical_url: #{canonical_url if with_canonical_url}
---
#{Faker::Hipster.paragraph(2)}
#{Faker::Hipster.paragraph(sentence_count: 2)}
#{'{% tweet 1018911886862057472%}' if with_tweet_tag}
#{Faker::Hipster.paragraph(1)}
#{Faker::Hipster.paragraph(sentence_count: 1)}
#{"\n\n---\n\n something \n\n---\n funky in the code? \n---\n That's nice" if with_hr_issue}
HEREDOC
end

View file

@ -1,7 +1,7 @@
FactoryBot.define do
factory :block do
input_html { Faker::Hipster.paragraph(1) }
input_html { Faker::Hipster.paragraph(sentence_count: 1) }
input_css { "body {color:red}" }
input_javascript { Faker::Hipster.paragraph(1) }
input_javascript { Faker::Hipster.paragraph(sentence_count: 1) }
end
end

View file

@ -2,7 +2,7 @@ FactoryBot.define do
factory :classified_listing do
user
title { Faker::Book.title + rand(100).to_s }
body_markdown { Faker::Hipster.paragraph(2) }
body_markdown { Faker::Hipster.paragraph(sentence_count: 2) }
category { "education" }
published { true }
bumped_at { Time.current }

View file

@ -1,7 +1,7 @@
FactoryBot.define do
factory :comment do
user
body_markdown { Faker::Hipster.paragraph(1) }
body_markdown { Faker::Hipster.paragraph(sentence_count: 1) }
commentable_id { rand(1000) }
commentable_type { "Article" }
factory :article_comment do

View file

@ -1,7 +1,7 @@
FactoryBot.define do
factory :event do
title { Faker::Company.bs }
description_markdown { Faker::Hipster.paragraph(2) }
description_markdown { Faker::Hipster.paragraph(sentence_count: 2) }
starts_at { Time.current }
ends_at { 3660.seconds.from_now }
category { "AMA" }

View file

@ -1,7 +1,7 @@
FactoryBot.define do
factory :html_variant do
user
name { Faker::Hipster.paragraph(1) }
name { Faker::Hipster.paragraph(sentence_count: 1) }
html { "<div>#{rand(10_000_000_000)}</div><h1>HEllo</h1>" }
success_rate { 0.3 }
group { "article_show_sidebar_cta" }

View file

@ -1,7 +1,7 @@
FactoryBot.define do
factory :organization do
name { Faker::Company.name }
summary { Faker::Hipster.paragraph(1)[0..150] }
summary { Faker::Hipster.paragraph(sentence_count: 1)[0..150] }
profile_image { File.open(Rails.root.join("app", "assets", "images", "android-icon-36x36.png")) }
nav_image { Faker::Avatar.image }
url { Faker::Internet.url }

View file

@ -1,12 +1,12 @@
FactoryBot.define do
factory :podcast_episode_rss_item, class: "Podcasts::EpisodeRssItem" do
title { Faker::Book.title }
itunes_subtitle { Faker::Hipster.words(3) }
itunes_summary { Faker::Hipster.words(3) }
itunes_subtitle { Faker::Hipster.words(number: 3) }
itunes_summary { Faker::Hipster.words(number: 3) }
link { Faker::Internet.url }
guid { "<guid isPermaLink=\"false\">#{Faker::Internet.url}/2.mp3}</guid>" }
pubDate { Faker::Date.between(2.years.ago, Time.zone.today) }
body { Faker::Hipster.paragraph(1) }
pubDate { Faker::Date.between(from: 2.years.ago, to: Time.zone.today) }
body { Faker::Hipster.paragraph(sentence_count: 1) }
enclosure_url { "#{Faker::Internet.url}/2.mp3" }
initialize_with { new(attributes) }

View file

@ -4,7 +4,7 @@ FactoryBot.define do
title { rand(30) }
media_url { Faker::Internet.url }
website_url { Faker::Internet.url }
body { Faker::Hipster.paragraph(1) }
body { Faker::Hipster.paragraph(sentence_count: 1) }
slug { "slug-#{rand(10_000)}" }
guid { "guid-#{rand(10_000)}" }
podcast

View file

@ -7,7 +7,7 @@ FactoryBot.define do
factory :podcast do
title { Faker::Beer.name }
image { image }
description { Faker::Hipster.paragraph(1) }
description { Faker::Hipster.paragraph(sentence_count: 1) }
slug { "slug-#{rand(10_000)}" }
feed_url { Faker::Internet.url }
main_color_hex { "ffffff" }

View file

@ -1,5 +1,5 @@
FactoryBot.define do
factory :poll_option do
markdown { Faker::Hipster.words(3) }
markdown { Faker::Hipster.words(number: 3) }
end
end

View file

@ -1,6 +1,6 @@
FactoryBot.define do
factory :poll_skip do
# prompt_markdown { Faker::Hipster.words(5) }
# prompt_markdown { Faker::Hipster.words(number: 5) }
# factory :poll_with_options do
# after(:create) do |poll|
# create_list(:poll_option, poll: poll)

View file

@ -1,6 +1,6 @@
FactoryBot.define do
factory :poll do
prompt_markdown { Faker::Hipster.words(5) }
prompt_markdown { Faker::Hipster.words(number: 5) }
poll_options_input_array { [rand(5).to_s, rand(5).to_s, rand(5).to_s, rand(5).to_s] }
end
end

View file

@ -4,7 +4,7 @@ RSpec.describe YoutubeTag, type: :liquid_template do
describe "#id" do
let(:valid_id_no_time) { "dQw4w9WgXcQ" }
let(:valid_ids_with_time) { "QASbw8_0meM?t=8h12m26s" }
let(:invalid_id) { Faker::Lorem.characters(rand(12..100)) }
let(:invalid_id) { Faker::Lorem.characters(number: rand(12..100)) }
def parsed_id(id)
return id unless id.include?("?t=")

View file

@ -4,7 +4,7 @@ RSpec.describe Event, type: :model do
let(:event) { create(:event) }
it "rejects title with over 90 characters" do
event.title = Faker::Lorem.characters(100)
event.title = Faker::Lorem.characters(number: 100)
expect(event).not_to be_valid
end

View file

@ -4,7 +4,7 @@ RSpec.describe Message, type: :model do
let(:user) { create(:user) }
let(:chat_channel) { create(:chat_channel) }
let(:user2) { create(:user) }
let(:long_text) { Faker::Hipster.words(1500) }
let(:long_text) { Faker::Hipster.words(number: 1500) }
describe "validations" do
subject { build(:message, :ignore_after_callback) }

View file

@ -9,7 +9,7 @@ RSpec.describe Organization, type: :model do
describe "#name" do
it "rejects names with over 50 characters" do
organization.name = Faker::Lorem.characters(51)
organization.name = Faker::Lorem.characters(number: 51)
expect(organization).not_to be_valid
end
@ -20,7 +20,7 @@ RSpec.describe Organization, type: :model do
describe "#summary" do
it "rejects summaries with over 1000 characters" do
organization.summary = Faker::Lorem.characters(1001)
organization.summary = Faker::Lorem.characters(number: 1001)
expect(organization).not_to be_valid
end
@ -46,7 +46,7 @@ RSpec.describe Organization, type: :model do
end
it "rejects wrong color format" do
organization.text_color_hex = "##{Faker::Lorem.words(4)}"
organization.text_color_hex = "##{Faker::Lorem.words(number: 4)}"
expect(organization).not_to be_valid
end
end

View file

@ -298,7 +298,7 @@ RSpec.describe User, type: :model do
it "does not allow too short or too long name" do
user.name = ""
expect(user).not_to be_valid
user.name = Faker::Lorem.paragraph_by_chars(200)
user.name = Faker::Lorem.paragraph_by_chars(number: 200)
expect(user).not_to be_valid
end