Skip to content

Commit

Permalink
Avoid erratic failures by freezing time
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Nov 8, 2011
1 parent e50ba56 commit 7c4795a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions fake_braintree.gemspec
Expand Up @@ -24,4 +24,5 @@ Gem::Specification.new do |s|

s.add_development_dependency 'rspec', '~> 2.6.0'
s.add_development_dependency 'mocha', '~> 0.9.12'
s.add_development_dependency 'timecop', '~> 0.3.5'
end
8 changes: 5 additions & 3 deletions spec/fake_braintree/subscription_spec.rb
Expand Up @@ -31,10 +31,12 @@
end

it "sets the next billing date to 1 month from now in UTC" do
result = Braintree::Subscription.create(:payment_method_token => payment_method_token,
:plan_id => plan_id)
Timecop.freeze do
result = Braintree::Subscription.create(:payment_method_token => payment_method_token,
:plan_id => plan_id)

result.subscription.next_billing_date.to_i.should == 1.month.from_now.utc.to_i
result.subscription.next_billing_date.to_i.should == 1.month.from_now.utc.to_i
end
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -2,6 +2,7 @@
# in spec/support/ and its subdirectories.
require 'rspec'
require 'fake_braintree'
require 'timecop'
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}

Dir.mkdir('tmp') unless Dir.exist?('tmp')
Expand Down

0 comments on commit 7c4795a

Please sign in to comment.