开发者

Tarantula for rails app

开发者 https://www.devze.com 2023-01-02 14:41 出处:网络
I am just trying to get a simple tarantula request working, but finding it difficult without an api. If I have a simple test like tarantula_crawl(self) I get an error like

I am just trying to get a simple tarantula request working, but finding it difficult without an api. If I have a simple test like tarantula_crawl(self) I get an error like

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:inreport_results' tarantula (0.3.3) [v] lib/relev开发者_如何学编程ance/tarantula/crawler.rb:82:in crawl' tarantula (0.3.3) [v] lib/relevance/core_extensions/test_case.rb:8:intarantula_crawl' /test/tarantula/tarantula_test.rb:20: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...]

Further if I try a simple test like:

  • def test_with_login

    post '/login', :email => 'scarshark@gmail.com', :password => 'asdfasdf1'

    assert_response :redirect

    assert_redirected_to '/dashboard'

    follow_redirect! 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>

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.

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. That's why the :success response is returned when you test for it. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消