Skip to content

Fix block and proc definition to work with Ruby 3.0 - #39

Open
JHK wants to merge 3 commits into
samnissen:masterfrom
JHK:deprecated_proc_usage
Open

Fix block and proc definition to work with Ruby 3.0#39
JHK wants to merge 3 commits into
samnissen:masterfrom
JHK:deprecated_proc_usage

Conversation

@JHK

@JHK JHK commented May 6, 2021

Copy link
Copy Markdown

This should fix the following warning in Ruby 2.7, which will become breaking in 3.0:

/var/lib/gems/2.7.0/gems/arachnid2-0.4.0/lib/arachnid2/typhoeus.rb:27: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead

@breunigs

breunigs commented May 7, 2021

Copy link
Copy Markdown

I think this one you missed:

/var/lib/gems/2.7.0/bundler/gems/arachnid2-91b3a8cddc03/lib/arachnid2.rb:112: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead

@samnissen

Copy link
Copy Markdown
Owner

Do tests pass for you? I get:

  1) Arachnid2::Typhoeus#crawl data is available in the cache loads data from the cache
     Failure/Error: use_response(data, &Proc.new) if data

     ArgumentError:
       tried to create Proc object without a block
     # ./lib/arachnid2/typhoeus.rb:61:in `new'
     # ./lib/arachnid2/typhoeus.rb:61:in `use_cache'
     # ./lib/arachnid2/typhoeus.rb:23:in `block in crawl'
     # ./lib/arachnid2/typhoeus.rb:17:in `times'
     # ./lib/arachnid2/typhoeus.rb:17:in `crawl'
     # ./spec/arachnid2/typhoeus_spec.rb:90:in `block (4 levels) in <top (required)>'

  2) Arachnid2::Watir#crawl accepts the options
     Failure/Error: make_request(q, &Proc.new)

     ArgumentError:
       tried to create Proc object without a block
     # ./lib/arachnid2/watir.rb:26:in `new'
     # ./lib/arachnid2/watir.rb:26:in `crawl'
     # ./spec/arachnid2/watir_spec.rb:36:in `block (3 levels) in <top (required)>'

# ...

I had a number of issues getting the tests to run, and need to repair the gemspec. Look out for that if that's helpful

@JHK

JHK commented May 19, 2021

Copy link
Copy Markdown
Author

With the Gemfile in the current project the tests don't work for me. Updating some gems and bundler itself worked. I had a successful test run with this patch:

Finished in 2 minutes 34.8 seconds (files took 2.01 seconds to load)
16 examples, 0 failures

Wasn't sure if I should include the Gemfile.lock patch into this PR. Here would be the diff:

diff --git a/Gemfile.lock b/Gemfile.lock
index 4810802..995f27a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
 PATH
   remote: .
   specs:
-    arachnid2 (0.3.9)
+    arachnid2 (0.4.0)
       addressable
       adomain
       bloomfilter-rb
@@ -16,28 +16,28 @@ GEM
   specs:
     addressable (2.7.0)
       public_suffix (>= 2.0.2, < 5.0)
-    adomain (0.2.3)
+    adomain (0.2.4)
       addressable (~> 2.5)
       logger
     bloomfilter-rb (2.1.1)
       redis
     childprocess (3.0.0)
     diff-lcs (1.3)
-    ethon (0.12.0)
-      ffi (>= 1.3.0)
+    ethon (0.14.0)
+      ffi (>= 1.15.0)
     facets (3.1.0)
-    ffi (1.12.2)
-    json (2.3.0)
-    logger (1.4.2)
-    mini_portile2 (2.4.0)
-    nokogiri (1.10.9)
-      mini_portile2 (~> 2.4.0)
-    os (1.0.1)
-    psych (3.1.0)
-    public_suffix (4.0.3)
+    ffi (1.15.0)
+    json (2.5.1)
+    logger (1.4.3)
+    nokogiri (1.11.3-x86_64-darwin)
+      racc (~> 1.4)
+    os (1.1.1)
+    psych (3.3.1)
+    public_suffix (4.0.6)
+    racc (1.5.2)
     rake (13.0.1)
-    redis (4.1.3)
-    regexp_parser (1.7.0)
+    redis (4.2.5)
+    regexp_parser (2.1.1)
     rspec (3.8.0)
       rspec-core (~> 3.8.0)
       rspec-expectations (~> 3.8.0)
@@ -51,22 +51,22 @@ GEM
       diff-lcs (>= 1.2.0, < 2.0)
       rspec-support (~> 3.8.0)
     rspec-support (3.8.0)
-    rubyzip (2.2.0)
+    rubyzip (2.3.0)
     selenium-webdriver (3.142.7)
       childprocess (>= 0.5, < 4.0)
       rubyzip (>= 1.2.2)
-    typhoeus (1.3.1)
+    typhoeus (1.4.0)
       ethon (>= 0.9.0)
-    watir (6.16.5)
-      regexp_parser (~> 1.2)
-      selenium-webdriver (~> 3.6)
-    webdriver-user-agent (7.6)
+    watir (6.19.1)
+      regexp_parser (>= 1.2, < 3)
+      selenium-webdriver (>= 3.142.7)
+    webdriver-user-agent (7.8)
       facets
       json
       os
       psych
       selenium-webdriver (>= 3.4.0)
-    webdrivers (4.2.0)
+    webdrivers (4.6.0)
       nokogiri (~> 1.6)
       rubyzip (>= 1.3.0)
       selenium-webdriver (>= 3.0, < 4.0)
@@ -81,4 +81,4 @@ DEPENDENCIES
   rspec (~> 3.0)

 BUNDLED WITH
-   1.17.3
+   2.2.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants