From b8e4585c9e507268c9e962f8462b15ffe482946f Mon Sep 17 00:00:00 2001 From: Arthur Chiu Date: Wed, 24 Jan 2024 16:29:59 -0800 Subject: [PATCH] remove fakeweb stub with webmock --- Gemfile | 1 - padrino-gen/test/helper.rb | 37 ++++++++++++-------- padrino-gen/test/test_component_generator.rb | 1 + padrino-gen/test/test_project_generator.rb | 1 + 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 5ac157e48..83ce38492 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,6 @@ group :development do end gem "builder", ">= 2.1.2" - gem "fakeweb", ">= 1.2.8" gem "webmock", ">= 0" gem "minitest", ">= 4.0" gem "mocha", ">= 2.0" diff --git a/padrino-gen/test/helper.rb b/padrino-gen/test/helper.rb index eff0dad89..87850cc7b 100644 --- a/padrino-gen/test/helper.rb +++ b/padrino-gen/test/helper.rb @@ -11,23 +11,8 @@ require 'mocha/minitest' require 'webmock/minitest' -# include WebMock::API - Padrino::Generators.load_components! -# register fake URL to avoid downloading static files every time tests run -fake_uri_base = "https://raw.github.com/padrino/padrino-static/master/" -%W[ - js/dojo.js ujs/dojo.js - js/ext.js ujs/ext.js - js/jquery.js ujs/jquery.js - js/mootools.js ujs/mootools.js - js/right.js ujs/right.js - js/protopak.js js/lowpro.js ujs/prototype.js -].each do |suffix| - WebMock::API.stub_request(:get, fake_uri_base + suffix) -end - class Minitest::Spec def stop_time_for_test time = Time.now @@ -35,6 +20,28 @@ def stop_time_for_test return time end + def stub_static_files + # register fake URL to avoid downloading static files every time tests run + fake_uri_base = "https://raw.github.com/padrino/padrino-static/master/" + %W[ + js/dojo.js + js/ext.js + js/jquery.js + js/lowpro.js + js/mootools.js + js/protopak.js + js/right.js + ujs/dojo.js + ujs/ext.js + ujs/jquery.js + ujs/mootools.js + ujs/prototype.js + ujs/right.js + ].each do |suffix| + WebMock::API.stub_request(:get, fake_uri_base + suffix) + end + end + # generate(:controller, 'DemoItems', '-r=/tmp/sample_project') def generate(name, *params) "Padrino::Generators::#{name.to_s.camelize}".constantize.start(params) diff --git a/padrino-gen/test/test_component_generator.rb b/padrino-gen/test/test_component_generator.rb index 99206d875..91d12de79 100644 --- a/padrino-gen/test/test_component_generator.rb +++ b/padrino-gen/test/test_component_generator.rb @@ -5,6 +5,7 @@ def setup @apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}" `mkdir -p #{@apptmp}` + stub_static_files end def teardown diff --git a/padrino-gen/test/test_project_generator.rb b/padrino-gen/test/test_project_generator.rb index e9817d6d7..827416b89 100644 --- a/padrino-gen/test/test_project_generator.rb +++ b/padrino-gen/test/test_project_generator.rb @@ -4,6 +4,7 @@ def setup @apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}" `mkdir -p #{@apptmp}` + stub_static_files end def teardown