简体   繁体   English

塔兰图拉毒蛛的应用程序

[英]Tarantula for rails app

I am just trying to get a simple tarantula request working, but finding it difficult without an api. 我只是想让一个简单的狼蛛请求工作,但没有api很难。 If I have a simple test like tarantula_crawl(self) I get an error like 如果我有像tarantula_crawl(self)这样的简单测试,则会收到类似

1) Error: test_tarantula(TarantulaTest): RuntimeError: 9 failures tarantula (0.3.3) [v] lib/relevance/tarantula/crawler.rb:221:in generate_reports' tarantula (0.3.3) [v] lib/relevance/tarantula/crawler.rb:227:in report_results' tarantula (0.3.3) [v] lib/relevance/tarantula/crawler.rb:82:in crawl' tarantula (0.3.3) [v] lib/relevance/core_extensions/test_case.rb:8:in tarantula_crawl' /test/tarantula/tarantula_test.rb:20:in `test_tarantula' 1)错误:test_tarantula(TarantulaTest):RuntimeError:9个失败的狼蛛(0.3.3)[v] lib / relevance / tarantula / crawler.rb:221: generate_reports' tarantula (0.3.3) [v] lib/relevance/tarantula/crawler.rb:227:in report_results的塔兰图拉毒蛛(0.3.3)中[v] lib / relevance / tarantula / crawler.rb:82:在crawl' tarantula (0.3.3) [v] lib/relevance/core_extensions/test_case.rb:8:in塔兰图拉毒蛛crawl' tarantula (0.3.3) [v] lib/relevance/core_extensions/test_case.rb:8:in `test_tarantula'中

2 tests, 0 assertions, 0 failures, 1 errors Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ru...] 2个测试,0个断言,0个失败,1个错误命令以状态(1)失败:[/usr/bin/ruby1.8 -I“ lib:test”“ / usr / lib / ru ...]

Further if I try a simple test like: 此外,如果我尝试一个简单的测试,例如:

  • def test_with_login def test_with_login
    post '/login', :email => 'scarshark@gmail.com', :password => 'asdfasdf1' 发布'/ login',:email =>'scarshark@gmail.com',:password =>'asdfasdf1'
    assert_response :redirect assert_response:重定向
    assert_redirected_to '/dashboard' assert_redirected_to'/ dashboard'
    follow_redirect! follow_redirect! t = tarantula_crawler(self) t.crawl '/' end t = tarantula_crawler(self)t.crawl'/'end

I get 我懂了

2) Failure: test_with_login(TarantulaTest) [/test/tarantula/tarantula_test.rb:25]: Expected response to be a <:redirect>, but was <200> 2)失败:test_with_login(TarantulaTest)[/test/tarantula/tarantula_test.rb:25]:预期响应为<:redirect>,但为<200>

I believe it has something to do with my post request. 我认为这与我的发帖要求有关。 My understanding is it should go to localhost:3000/login and enter the email and password fields submitting the page, but i get a 200 status code instead of redirect. 我的理解是,它应该转到localhost:3000 / login并输入提交页面的电子邮件和密码字段,但是我得到的是200状态代码而不是重定向。

Any help on learning how to use tarantula better would be great, thanks! 感谢更好地学习如何使用狼蛛的任何帮助。

What is your method definition for "login"? 您对“登录”的方法定义是什么? It looks to me that the '/login' is just a display of login form. 在我看来,“ / login”只是显示登录表单。 That's why the :success response is returned when you test for it. 这就是为什么在测试时返回:success响应的原因。 What you need to do is to open your login page, look at your 'form' action to find out what the real action is being called by the page, and then replace '/login' with that action in order to pass the test. 您需要做的是打开您的登录页面,查看您的“ form”操作以找出该页面正在调用的实际操作,然后用该操作替换“ / login”以通过测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM