37 lines
978 B
Ruby
37 lines
978 B
Ruby
require 'rails_helper'
|
|
|
|
describe RecaptchaHelper do
|
|
|
|
describe '#recaptchable?' do
|
|
|
|
it 'should be true if new record' do
|
|
assign(:debate, build(:debate))
|
|
expect(helper.recaptchable?).to be true
|
|
end
|
|
|
|
it 'should be false if existing record' do
|
|
assign(:debate, create(:debate))
|
|
expect(helper.recaptchable?).to be false
|
|
end
|
|
|
|
end
|
|
|
|
describe "#recaptcha_keys?" do
|
|
|
|
it "should be true if Recaptcha keys are configured" do
|
|
allow(Recaptcha.configuration).to receive(:public_key).and_return("akjasf")
|
|
allow(Recaptcha.configuration).to receive(:private_key).and_return("akjasf4532")
|
|
|
|
expect(helper.recaptcha_keys?).to be true
|
|
end
|
|
|
|
it "should be false if Recaptcha keys are not configured" do
|
|
allow(Recaptcha.configuration).to receive(:public_key).and_return(nil)
|
|
allow(Recaptcha.configuration).to receive(:private_key).and_return(nil)
|
|
|
|
expect(helper.recaptcha_keys?).to be false
|
|
end
|
|
|
|
end
|
|
end
|