Skip to content

Commit

Permalink
remove fakeweb stub with webmock
Browse files Browse the repository at this point in the history
  • Loading branch information
achiurizo committed Jan 25, 2024
1 parent 2a3444d commit b8e4585
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 22 additions & 15 deletions padrino-gen/test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,37 @@
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
Time.stubs(:now).returns(time)
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)
Expand Down
1 change: 1 addition & 0 deletions padrino-gen/test/test_component_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
def setup
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}"
`mkdir -p #{@apptmp}`
stub_static_files
end

def teardown
Expand Down
1 change: 1 addition & 0 deletions padrino-gen/test/test_project_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
def setup
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}"
`mkdir -p #{@apptmp}`
stub_static_files
end

def teardown
Expand Down

0 comments on commit b8e4585

Please sign in to comment.