rails integration test logging - ruby-on-rails

Is there any way to see what is happening during an integration test?
When I test my application manually, I can look at the webserver logs to see what parameters are sent, which queries are run and can use puts to log variables. Is there any way to do this during an integration test? I found /log/test.log but it doesn't show much.
Thanks
Walter

You could use this in your test file to mimic a console.log of a javascript program. It's output will be available in log/test.log
Rails::logger.debug "The value of x at this time is " + x

Related

grails 3 functional test plugin

When I use grails 2, I use the functional plugin to create the function test and I use Rest-client-builder to send post and get request. The function test itself can start up the server.
However, When I upgrade to grails 3. the built in geb framework can help me create the function test. However, I don't know how i can send the post and get request. And the function test itself can not start up the server. I have to run-app first and then run the test. Does anyone know what should I do function post/get test via grails 3?
Thanks very much
And the function test itself can not start up the server.
You haven't described the details of what you are doing so I don't know why it might not be working for you, but it certainly can be made to work. You probably want to create integration tests and mark them with #Integration. We have a lot of examples in the project at https://github.com/grails/grails3-functional-tests. Look in https://github.com/grails/grails3-functional-tests/tree/master/app1/src/integration-test/groovy/functionaltests. A simple example that should be easy to read is at https://github.com/grails/grails3-functional-tests/blob/master/app1/src/integration-test/groovy/functionaltests/HomeSpec.groovy.
I hope that helps.

Test website by iterating every page and report which page produces error

Is there a plugin/extension/gem that iterates every page in a Rails app/website, to see if it renders properly, and returns a report with errors? Or am I over testing?
it seems what you are looking for is a smoke test gem, just google it and find whether that is something suite your need. And i find one here.
https://techblog.livingsocial.com/blog/2013/09/19/smokescreen-smoke-tests-for-ruby/

How do I take input using the gets module when using Frank and cucumber?

Background Info
I am currently using Frank with Cucumber to automate testing on an iOS app.
Everything works as it should, I can Frankify the app, run it, etc. Symbiote works as it should, as does Cucumber. I've already written many testing steps that work exactly as I intended. All my steps are written in Ruby.
Problem
My problem is that, as everything works as it should, I want the ability to have a step that takes input. I was thinking I could just use the gets module, but for some reason it doesn't wait for any user input and I only see the prompt works after the feature fails.
Here's the code for that step:
When(/^I verify the device via text$/) do
print "What's the Verify link?"
link_to_app = gets.chomp
sleep 20
press_home_on_simulator
sleep 1
# for this next part you're gonna need this link:
# https://github.com/moredip/Frank/issues/177
# It's used to go out of the app and open an html doc in safari
html_format = "<!DOCTYPE HTML><html><head><title></title><meta http-equiv=\"refresh\" content=\"0;URL='#{link_to_app}'\"></head><boßdy></body></html>"
html = html_format
require 'tempfile'
file = Tempfile.new(['launch', '.html'])
begin
file.write(html)
%x( /usr/bin/open "#{file.path}" -a "iPhone Simulator" )
ensure
file.close
file.unlink
end
sleep 2
end
This basically is meant to take a link that can only be taken from a SMS text and allow me to automatically go to that link in the simulator (this is used for account verification in the app).
As I said before, instead of the prompt stopping and waiting for any input, it simply skips past.
Question
Basically, how can I, while using Frank and Cucumber, make the gets module work and take input for me?
Thank you
Try using STDIN.gets, rather than plain old gets

Fitnesse - runner process not starting

I have a test in fitnesse which used to work, but when I got into work today the test did not start at all. As soon as I press test I get the "0 errors 0 warrings..." text on the top of the test. Looking in the source control software, I can not find any changes to the test, or to anything related to it. I have noticed that the runner process does not start when I run the test. Other tests seem to work fine, and I can copy the tables from the test which is not working into an other test and everything is fine. Any ideas on what could be wrong?
My standard answer in this situation is, "have you checked your classpath?"
I say this, as typically when this sort of thing happens, it is that the !path doesn't point to the stuff you need, whether it be FitNesse.jar or your own custom code.
Also, do you get an output page where you can check the classpath? i doubt it, but that can help diagnose classpath issues.

Why is my functional test getting the meta tag http-equiv='refresh' and then quitting?

When I run a simple functional test to get (for example) the users/signIn page, I'm getting this:
<html><head><meta http-equiv="refresh" content="0;url=https://localhost/index.php/users/signIn"/></head></html>
and then the functional test just stops. It happens in other functional tests too, but not on every request. Other tests will run fine, then when it gets to a certain request in the test, it will get that response (with the requested URL in the content attribute), and stop.
Any ideas on why this might be happening?
These functional tests used to work, but I just got this project back from another development company and I don't have an idea of where to start looking for the changes. Of course I can do diffs on the files with the version control, but I don't know where to start. Thanks for any leads!
Argh, found it quicker than I thought.
The SSL filter was turned on, and needs to be disabled for the test environment. They had removed the test environment from app.yml.
test:
disable_sslfilter: true

Resources