Skip to content

Commit

Permalink
Drop Timecop dependency
Browse files Browse the repository at this point in the history
If #857 comes in, it turns out that we don't need Timecop anymore (it
doesn't freeze the monotic clock, so I had to find another way) -- here
we remove all mentions of it and drop the dependency.

I don't find it causes too much trouble so I'm not against bringing it
back in the future if we need it again, but it seems good for project
cleanliness to take it out for now.
  • Loading branch information
brandur committed Oct 1, 2019
1 parent e52bb95 commit 6c068a0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ group :development do
gem "rake"
gem "shoulda-context"
gem "test-unit"
gem "timecop"
gem "webmock"

# Rubocop changes pretty quickly: new cops get added and old cops change
Expand Down
5 changes: 2 additions & 3 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ def self.flatten_params_array(value, calculated_key)
# to calculate an elapsed duration.
#
# Shortcut for getting monotonic time, mostly for purposes of line length
# and stubbing (Timecop doesn't freeze the monotonic clock). Returns time
# in seconds since the event used for monotonic reference purposes by the
# platform (e.g. system boot time).
# and test stubbing. Returns time in seconds since the event used for
# monotonic reference purposes by the platform (e.g. system boot time).
def self.monotonic_time
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
Expand Down
10 changes: 5 additions & 5 deletions test/stripe/stripe_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ class StripeClientTest < Test::Unit::TestCase

context "logging" do
setup do
# Freeze time for the purposes of the `elapsed` parameter that we emit
# for responses. Mocha's `anything` parameter can't match inside of a
# hash and is therefore not useful for this purpose, and Timecop
# doesn't freeze monotonic time. If we switch over to rspec-mocks at
# some point, we can probably remove Timecop from the project.
# Freeze time for the purposes of the `elapsed` parameter that we
# emit for responses. Mocha's `anything` parameter can't match inside
# of a hash and is therefore not useful for this purpose. If we
# switch over to rspec-mocks at some point, we can probably remove
# this.
Util.stubs(:monotonic_time).returns(0.0)
end

Expand Down
1 change: 0 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
require "mocha/setup"
require "stringio"
require "shoulda/context"
require "timecop"
require "webmock/test_unit"

PROJECT_ROOT = ::File.expand_path("../", __dir__)
Expand Down

0 comments on commit 6c068a0

Please sign in to comment.