Skip to content

Commit

Permalink
fix rubocops
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hutchinson committed Dec 4, 2022
1 parent a66624c commit 1ff9e00
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion acts_as_textcaptcha.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
7 changes: 2 additions & 5 deletions lib/acts_as_textcaptcha/textcaptcha_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/textcaptcha_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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

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

Expand Down
2 changes: 1 addition & 1 deletion test/textcaptcha_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1ff9e00

Please sign in to comment.