From 3f6600541edad26f59fbc479ffa392bcb3c78653 Mon Sep 17 00:00:00 2001 From: Vaidehi Joshi Date: Fri, 19 Mar 2021 13:28:06 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=82=EF=B8=8F=20Remove=20the=20approvals?= =?UTF-8?q?=20gem=20=E2=9C=82=EF=B8=8F=20(#12978)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove approvals fixtures * Remove approvals initializer * Remove approvals gem * Remove approvals step from travis.yml * Remove approvals from dockerignore and gitignore * Remove references to approvals gem in docs * Un-approvals spec/liquid_tags/codepen_tag_spec.rb * Un-approvals spec/liquid_tags/dotnet_fiddle_tag_spec.rb * Temporarily skip other approvals tests We will still need to delete files in /spec/fixtures/approvals after this. * Revert changes to dotnet_fiddle_tag_spec and codepen_tag_spec, skip those tests instead * Temporarily skip more approvals based tests * Attempt at moving html doc inline * Comment out one more approvals spec * Update dotnet fiddle and codepen liquid tag specs to not use Approvals * Update liquid tag specs + system specs to not use Approvals * Un-approval feed import, github issue, and tweet tag specs * Re-add .approvals to gitignore and dockerignore * Use Rspec compound expectations --- .travis.yml | 1 - Gemfile | 1 - Gemfile.lock | 4 - docs/tests/approvals-tests.md | 43 ------ docs/tests/readme.md | 1 - .../generates_katex_output.approved.html | 12 -- .../accepts_a_valid_parler_url.approved.html | 7 - spec/liquid_tags/codepen_tag_spec.rb | 7 +- spec/liquid_tags/comment_tag_spec.rb | 2 +- spec/liquid_tags/details_tag_spec.rb | 4 +- spec/liquid_tags/dotnet_fiddle_tag_spec.rb | 5 +- spec/liquid_tags/instagram_tag_spec.rb | 10 +- spec/liquid_tags/js_fiddle_tag_spec.rb | 7 +- spec/liquid_tags/jsitor_tag_spec.rb | 39 +++-- spec/liquid_tags/katex_tag_spec.rb | 4 +- spec/liquid_tags/kotlin_tag_spec.rb | 9 +- spec/liquid_tags/next_tech_tag_spec.rb | 10 +- spec/liquid_tags/parler_tag_spec.rb | 6 +- spec/liquid_tags/runkit_tag_spec.rb | 7 +- spec/liquid_tags/soundcloud_tag_spec.rb | 7 +- spec/liquid_tags/tweet_tag_spec.rb | 7 +- spec/liquid_tags/user_tag_spec.rb | 2 +- spec/liquid_tags/wikipedia_tag_spec.rb | 4 +- spec/liquid_tags/youtube_tag_spec.rb | 18 ++- spec/models/github_issue_spec.rb | 6 +- spec/services/feeds/import_spec.rb | 17 +-- .../codepen_liquid_tag.approved.html | 7 - .../details_liquid_tag_spec.approved.html | 7 - .../dotnetfiddle_liquid_tag.approved.html | 7 - ...ail_subscriptionsunsubscribe.approved.html | 18 --- .../instagram_liquid_tag.approved.html | 9 -- .../jsfiddle_liquid_tag.approved.html | 7 - .../approvals/jsitor_liquid_tag.approved.html | 7 - ...sitor_liquid_tag_with_hyphen.approved.html | 7 - ...sitor_liquid_tag_with_params.approved.html | 7 - .../approvals/kotlin_liquid_tag.approved.html | 7 - .../nexttech_liquid_tag.approved.html | 7 - .../runkit_liquid_tag_spec.approved.html | 18 --- .../soundcloud_liquid_tag.approved.html | 7 - .../user_preview_article_body.approved.html | 142 ------------------ .../user_submit_article.approved.html | 1 - .../youtube_liquid_tag_no_time.approved.html | 7 - ...d_tag_no_time_trailing_space.approved.html | 7 - ...youtube_liquid_tag_with_time.approved.html | 7 - spec/support/initializers/approvals.rb | 5 - spec/system/user_uses_the_editor_spec.rb | 16 +- .../unsubscribe.html.erb_spec.rb | 2 +- vendor/cache/approvals-0.0.24.gem | Bin 35840 -> 0 bytes 48 files changed, 131 insertions(+), 411 deletions(-) delete mode 100644 docs/tests/approvals-tests.md delete mode 100644 spec/fixtures/approvals/katextag/render/generates_katex_output.approved.html delete mode 100644 spec/fixtures/approvals/parlertag/id/accepts_a_valid_parler_url.approved.html delete mode 100644 spec/support/fixtures/approvals/codepen_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/details_liquid_tag_spec.approved.html delete mode 100644 spec/support/fixtures/approvals/dotnetfiddle_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/email_subscriptionsunsubscribe.approved.html delete mode 100644 spec/support/fixtures/approvals/instagram_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/jsfiddle_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/jsitor_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/jsitor_liquid_tag_with_hyphen.approved.html delete mode 100644 spec/support/fixtures/approvals/jsitor_liquid_tag_with_params.approved.html delete mode 100644 spec/support/fixtures/approvals/kotlin_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/nexttech_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/runkit_liquid_tag_spec.approved.html delete mode 100644 spec/support/fixtures/approvals/soundcloud_liquid_tag.approved.html delete mode 100644 spec/support/fixtures/approvals/user_preview_article_body.approved.html delete mode 100644 spec/support/fixtures/approvals/user_submit_article.approved.html delete mode 100644 spec/support/fixtures/approvals/youtube_liquid_tag_no_time.approved.html delete mode 100644 spec/support/fixtures/approvals/youtube_liquid_tag_no_time_trailing_space.approved.html delete mode 100644 spec/support/fixtures/approvals/youtube_liquid_tag_with_time.approved.html delete mode 100644 spec/support/initializers/approvals.rb delete mode 100644 vendor/cache/approvals-0.0.24.gem diff --git a/.travis.yml b/.travis.yml index 9633cc4d3..3c1abcf4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,6 @@ install: script: - bundle exec rails db:create db:schema:load webpacker:compile - bin/knapsack_pro_rspec - - '[ ! -f .approvals ] || bundle exec approvals verify --ask false' notifications: slack: if: branch = master diff --git a/Gemfile b/Gemfile index c05f5c58e..c2d730649 100644 --- a/Gemfile +++ b/Gemfile @@ -159,7 +159,6 @@ group :development, :test do end group :test do - gem "approvals", "~> 0.0" # A library to make it easier to do golden-master style testing in Ruby gem "exifr", ">= 1.3.6" # EXIF Reader is a module to read EXIF from JPEG and TIFF images gem "factory_bot_rails", "~> 6.1" # factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies gem "launchy", "~> 2.5" # Launchy is helper class for launching cross-platform applications in a fire and forget manner. diff --git a/Gemfile.lock b/Gemfile.lock index 445593767..6e43775da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,9 +111,6 @@ GEM activerecord (>= 4.2.0) anyway_config (2.1.0) ruby-next-core (>= 0.11.0) - approvals (0.0.24) - nokogiri (~> 1.6) - thor (~> 0.18) ast (2.4.2) aws-eventstream (1.1.1) aws-sigv4 (1.2.3) @@ -886,7 +883,6 @@ DEPENDENCIES ahoy_matey (~> 3.2) amazing_print (~> 1.3) ancestry (~> 3.2) - approvals (~> 0.0) better_errors (~> 2.9) binding_of_caller (~> 0.8) blazer (~> 2.4.2) diff --git a/docs/tests/approvals-tests.md b/docs/tests/approvals-tests.md deleted file mode 100644 index f458a71ee..000000000 --- a/docs/tests/approvals-tests.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Approvals Tests ---- - -# Approvals Tests - -Approvals test is a form of unit test. It works by taking a snapshot of the -results and confirming that they have not changed. A good use-case for the -Approvals tests is to compare the rendered HTML to the test specified HTML. - -## Usage - -Simply create your test similar to the following: - -```ruby -it "renders the correct HTML on the home page" do - page = '

ZOMG

' - verify(format: :html) { page } # format can also be :json -end -``` - -You may then run the said test and a new `*.received.*` file will be created. -Thereafter, run the following command to verify the newly created file and -approve the created change. - -```shell -approvals verify -``` - -Please be sure to include the Approvals file in your commit. - -## Edge cases - -Approvals tests are difficult to utilise for testing variables that change. This -includes variables like: - -- Time -- URL slug -- uploaded image slug - -Please avoid generating large approvals files as it will be stored in the -codebase. If your approvals file gets too large, Approvals test may not be the -right tool for the job. diff --git a/docs/tests/readme.md b/docs/tests/readme.md index 962663737..43337f47e 100644 --- a/docs/tests/readme.md +++ b/docs/tests/readme.md @@ -2,7 +2,6 @@ title: Testing/QA Guide items: - acceptance-tests.md - - approvals-tests.md - integration-tests.md - unit-functional-tests.md - frontend-tests.md diff --git a/spec/fixtures/approvals/katextag/render/generates_katex_output.approved.html b/spec/fixtures/approvals/katextag/render/generates_katex_output.approved.html deleted file mode 100644 index de3d7d542..000000000 --- a/spec/fixtures/approvals/katextag/render/generates_katex_output.approved.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - -
- c=±a2+b2c = \pm\sqrt{a^2 + b^2} -
- - diff --git a/spec/fixtures/approvals/parlertag/id/accepts_a_valid_parler_url.approved.html b/spec/fixtures/approvals/parlertag/id/accepts_a_valid_parler_url.approved.html deleted file mode 100644 index 9e1c5aad4..000000000 --- a/spec/fixtures/approvals/parlertag/id/accepts_a_valid_parler_url.approved.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/spec/liquid_tags/codepen_tag_spec.rb b/spec/liquid_tags/codepen_tag_spec.rb index 5a01c1455..ff1b49af2 100644 --- a/spec/liquid_tags/codepen_tag_spec.rb +++ b/spec/liquid_tags/codepen_tag_spec.rb @@ -19,8 +19,11 @@ RSpec.describe CodepenTag, type: :liquid_tag do it "accepts codepen link" do liquid = generate_new_liquid(codepen_link) - rendered_codepen_iframe = liquid.render - Approvals.verify(rendered_codepen_iframe, name: "codepen_liquid_tag", format: :html) + + expect(liquid.render).to include("Click to see the answer!') # rubocop:disable Style/StringLiterals end end end diff --git a/spec/liquid_tags/dotnet_fiddle_tag_spec.rb b/spec/liquid_tags/dotnet_fiddle_tag_spec.rb index 12341d754..98471dfce 100644 --- a/spec/liquid_tags/dotnet_fiddle_tag_spec.rb +++ b/spec/liquid_tags/dotnet_fiddle_tag_spec.rb @@ -17,8 +17,9 @@ RSpec.describe DotnetFiddleTag, type: :liquid_tag do it "accepts dotnet link" do liquid = generate_new_liquid(dotnetfiddle_link) - rendered_dotnet_iframe = liquid.render - Approvals.verify(rendered_dotnet_iframe, name: "dotnetfiddle_liquid_tag", format: :html) + + expect(liquid.render).to include("') + # rubocop:enable Style/StringLiterals end it "rejects invalid ids" do diff --git a/spec/liquid_tags/js_fiddle_tag_spec.rb b/spec/liquid_tags/js_fiddle_tag_spec.rb index 94ae506c0..b3cd67c68 100644 --- a/spec/liquid_tags/js_fiddle_tag_spec.rb +++ b/spec/liquid_tags/js_fiddle_tag_spec.rb @@ -18,8 +18,11 @@ RSpec.describe JsFiddleTag, type: :liquid_tag do it "accepts jsfiddle link" do liquid = generate_new_liquid(jsfiddle_link) - rendered_jsfiddle_iframe = liquid.render - Approvals.verify(rendered_jsfiddle_iframe, name: "jsfiddle_liquid_tag", format: :html) + + # rubocop:disable Style/StringLiterals + expect(liquid.render).to include('