LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-19-2016, 02:29 PM   #1
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Rails V5 and Ruby 2.3.1 - tests completing slowly


I have been going over some old courses on rails which have updated to the new version (5).
I am up to the first section on testing and have come across a strange timing that I cannot explain

So here is my super simple test code:
Code:
require 'test_helper'

class StaticPagesControllerTest < ActionDispatch::IntegrationTest

  test "should get root" do
    get root_url
    assert_response :success
  end
end
As you can see it is a simple test to see if the root_url is returning successfully.
Now when I time the output of this I get:
Code:
$ time rails t
Started with run options --seed 38470

  1/1: [======================================================================================================================================================================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.49690s
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips


real	0m54.209s
user	0m3.450s
sys	0m0.397s
Here we see that the actual test took less than half a second (see 'Finished in' time), but that the whole command took a whopping 54+ seconds to complete

I have tried searching for a reason but I am only able to find optimization options instead of a reason why there is an additional 53 seconds (rounded) to complete the command after the tests have finished.

If anyone can point me in the direction of an answer it would be much appreciated

Please also let me know if there is any other detail to be provided to help with a solution?
 
Old 09-19-2016, 02:54 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,673
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Although I am entirely(!) unfamiliar with "the present situation," I have definitely encountered this sort of [esoteric ...] problem before.

I suspect that your test ... condition encompasses an expectation that is not "entirely fulfilled" by "the entire block." Instead, it is fulfilled by just the first part of it ... which therefore is never actually seen(!). And so, the test block eventually times out.

Your test block should encompass only "the thing that actually is to be tested," not any subsequent response to its success.

The action assert_response :success should only occur if the test outcome is favorable. Therefore, it should follow that block, not be a part of it.
 
Old 09-20-2016, 02:14 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Original Poster
Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
I see where you are coming from, however, no test that I can create has any different results. Also, this test is directly from the course and when I previously used the course on version 4+ of rails I had no issues.

It is as though there is something else running after the test that I am unable to locate
 
Old 09-20-2016, 10:50 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Original Poster
Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
As a little extra, I have removed all tests and still have to wait 53+ seconds for the process to complete Obviously something else is running but I am buggered if I can see what
 
Old 09-25-2016, 01:20 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Original Poster
Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Okee dokee then ... I have found the cause and a work-around which gets me back to practicing

The problem stems from the addition of the following to my Gemfile:
Code:
group :test do
	gem 'rails-controller-testing', '0.1.1'
	gem 'minitest-reporters',       '1.1.9'
	gem 'guard',                    '2.13.0'
#	gem 'guard-minitest',           '2.4.4'
end
The commented out line for guard-minitest has all my tests returning immediately after they are completed I have noted that on the github site
related to the gem that there is mention of some issues and although I tried the suggested solution, I was not able to overcome the extra time issue.

As I do not intend to use guard this is a non-issue for me at the moment but I will continue to follow the solutions to see if I can update this question when a solution exists
 
  


Reply

Tags
rails, ruby, testing



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to install Ruby and Ruby on Rails on CentOS LXer Syndicated Linux News 0 09-15-2014 07:30 PM
LXer: Rails::API strips the fat off Ruby on Rails LXer Syndicated Linux News 0 11-23-2012 09:50 PM
Any issues installing Ruby Gems and Ruby on Rails in Slackware? Lufbery Slackware 8 02-09-2011 07:22 PM
[SOLVED] [Ruby on Rails] backticks don't work under rails. bartonski Programming 1 09-08-2009 04:19 PM
PHP v Ruby/Ruby on Rails Neko_D Linux - General 4 02-08-2007 11:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration