狼蛛测试报告undefined方法处理程序

时间:2015-01-20 16:33:59

标签: ruby security web-crawler

我正在使用塔兰图拉爬行我的rails应用程序。我创建了这个简单的测试文件:

require "test_helper"
require "relevance/tarantula"

class TarantulaTest < ActionController::IntegrationTest
  fixtures :all

  def test_tarantula  

    post '/login', :user_username => 'user', :user_password => 'pass'
    assert_response :success

    t = tarantula_crawl(self)
    t.handlers << Relevance::Tarantula::TidyHandler.new
    t.crawl '/'
  end
end

当我跑步时:

rake tarantula:test

我收到了这个错误:

warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.4-compliant syntax, but you are running 2.1.2.
rm -rf tmp/tarantula
/usr/local/bin/ruby -I"lib:test" -I"/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.2.1/lib" "/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.2.1/lib/rake/rake_test_loader.rb" "test/tarantula/**/*_test.rb" 
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.4-compliant syntax, but you are running 2.1.2.
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Run options: 

# Running tests:

 5 of 5 links completed               Crawled 5 links and forms.
Writing results to /beesor/tmp/tarantula
 = 2.23 s
  1) Error:
TarantulaTest#test_tarantula:
NoMethodError: undefined method `handlers' for 1:Fixnum
    /beesor/test/tarantula/tarantula_test.rb:31:in `test_tarantula'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1265:in `run'
    /usr/local/lib/ruby/2.1.0/test/unit/testcase.rb:17:in `run'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:447:in `_run__2214845784260671277__setup__2043950904409813117__callbacks'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `__run_callback'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/testing/setup_and_teardown.rb:35:in `run'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:940:in `block in _run_suite'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:933:in `map'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:933:in `_run_suite'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:663:in `block in _run_suites'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:661:in `each'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:661:in `_run_suites'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:884:in `_run_anything'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1092:in `run_tests'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1079:in `block in _run'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1078:in `each'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1078:in `_run'
    /usr/local/lib/ruby/2.1.0/minitest/unit.rb:1066:in `run'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:27:in `run'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:780:in `run'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:372:in `block (2 levels) in autorun'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:33:in `run_once'
    /usr/local/lib/ruby/2.1.0/test/unit.rb:371:in `block in autorun'

Finished tests in 2.351987s, 0.4252 tests/s, 0.4252 assertions/s.
1 tests, 1 assertions, 0 failures, 1 errors, 0 skips

ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.2.1/lib" "/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.2.1/lib/rake/rake_test_loader.rb" "test/tarantula/**/*_test.rb" ]

Tasks: TOP => tarantula_test
(See full trace by running task with --trace)

我不是为什么当我调用tarantula_crawl(self)方法时它会返回值1

我真的迷失了!!!

提示:我正在使用此tarantula gem,我正在关注github documentation examples

1 个答案:

答案 0 :(得分:1)

再次在GitHub页面上查看示例,区别是真的微妙,但您需要更改:

t = tarantula_crawl(self)

t = tarantula_crawler(self)