Skip to content

Commit

Permalink
Update minitest-substitute to 1.0.0 and fix breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
svoop committed Mar 7, 2024
1 parent 83ef89e commit fe8f9f5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion spec/lib/rodbot/async_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

it "yields as an asynchronous job in non-test environment" do
with '@current', 'production', on: Rodbot::Env do
substitute '@current', 'production', on: Rodbot::Env do
yielded = false
subject.perform { yielded = true }
_(yielded).must_equal true
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/rodbot/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@
end

it "defaults to development" do
with "ENV['RODBOT_ENV']", 'unset or invalid' do
substitute "ENV['RODBOT_ENV']", 'unset or invalid' do
_(subject).must_be :development?
end
end
end

describe 'APP_ENV environment variable' do
it "sets the environment" do
with "ENV['APP_ENV']", 'production' do
with "ENV['RODBOT_ENV']", nil do
substitute "ENV['APP_ENV']", 'production' do
substitute "ENV['RODBOT_ENV']", nil do
_(subject).must_be :production?
end
end
end

it "RODBOT_ENV takes precedence" do
with "ENV['APP_ENV']", 'production' do
substitute "ENV['APP_ENV']", 'production' do
_(subject).must_be :test?
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/rodbot/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
end

describe :relay_extensions do
with '@config', on: Rodbot do
substitute '@config', on: Rodbot do
Rodbot::Config.new('plugin :matrix')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/rodbot/plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(*)
end

describe :extend_relay do
with '@config', on: Rodbot do
substitute '@config', on: Rodbot do
Rodbot::Config.new('plugin :matrix')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/rodbot/rack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def matched?

describe Rodbot::Rack do
describe :request do
with '::HTTPX', Minitest::HTTPX
substitute '::HTTPX', Minitest::HTTPX

it "does a GET request to the full URL using HTTPX" do
_(Rodbot.request('/search', params: { foo: 'bar' })).must_be :matched?
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/rodbot/relay_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ def write(message, extension)

describe :bind do
it "returns localhost and ports above 7200 by default" do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
_(matrix.send(:bind)).must_equal ['localhost', 7201]
_(slack.send(:bind)).must_equal ['localhost', 7202]
end
end

it "returns localhost and ports about explicit port config" do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack; port 8888"), on: Rodbot do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack; port 8888"), on: Rodbot do
_(matrix.send(:bind)).must_equal ['localhost', 8889]
_(slack.send(:bind)).must_equal ['localhost', 8890]
end
end

it "returns value of RODBOT_RELAY_HOST and ports above 7200" do
with "ENV['RODBOT_RELAY_HOST']", '0.0.0.0' do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
substitute "ENV['RODBOT_RELAY_HOST']", '0.0.0.0' do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
_(matrix.send(:bind)).must_equal ['0.0.0.0', 7201]
_(slack.send(:bind)).must_equal ['0.0.0.0', 7202]
end
Expand All @@ -52,7 +52,7 @@ def write(message, extension)

describe :say do
context "all relay extensions have say enabled" do
with '@config', on: Rodbot do
substitute '@config', on: Rodbot do
Rodbot::Config.new("plugin(:matrix) { say true }; plugin(:slack) { say true }")
end

Expand All @@ -68,7 +68,7 @@ def write(message, extension)
end

context "some relay extensions have say enabled" do
with '@config', on: Rodbot do
substitute '@config', on: Rodbot do
Rodbot::Config.new("plugin(:matrix) { say true }; plugin(:slack)")
end

Expand All @@ -88,7 +88,7 @@ def write(message, extension)
end

context "no relay extensions have say enabled" do
with '@config', on: Rodbot do
substitute '@config', on: Rodbot do
Rodbot::Config.new("plugin(:matrix); plugin(:slack)")
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/rodbot/services/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
end

it "returns localhost and explicit port config" do
with '@config', Rodbot::Config.new("port 8888"), on: Rodbot do
substitute '@config', Rodbot::Config.new("port 8888"), on: Rodbot do
_(subject.send(:bind)).must_equal ['localhost', 8888]
end
end

it "returns value of RODBOT_APP_HOST and port 7200" do
with "ENV['RODBOT_APP_HOST']", 'app.local' do
substitute "ENV['RODBOT_APP_HOST']", 'app.local' do
_(subject.send(:bind)).must_equal ['app.local', 7200]
end
end
Expand All @@ -36,15 +36,15 @@

it "returns http://localhost and explicit port config" do
Rodbot::Memoize::suspend do
with '@config', Rodbot::Config.new("port 8888"), on: Rodbot do
substitute '@config', Rodbot::Config.new("port 8888"), on: Rodbot do
_(subject.url).must_equal 'http://localhost:8888'
end
end
end

it "returns value of RODBOT_APP_URL and port 7200" do
Rodbot::Memoize::suspend do
with "ENV['RODBOT_APP_URL']", 'https://app.local' do
substitute "ENV['RODBOT_APP_URL']", 'https://app.local' do
_(subject.url).must_equal 'https://app.local:7200'
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/rodbot/services/relay_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
describe :url do
it "returns tcp://localhost and ports above 7200 by default" do
Rodbot::Memoize::suspend do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
_(subject.url(:matrix)).must_equal 'tcp://localhost:7201'
_(subject.url(:slack)).must_equal 'tcp://localhost:7202'
end
Expand All @@ -17,7 +17,7 @@

it "returns tcp://localhost and ports above explicit port config" do
Rodbot::Memoize::suspend do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack; port 8888"), on: Rodbot do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack; port 8888"), on: Rodbot do
_(subject.url(:matrix)).must_equal 'tcp://localhost:8889'
_(subject.url(:slack)).must_equal 'tcp://localhost:8890'
end
Expand All @@ -26,8 +26,8 @@

it "returns value of RODBOT_RELAY_URL_XXX and ports above 7200" do
Rodbot::Memoize::suspend do
with "ENV['RODBOT_RELAY_URL_MATRIX']", 'tcp://matrix.relay.local' do
with '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
substitute "ENV['RODBOT_RELAY_URL_MATRIX']", 'tcp://matrix.relay.local' do
substitute '@config', Rodbot::Config.new("plugin :matrix; plugin :slack"), on: Rodbot do
_(subject.url(:matrix)).must_equal 'tcp://matrix.relay.local:7201'
_(subject.url(:slack)).must_equal 'tcp://localhost:7202'
end
Expand Down

0 comments on commit fe8f9f5

Please sign in to comment.