yandex_captcha 0.4.3.5 → 0.4.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dec49d32aa312a91762b280c934c38aa8fc44890
4
- data.tar.gz: 42b4f188c419dc203b5742e5bbbd0c8d5f0e560f
3
+ metadata.gz: 3f3c550c9209b0bb1f5b67ea60688d30abee59e5
4
+ data.tar.gz: 6af1b0ac0c5ece46e60c54cd67baa8ad71a366d1
5
5
  SHA512:
6
- metadata.gz: ba4557d65c6bbd374c806e01c846f6ff3c0e4f8e1df1523ced84905d754bb43af1afed921f52e300ca0cc18b3636b0789de68031dd6167d055daad3df0b9cc74
7
- data.tar.gz: 0b64cb323d9b11471b83c648b20263159e6436b35911cbce215e3a6fd8995ec16ddb34f755a4946994428336cbaa766878149917c72be7945876cd9a7d0b445a
6
+ metadata.gz: 8547a1a047cf4ad1370798df4ef90fbe9ce5064c871eb11c2abce55f4595fd2b2d0b7c22afea6c5dcf8df1bb3d6aabe6f3aa6b5f4cdddc2e3bca1d5260b055e9
7
+ data.tar.gz: 070ad9f9fcc2668d9c66628cf158cc9de4d7bb2fc4d8c027adde625a48ad128d10961bc52bd030286c9c2a934e41701f94b1cf54776e74c5c7cd2a90b872b42b
@@ -1,3 +1,3 @@
1
1
  module YandexCaptcha
2
- VERSION = "0.4.3.5"
2
+ VERSION = "0.4.3.6"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -4,6 +4,8 @@ require "minitest/autorun"
4
4
  require "minitest/spec"
5
5
  require "minitest/pride"
6
6
  require "minitest-spec-context"
7
- require "fakeweb"
7
+ require 'webmock/minitest'
8
8
 
9
- require "yandex_captcha"
9
+ require "yandex_captcha"
10
+
11
+ WebMock.allow_net_connect!
@@ -85,50 +85,53 @@ describe YandexCaptcha do
85
85
  end
86
86
  end
87
87
 
88
- # describe "#spam?" do
89
- #
90
- # describe "simple check" do
91
- # it "works" do
92
- # YandexCaptcha::Verify.spam?("фраза").must_equal false
93
- # YandexCaptcha::Verify.spam?("недорого увеличение пениса проститутки").must_equal false
94
- # end
95
- # end
96
- #
97
- # describe "advanced mode" do
98
- # it "works" do
99
- # YandexCaptcha::Verify.spam?(body_plain: "my text", ip: "80.80.40.3").must_equal false
100
- # end
101
- #
102
- # it "with some html" do
103
- # result = YandexCaptcha::Verify.spam?(body_html: "some spam <a href='http://spam.com'>spam link</a>")
104
- #
105
- # result[:id].wont_be_empty
106
- # result[:links].must_be_empty
107
- # end
108
- # end
109
- # end
88
+ describe "#spam?" do
89
+
90
+ describe "simple check" do
91
+ it "works" do
92
+ YandexCaptcha::Verify.spam?("фраза").must_equal false
93
+ YandexCaptcha::Verify.spam?("недорого увеличение пениса проститутки").must_equal false
94
+ end
95
+ end
96
+
97
+ describe "advanced mode" do
98
+ it "works" do
99
+ YandexCaptcha::Verify.spam?(body_plain: "my text", ip: "80.80.40.3").must_equal false
100
+ end
101
+
102
+ it "with some html" do
103
+ result = YandexCaptcha::Verify.spam?(body_html: "some spam <a href='http://spam.com'>spam link</a>")
104
+
105
+ result[:id].wont_be_empty
106
+ result[:links].must_be_empty
107
+ end
108
+ end
109
+ end
110
110
 
111
111
  describe "#get_captcha + #valid_captcha?" do
112
112
 
113
113
  it "works for not valid captchas" do
114
- captcha = YandexCaptcha::Verify.get_captcha
114
+ result = YandexCaptcha::Verify.spam?(body_html: "some spam <a href='http://spam.com'>spam link</a>")
115
+ captcha = YandexCaptcha::Verify.get_captcha(result[:id])
115
116
 
116
117
  captcha[:url].wont_be_empty
117
118
  captcha[:captcha].wont_be_empty
118
119
 
119
- valid = YandexCaptcha::Verify.valid_captcha?(captcha[:captcha], "1234")
120
+ valid = YandexCaptcha::Verify.valid_captcha?(captcha[:captcha], "1234", result[:id])
120
121
  valid.must_equal false
121
122
  end
122
123
  end
123
124
 
124
125
  describe "raises BadResponseException in case of empty result" do
125
126
  before do
126
- FakeWeb.clean_registry
127
+ WebMock.disable_net_connect!
127
128
  end
128
129
 
129
130
  it "check for spam" do
130
- FakeWeb.register_uri(:post, "http://cleanweb-api.yandex.ru/1.0/check-spam", body: "")
131
+ stub_request(:post, "http://cleanweb-api.yandex.ru/1.0/check-spam")
131
132
  proc { YandexCaptcha::Verify.spam?(body_plain: "any text") }.must_raise(YandexCaptcha::BadResponseException)
133
+ WebMock.reset!
134
+ WebMock.allow_net_connect!
132
135
  end
133
136
  end
134
137
  end
@@ -22,5 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "rake"
23
23
  gem.add_development_dependency "minitest", "~> 5.0"
24
24
  gem.add_development_dependency "minitest-spec-context"
25
- gem.add_development_dependency "fakeweb"
25
+ gem.add_development_dependency "webmock"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3.5
4
+ version: 0.4.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Merkulov
@@ -68,7 +68,7 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: fakeweb
71
+ name: webmock
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="