From 1ff9e00042ecc0c98871712fc67e159f32d830ca Mon Sep 17 00:00:00 2001 From: Matthew Hutchinson Date: Sun, 4 Dec 2022 21:59:30 +0000 Subject: [PATCH] fix rubocops --- acts_as_textcaptcha.gemspec | 1 - lib/acts_as_textcaptcha/textcaptcha_api.rb | 7 ++----- test/textcaptcha_api_test.rb | 4 ++-- test/textcaptcha_test.rb | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/acts_as_textcaptcha.gemspec b/acts_as_textcaptcha.gemspec index bc81d5b..744419f 100644 --- a/acts_as_textcaptcha.gemspec +++ b/acts_as_textcaptcha.gemspec @@ -30,7 +30,6 @@ Gem::Specification.new do |spec| } spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - spec.test_files = `git ls-files -- {test}/*`.split("\n") spec.bindir = "bin" spec.require_paths = ["lib"] diff --git a/lib/acts_as_textcaptcha/textcaptcha_api.rb b/lib/acts_as_textcaptcha/textcaptcha_api.rb index 7a37dac..4312163 100644 --- a/lib/acts_as_textcaptcha/textcaptcha_api.rb +++ b/lib/acts_as_textcaptcha/textcaptcha_api.rb @@ -7,11 +7,8 @@ class TextcaptchaApi BASE_URL = "http://textcaptcha.com" def initialize(api_key: nil, api_endpoint: nil, raise_errors: false) - self.uri = if api_endpoint - URI(api_endpoint) - else - URI("#{BASE_URL}/#{api_key}.json") - end + self.uri = URI(api_endpoint || "#{BASE_URL}/#{api_key}.json") + self.raise_errors = raise_errors || false rescue URI::InvalidURIError => e raise ApiKeyError.new(api_key, e) diff --git a/test/textcaptcha_api_test.rb b/test/textcaptcha_api_test.rb index a3b1b7d..dc5a9db 100644 --- a/test/textcaptcha_api_test.rb +++ b/test/textcaptcha_api_test.rb @@ -14,7 +14,7 @@ def test_raises_error_for_invalid_api_key def test_fetch_and_parse_q_and_a stub_api_with(valid_json_response) q_and_a = textcaptcha_api.fetch - assert_equal q_and_a["q"], "What is Jennifer\'s name?" + assert_equal q_and_a["q"], "What is Jennifer's name?" assert_equal q_and_a["a"], ["1660fe5c81c4ce64a2611494c439e1ba"] end @@ -22,7 +22,7 @@ def test_fetch_and_parse_q_and_a_from_defined_endpoint my_api_endpoint = "http://myserver.com/my-api.json" stub_api_with(valid_json_response, api_endpoint: my_api_endpoint) q_and_a = textcaptcha_api(api_endpoint: my_api_endpoint).fetch - assert_equal q_and_a["q"], "What is Jennifer\'s name?" + assert_equal q_and_a["q"], "What is Jennifer's name?" assert_equal q_and_a["a"], ["1660fe5c81c4ce64a2611494c439e1ba"] end diff --git a/test/textcaptcha_test.rb b/test/textcaptcha_test.rb index 73e0443..77f8681 100644 --- a/test/textcaptcha_test.rb +++ b/test/textcaptcha_test.rb @@ -35,7 +35,7 @@ def test_parses_answers_from_json_response stub_api_with(valid_json_response) review.textcaptcha - assert_equal review.textcaptcha_question, "What is Jennifer\'s name?" + assert_equal review.textcaptcha_question, "What is Jennifer's name?" assert_equal find_in_cache(review.textcaptcha_key).length, 1 end