Coverage for desktop application in Ruby - ruby

I am writing a simple desktop application in Ruby. For testing my choice is minitest.
Now I want to measure test-coverage. In case of Ruby on Rails you can use Simplecov (https://github.com/colszowka/simplecov).
Can it be used with desktop app? If so, how?
(I am newbe in Ruby).

The docs do seem to be written with a bias towards Rails apps, but I don't see anything in there that should prevent you from being able to use Simplecov with any Ruby application, GUI or otherwise. I've used Simplecov for command line apps in the past.
And using minitest should not give you any problems either, based on the section titled "Use it with any framework".

Related

Can I use Ruby with Shoes for GUI for a multiple choice test app?

I'm trying to make a simple multiple choice question app. Is this possible on ruby?
I've tried using shoes but I don't know how to create multiple classes and a GUI that uses them.
I'm also trying to connect all of this to a database.
I'm having trouble in understanding how to connect all of this together.
According to the comments the main problem seems to be with using the mysql gem part.
Gem usage depends on the version of shoes you are using. For green_shoes you should be good with the standard gems, but it is unmaintained. Shoes 3.1 has problems with gems that have C extensions (such as mysql). Shoes 3.2 should work. With Shoes4 you can't install the normal Ruby gems with C extensions as it uses JRuby and C extension support in JRuby is disabled. You have to use different gems to connect to the database, functionality is the same. A starting point might be activerecord-jdbc.

Is it possible to automate installion using Ruby or Watir?

Currently we are installing our setup(.exe file) on daily basis for testing purpose.I want to automate my installation using Ruby or Watir.Is it possible to automate? Please help me how to perform and give your suggestions.
There are many libraries available for Ruby. Watir itself is constrained to the web browser. Although it does have some technology it's built on top of that should allow Windows environment control. Some of the libraries you can try are Win32-autogui, RAutomation, and windows-pr to name a few.
If you are installing for testing purposes, you can use autoit. It will run your installer, and you can handle some unexpected (though anticipated) errors. I wouldn't use autoit for testing, just for setting up to test.

Ruby browser automation

I want to write ruby script which run browser (for example, firefox), open web-addresses, click links, check/uncheck boxes and other stuff. What gem can i use for that?
Selenium / Selenium Ruby is another option and there's Selenium IDE for scripting Firefox.
"It is implemented as a Firefox extension, and allows you to record,
edit, and debug tests."
Check watir and watir_webdriver which is used for automated web browser testing but it can be used for browser scripting from ruby http://watir.com/
you can use the rb-appscript framework to automate macosx
http://appscript.sourceforge.net/rb-appscript/index.html
Its a ruby framework that uses the applescript interfaces to interact with the macos applications.
I'm not sure if there is a gem you can use to install yet but there is are install instructions in the link above.
there is a nice article at http://www.apeth.com/rbappscript/00intro.html that shows how to replace applescript with ruby using rb-appscript
Check out watir, watir-webdriver or firewatir. It's very easy to use especially if you're just starting out. You can check out this quick tutorial on how to set it up, it's extremely easy.
http://webmites.org/watir-automated-tests-for-everyone/

Can I switch versions of Ruby dynamically using RVM?

I'm working on building a GUI for my checkers implementation. I'm utilizing a GUI framework that only works with Ruby 1.8, yet my game engine, which I have packaged as a gem, only works with Ruby 1.9.
I can't change the code for the GUI framework and reworking my game engine to make it compatible with 1.8 is undesirable, to say the least.
I'm using RVM though, and it looks like you can write RVM scripts to change Ruby versions on the fly.
Does anyone have any experience with that or what the script might look like?
You could run it in two processes. Give the GUI a 1.8 process and talk to it via a shared db or an API on the other side. That's how I'd do it. The good part about that is you can have on online version of your game as well because other clients will be able to talk to it as well.
You can't run one app with two versions of Ruby. How do you imagine this?
RVM has an ability to automatically change current ruby when you cd into a directory. Just create in that directory a file called .rvmrc with content like
rvm use 1.8.7

Language in a Sandbox in Rails [duplicate]

This question already has answers here:
How to run untrusted Ruby code inside a safe sandbox?
(4 answers)
Closed 8 years ago.
I've found that there WAS a sandbox gem (created by the guys that made try ruby in your browser but it was compatible only with Ruby 1.8. Another problem is that I cannot find it anymore (it seems they stop serving the gem from the servers...).
So, is there any secure way of running ruby in a sandbox (so you can run it from your browser)?
Or an easy way to run (for example lua/python) in a sandbox (no filesystem access, no creation of objects etc) and be called from Ruby (Rails 2.2)?
I want to make an application like try_ruby even without having a ruby underneath. But it has to be an easy language (I saw there was a prolog in ruby, even a lisp but I don't think they are easy to learn languages...).
So, do you have any suggestions or tips? Or should I just start creating my own DSL in Ruby (if there is a solution in creating a somewhat safe system)?
Thx
I am developing an implementation of a sandbox for ruby based on a modification of the ruby interpreter written in C, I have released recently a functional version of the gem called shikashi (rdoc documentation).
You should try embedding JRuby in the browser.
http://ruby-in-browser.googlecode.com/svn/trunk/evalruby/index.html
The guy who wrote the original gem disappeared, Keyser Söze style:
http://www.rubyinside.com/why-the-lucky-stiff-is-missing-2278.html
I've read that the JRuby gem is more current or maintained, but I've found it buggy so far. Here are some setup instructions:
http://flouri.sh/2009/4/4/how-to-set-up-the-jruby-sandbox
Overall, it looks like Ruby is lacking a solid implementation of this right now :(
I came across This article on hackety.org(dead link) this morning. Maybe it can serve you as a guide into the right direction
Another way is like codepad.org does it (VM isolation and checking the calls)
I am not sure if you want to run any language in a sandbox. But I found that JavaScript has been running as a sandbox language for a long time. The ruby racer project lets you embed the v8 engine in ruby. Hope that helps.

Resources