We're using Jenkins as a CI server, and without any pattern that I can determine, sometimes the request and routing specs fail - only on the CI server though, never on the development machines.
It's currently using Selenium as the Capybara driver, and I've seen problems with that configuration before, but the routing specs failing sporadically is baffling me. Can anybody make any suggestions for things to check?
Update:
I have a single failure now happening sporadically:
NoMethodError: undefined method `to_a' for false:FalseClass
(in /blah/app/assets/stylesheets/application.css.scss)
/home/paul/.rvm/gems/ruby-1.9.3-p374/gems/sass-3.2.5/lib/sass/selector/simple_sequence.rb:153:in `block in to_a'
This is definitely the same error message I've seen before, but I've never seen the line before... investigating.
Related
In the process of upgrading our application to Rails 5, I'm seeing some really baffling behavior with Javascript XHR requests during our Capybara-based feature specs.
Here is the code (CoffeeScript) in question:
$.ajax(
url: "/foobar"
).done((_data, _status, _jqXhr) ->
# *snip* all is well
return
).fail((jqXhr) ->
# This should be 422 but is 0 instead
status = jqXhr.status
console.log("AJAX request returned with error code #{status}")
return
)
Everything works when using a Rails server in development mode and a real browser (i.e. Chromium or Firefox)
Poltergeist/PhantomJS reports status 0
capybara-webkit also reports status 0
Selenium Webdriver (geckodriver) correctly reports status 422
The versions of Poltergeist (1.11.0) and PhantomJS (2.1.1) stayed the same. During gem updates to Rails 5, Capybara was upgraded from 2.10.2 to 2.12.0, but I also upgraded the old branch to Capybara 2.12.0 without anything breaking, so it's likely that this isn't the problem either.
I was able to bring up the fabulous PhantomJS developer console and, in the "network" panel, saw that the status code was, also in test mode, 422 as expected, which means that the problem must really be somewhere in JavaScript-land.
Note that this is not a cross-origin request and the request is not aborted (the usual causes for status code 0). And since it works when in development mode, I'm a bit baffled who might be the culprit for this behavior.
I also tried looking at other properties and arguments to the callback function and whether I could find the status code in some other property, but haven't had any luck with that.
I am developing a backend service using meanjs.org scaffold. I have written around 1700 tests and they were working fine. But now, tests just started to act weird. Suddenly a lot of tests fails with error:
Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.
Callback done() is being called so this is not the problem. The tests were working all the time but now they don't want to work any more. I tried to drop the mongo database, to stop and start mongod process but nothing works.
Did anyone have the same problem of tests not working from time to time?
I answered a similar post maybe it will be helpfull, as the solution is the same.
mocha timout
The problem is that your connection to mongodb probably exceeds the 2000ms timout from mocha.
I used to program with Ruby on rails and I have just started SailsJS.
With rails when I had an error in my backend, it didnt kill my server. I used to have a nice error displayed in my web browser and I even used the gem better error to have a live console displayed in my webbrowser when an error occured.
How can I prevent the server to shut down everytime there's an error in Sails JS ?
Is there a way to have a nice way to display errors with Sails (with the live console in the web browser, just like with the gem better errors) ?
For running your server despite errors, take a look at foreverjs. However, I'd advise you to be defensive about your programming and properly handle errors.
I am working on a very small app, it is a RabbitMQ notification system. It triggers an API call when a state changes. That part is fine and I believe is working correctly. What I am having problems is testing the notification part, I am using rspec and I do not have a way to test the notification, or do not know of a way. I have heard of mocking the RabbitMQ call in the test, but I do not know what that means specifically. Can anybody explain? thank you.
For testing app working with rabbitmq you can try evented-spec or moqueue.
For example, stubbing connect to AMQP (in moqueue):
before(:each) do
reset_broker
producer.stub(:connect).and_return(mock_exchange(:topic => "common"))
end
Other examples you can see here
We're working on a Rails 3 project and testing using Capybara/RSpec. The problem is that the staging and production environment differ somewhat. Sometimes, the tests will run fine and there will be no problem on staging, but will break in production.
An example is when we added a middleware that uses Rack::File to send files. The application sent the header 'X-Sendfile' which works under Apache but Nginx expects 'X-Accel-Redirect'.
I'm looking for the best way to run a battery of tests when we push to production. Has anyone done this? Ideally the tests should not be run on the production server itself.
The tests would basically cover the core features of our product and would be different from the tests we are currently running.
Thanks a lot
What I ended up doing is have another set of RSpec test in a production_test environment that has read-only access to the database. I use the capybara-webkit driver and each test starts by visiting the complete URL for that test.