Ruby Cucumber - Running using Cucumber::Runtime(config).run! - 'Officially supported'? - ruby

I have a test farm I'm making that can run Cucumber tests and will take the results and write to a database.
Instead of using backticks to run from the command line I'm considering this, which seemed to work rather well from an irb prompt:
config = {paths: ['.\\scenarios\\my.feature'], filters: [], tag_expressions: ['#open_print_pdf'],tag_limits: [], profiles: ['example'], require: []}
Cucumber::Runtime.new(Cucumber::Configuration.new(config)).run!
I like that I then get some objects that I can interrogate to write things I need to the db like:
steps
feature and scenario name
etc.
Before I considered this I was going to run using the JSON formatter, save the file, and then parse it, make it a hash and send to db.
Is the only supported way to run it through the command line. I find it useful to programmatically run it so I have everything I need without needing to do needless IO.
So, is running using Cucumber::Runtime(config).run! officially supported?

Related

How to reduce logs from database cleaner in ruby application

Here is my ruby spec_helper for rspec:
As you see I'm using database cleaner because I'm writing tests using the DB.
However, I get all this nonsense in my console output:
Is there a way to supress some of this output? Again remember, I'm not in RAils so I can't simply do:
config.logger.level = Logger::ERROR

Store data in selenium webdriver

Im looking for a way to store data in selenium for use in future tests.
Im using jenkins, maven + selenium and testng.
How can i store some data, lets say i want to run test, get some data from website (weather forecast). Store it somewhere and next day run test to check if forecast match todays weather.
I can store it in txt file, and parse by regex but im sure there is better way to do it?
You have to consider what "selenium webdriver" is in this context. It is a Java app. It "exists" only when it is running. Once the run stops, it is purged from memory, including all data it held. If you are using JUnit or TestNG (as you specified), then this data is purged even more frequently: after every the class.
To accomplish what you are asking, you will need something external to your tests. You can certainly utilize a txt file as you suggested. A spreadsheet might do for your purposes. Most applications utilize an entire database.
You also mentioned Jenkins. This will make the external storage a more interesting problem, as Jenkins often purges the current working directory before each run.

Start Embedded MongoDB with RSpec?

Is there such thing as an embedded version of MongoDB suitable for use with RSpec, that can be started with a suite of tests?
In JavaLand, where I normally live when I'm not vacationing in the United States of Ruby, we are in the habit of starting portable embedded versions of database servers when we run tests, such as this Java-embeddable MongoDB.
Is there an equivalent for Ruby? Or do we always expect developers to have a local MongoDB running?
Currently, our replica set tests use a MongoConfig test tool to bring up RS members:
https://github.com/mongodb/mongo-ruby-driver/blob/1.x-stable/test/tools/mongo_config.rb
Check out this method for how to use it:
https://github.com/mongodb/mongo-ruby-driver/blob/1.x-stable/test/helpers/test_unit.rb#L38-L62
We don't use it for our non-replica set tests, but I don't see why you couldn't use it yourself. I also don't see anything about Rspec in particular that would make this difficult either.

Mongo ruby driver: Running/getting mongostats/query Graphs

I am using mongo-ruby-driver, I want to get stats/query graphs to show for Mongo. But don't how can I get Mongostats/Graphs via mongo-ruby-driver.
Any help is highly appreciated.
Rather than righting your own, you can just set up MMS and use that instead.
But, if you do want to pull the data directly, you can do that too - anything that can be run from the shell can be run from the driver. So, for example, to run the stats() command, which translates on the command line to:
db.runCommand({dbstats : 1})
And so, just follow the guidelines at the top of the ruby driver FAQ - the first one includes how to run any of the commands via the driver.

Formatting shell output into structured data?

Are there any means of formatting the output of shell commands to a structured data format like JSON or XML to be processed by another application?
Use case: Bunch of CentOS servers on a network. I'd like to programatically login to them via SSH, run commands to obtain system stats and eventually run basic maintenance commands. Instead of parsing all the text output myself I'm wondering if there is anything out there will help me return the data in a structured format? Even if only some shell commands were supported that would be a head start.
Sounds like the task for SNMP.
It is possible to use puppet fairly lightly. You can configure it to run it's checks only on what you want to check for.
Your entire puppet config could consist of:
exec { "yum install foo":
unless => "some-check for software",
}
That would run yum install foo but only if some-check for software failed.
That said there are lots of benefits if you're managing more that a couple of servers to getting as much of your config and build into puppet manifests (or cfengine, bcfg2, or similar) as possible.
Check out Nagios (http://www.nagios.org/) for remote system monitoring. What you are looking for may already exist out there.

Resources