mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-10 00:03:09 -05:00
Clean up test output by capturing $stderr when we expect warnings (#894)
I just noticed while running tests that we produce some accidental output because both of `Source#source_transactions` and `SubscriptionItem#usage_record_summaries` are considered deprecated and have warnings attached. Here we capture output to `$stderr` and assert on it from the test cases that call these deprecated methods -- this pattern is already well established elsewhere in the test suite.
This commit is contained in:
parent
9afd73c16f
commit
fd71c5f50f
@ -99,10 +99,20 @@ module Stripe
|
|||||||
|
|
||||||
context "#source_transactions" do
|
context "#source_transactions" do
|
||||||
should "list source transactions" do
|
should "list source transactions" do
|
||||||
source = Stripe::Source.construct_from(id: "src_123",
|
old_stderr = $stderr
|
||||||
object: "source")
|
$stderr = StringIO.new
|
||||||
source.source_transactions
|
|
||||||
assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123/source_transactions"
|
begin
|
||||||
|
source = Stripe::Source.construct_from(id: "src_123",
|
||||||
|
object: "source")
|
||||||
|
source.source_transactions
|
||||||
|
assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123/source_transactions"
|
||||||
|
|
||||||
|
assert_include $stderr.string,
|
||||||
|
"use Source.list_source_transactions instead"
|
||||||
|
ensure
|
||||||
|
$stderr = old_stderr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -9,11 +9,21 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be listable" do
|
should "be listable" do
|
||||||
transactions = @sub_item.usage_record_summaries
|
old_stderr = $stderr
|
||||||
|
$stderr = StringIO.new
|
||||||
|
|
||||||
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/#{@sub_item.id}/usage_record_summaries"
|
begin
|
||||||
assert transactions.data.is_a?(Array)
|
transactions = @sub_item.usage_record_summaries
|
||||||
assert transactions.first.is_a?(Stripe::UsageRecordSummary)
|
|
||||||
|
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/#{@sub_item.id}/usage_record_summaries"
|
||||||
|
assert transactions.data.is_a?(Array)
|
||||||
|
assert transactions.first.is_a?(Stripe::UsageRecordSummary)
|
||||||
|
|
||||||
|
assert_include $stderr.string,
|
||||||
|
"use SubscriptionItem.list_usage_record_summaries instead"
|
||||||
|
ensure
|
||||||
|
$stderr = old_stderr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user