From ac7ef6672660535c07a9d5b82f783669dcfe5857 Mon Sep 17 00:00:00 2001 From: rhymes Date: Wed, 7 Aug 2019 21:59:23 +0200 Subject: [PATCH] Update Faker to 2.1.0 (#3652) * Upgrade Faker to 2.1.0 * Transition Faker calls to the new API --- Gemfile | 2 +- Gemfile.lock | 4 ++-- db/seeds.rb | 12 ++++++------ spec/factories/articles.rb | 8 ++++---- spec/factories/blocks.rb | 4 ++-- spec/factories/classified_listings.rb | 2 +- spec/factories/comments.rb | 2 +- spec/factories/events.rb | 2 +- spec/factories/html_variants.rb | 2 +- spec/factories/organizations.rb | 2 +- spec/factories/podcast_episode_rss_items.rb | 8 ++++---- spec/factories/podcast_episodes.rb | 2 +- spec/factories/podcasts.rb | 2 +- spec/factories/poll_options.rb | 2 +- spec/factories/poll_skips.rb | 2 +- spec/factories/polls.rb | 2 +- spec/liquid_tags/youtube_tag_spec.rb | 2 +- spec/models/event_spec.rb | 2 +- spec/models/message_spec.rb | 2 +- spec/models/organization_spec.rb | 6 +++--- spec/models/user_spec.rb | 2 +- 21 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile b/Gemfile index d14044aaf..986be84a0 100644 --- a/Gemfile +++ b/Gemfile @@ -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+ diff --git a/Gemfile.lock b/Gemfile.lock index 4fc5b041c..b94b54c5c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/db/seeds.rb b/db/seeds.rb index e8562bd8f..26c7c3806 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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" diff --git a/spec/factories/articles.rb b/spec/factories/articles.rb index 881038572..da55333d3 100644 --- a/spec/factories/articles.rb +++ b/spec/factories/articles.rb @@ -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 diff --git a/spec/factories/blocks.rb b/spec/factories/blocks.rb index a4fa842bc..e26562d10 100644 --- a/spec/factories/blocks.rb +++ b/spec/factories/blocks.rb @@ -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 diff --git a/spec/factories/classified_listings.rb b/spec/factories/classified_listings.rb index 562ae1f98..ca2dbeeb7 100644 --- a/spec/factories/classified_listings.rb +++ b/spec/factories/classified_listings.rb @@ -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 } diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index d21c43853..3a9e3ca14 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -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 diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 90b8d750b..ff149492e 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -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" } diff --git a/spec/factories/html_variants.rb b/spec/factories/html_variants.rb index af7dfb3ce..d36dbee5d 100644 --- a/spec/factories/html_variants.rb +++ b/spec/factories/html_variants.rb @@ -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 { "
#{rand(10_000_000_000)}

HEllo

" } success_rate { 0.3 } group { "article_show_sidebar_cta" } diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index dd0123f51..17a5568f9 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -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 } diff --git a/spec/factories/podcast_episode_rss_items.rb b/spec/factories/podcast_episode_rss_items.rb index dc6feacf2..2133cb77b 100644 --- a/spec/factories/podcast_episode_rss_items.rb +++ b/spec/factories/podcast_episode_rss_items.rb @@ -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 { "#{Faker::Internet.url}/2.mp3}" } - 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) } diff --git a/spec/factories/podcast_episodes.rb b/spec/factories/podcast_episodes.rb index d7a24c7a8..82fbe2619 100644 --- a/spec/factories/podcast_episodes.rb +++ b/spec/factories/podcast_episodes.rb @@ -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 diff --git a/spec/factories/podcasts.rb b/spec/factories/podcasts.rb index 3aabcb6ad..b41230ebc 100644 --- a/spec/factories/podcasts.rb +++ b/spec/factories/podcasts.rb @@ -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" } diff --git a/spec/factories/poll_options.rb b/spec/factories/poll_options.rb index fca3faa01..d50be7800 100644 --- a/spec/factories/poll_options.rb +++ b/spec/factories/poll_options.rb @@ -1,5 +1,5 @@ FactoryBot.define do factory :poll_option do - markdown { Faker::Hipster.words(3) } + markdown { Faker::Hipster.words(number: 3) } end end diff --git a/spec/factories/poll_skips.rb b/spec/factories/poll_skips.rb index 0bfdb36fc..17b242431 100644 --- a/spec/factories/poll_skips.rb +++ b/spec/factories/poll_skips.rb @@ -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) diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb index e42bd3af0..247349149 100644 --- a/spec/factories/polls.rb +++ b/spec/factories/polls.rb @@ -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 diff --git a/spec/liquid_tags/youtube_tag_spec.rb b/spec/liquid_tags/youtube_tag_spec.rb index 91fc807cd..f46f234fa 100644 --- a/spec/liquid_tags/youtube_tag_spec.rb +++ b/spec/liquid_tags/youtube_tag_spec.rb @@ -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=") diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 22e37cae1..093f9c4f4 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -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 diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index 81dce3a2c..eb958e592 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -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) } diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 0ba6a3c61..60a25f281 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 58ac2b956..fb8ff7c49 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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