diff --git a/spec/controllers_spec.rb b/spec/controllers_spec.rb index 396981a..987204d 100644 --- a/spec/controllers_spec.rb +++ b/spec/controllers_spec.rb @@ -14,6 +14,8 @@ InvisibleCaptcha.spinner_enabled = false end + after(:each) { travel_back } + context 'without invisible_captcha_timestamp in session' do it 'fails like if it was submitted too fast' do post :create, params: { topic: { title: 'foo' } } @@ -87,7 +89,7 @@ def custom_timestamp_callback context 'successful submissions' do it 'passes if submission on or after timestamp_threshold' do - sleep InvisibleCaptcha.timestamp_threshold + travel InvisibleCaptcha.timestamp_threshold post :create, params: { topic: { @@ -105,7 +107,7 @@ def custom_timestamp_callback end it 'allow to set a custom timestamp_threshold per action' do - sleep 2 # custom threshold + travel 2 # custom threshold post :publish, params: { id: 1 } @@ -126,7 +128,7 @@ def custom_timestamp_callback session[:invisible_captcha_timestamp] = Time.zone.now.iso8601 # Wait for valid submission - sleep InvisibleCaptcha.timestamp_threshold + travel InvisibleCaptcha.timestamp_threshold end it 'fails with spam' do @@ -237,7 +239,7 @@ def custom_timestamp_callback session[:invisible_captcha_timestamp] = Time.zone.now.iso8601 # Wait for valid submission - sleep InvisibleCaptcha.timestamp_threshold + travel InvisibleCaptcha.timestamp_threshold end after(:each) { InvisibleCaptcha.honeypot_enabled = true } @@ -265,7 +267,7 @@ def custom_timestamp_callback session[:invisible_captcha_spinner] = spinner_value # Wait for valid submission - sleep InvisibleCaptcha.timestamp_threshold + travel InvisibleCaptcha.timestamp_threshold end it 'fails with no spam, but mismatch of spinner' do