Cuke4Duke on Grails - ruby

Ok, so I've got a grails app here.
On a previous project we used cucumber alongside grails with our step definitions working in ruby.
It was ok, but it would be nice if we could write our defs in groovy, same scripting language we're using everywhere else.
If anyone's ever done it before, or knows how I could get it running, let me know. I've seen a few plugins that don't appear to work with 1.3.7
Is there not some way for me to just put jruby, cuke4duke in the BuildConfig dependencies and just write a scripts/Cucumber.groovy to invoke it?

https://github.com/thetrav/grails-cucumber
Looks like someone else had already built a cuke4duke plugin, my modification causes it to fail on errors and allocates a large permgen space for it to use.
We're now using groovy step definitions (just put .groovy files in ${project_root}/features/step_definitions) and geb to drive the browser, all seems to work ok

Related

Using RJB to call scala code from Ruby

I'm about to start rewriting bits and pieces of our Rails app that do the relatively heavier number crunching in Scala for speed. The plan eventually is to have all the processing done by a scala daemon running in the background and just use Rails for the frontend, but in the meantime I want to be able to rewrite bits and pieces of the slower code now and call them synchronously from Ruby.
For this reason I've been looking at RJB (I can't use JRuby) in the hope that I can use it with scala too, seeing as it compiles to Java Bytecode in the end anyway. I've had a google around to see if I can find someone who's already done this or similar but not come up with anything.
My inital, naive attempt was to just compile and package a test scala class into a jar and try loading it using Rjb like this:
Rjb::load("#{Rails.root}/lib/scala/scala-tester-1.0-SNAPSHOT.jar")
MyClass = Rjb::import('com.mydomain.MyClass')
But this just results in a java.lang.NoClassDefFoundError: com/mydomain/MyClass.
I tested importing a standard java class, which works fine, so I tested importing scala.Int, which resulted in another NoClassDefFoundError. This sort of suggests to me that the problem may lie in the scala libraries not being included on the classpath? But it's quite a while since I've had to deal with the endless headaches of Java classpaths so I'm pretty rusty at diagnosing and fixing this kind of problem.
So, has anyone done this? If not, does my hunch sound correct? Any suggestions? Or is there something I'm not thinking of that will mean this approach won't work at all?
EDIT: realised I'd been using slightly incorrect syntax. Have now managed to get it to load my test jar using syntax like this:
Rjb::load(classpath = "#{Rails.root}/lib/scala/scala-tester-1.0-SNAPSHOT.jar", jvmargs=[])
but fail with a different java.lang.NoClassDefFoundError: scala/ScalaObject which suggests it definitely is failing to load the scala libraries.
I got it to work with the following:
RJB_LOAD_PATH = ["#{ENV['SCALA_HOME']}/lib/scala-library.jar", "#{Rails.root}/lib/scala/scala-tester-1.0-SNAPSHOT.jar"].join(File::PATH_SEPARATOR)
RJB_OPTIONS = []
Rjb::load(RJB_LOAD_PATH, RJB_OPTIONS)
Going to put this code in an initializer but it still seems a little hacky and would be glad to hear if anyone has any neater suggestions.

Firefox plugin dll dependency on the filename

my current work tasking requires creating a firefox plugin. I've done this relatively easily on Linux but porting to windows has exposed a peculiar problem. To do the port, I refactored the basic windows example given in the mozilla source tree. I did this operation slowly and methodically, testing as I went. Aside from the occasional OS dependent glitch everything seemed to be going fine until I finally changed the output name of the plugin dll. So, instead of creating a dll called npbasic.dll, the filename was fubar.dll. This immediately caused the plugin to stop working: it did not get picked up in Firefox about:plugins. Changing the filename back to npbasic.dll allowed the firefox plugin tab to "see" the plugin again.
Is anyone aware of an aspect of dll linking/functionality which could be causing this observed dependency?, any help or pointers would be greatly appreciated.
Well, I've done some more research and it's clear that my approach of painstakingly refactoring the example plugin was flawed, the best strategy is to use something like firebreath, as described here : How to write a C++ FireFox 3 plugin (not extension) on Windows?

Scala Eclipse IDE suddenly ignoring breakpoints

I've been using Scala 2.8RC1 and Scala Eclipse plugin for 2.8 RC1 happily for a few days. However, last night after adding a couple jar files to my environment (apache http client jars) the debugger just stopped stopping at breakpoints in scala code.
Java code stops fine at breakpoints. I tried creating a new mimimal scala app breakpoints don't stop. I've tried switching to sun-jre-1.6.0.20 from the openjdk-1.6.18 I had been using. I've switched to the scala 2.8 nightly and also eclipse plugin for scala nightly builds. No luck.
I would greatly appreciate ideas for fixes. Rather frustrating as the initial experience with 2.8 was really great.
https://www.assembla.com/spaces/scala-ide/tickets/2731-breakpoints-against-objects-in-default-package-are-not-honoured
Says that scala eclipse plugin doesn't stop at breakpoints if you're class is in the default package (no package)
Adding a package and moving my class to it - make the debugger start working again.
It's possible that you've discovered a bug in the Scala tooling for Eclipse. The best place to take the issue is the scala-ide-user list here,
http://groups.google.com/group/scala-ide-user
If you're already sure that you've found a bug you can find instructions for opening a ticket here,
http://scala-ide.assembla.com/wiki/show/scala-ide/Bug_Reporting
I've just encountered this problem. Code is not in default package. I'm getting a warning about missing line numbers, but apparently that bug has been fixed and I can ignore the warning, per https://scala-ide-portfolio.assembla.com/spaces/scala-ide/tickets/1000155-its-impossible-to-add-line-numbers-debug-info-to-compiled-project#/activity/ticket:
It did seem to stop at breakpoints in the main file, though.

What is the ruby test tool called that 'breaks' your code to see how tight your tests are?

A wee while ago I ended up on a page which hosted several ruby tools, which had 'crazy' names like 'mangler' or 'executor' or something. The tool's job was to modify you production code (at runtime) in order to prove that your tests were precise.
Unfortunately I would now like to find that tool again, but can't remember what it was called. Any ideas?
I think you're thinking about Heckle, which flips your code to make sure your tests are accurate. Here:
http://seattlerb.rubyforge.org/heckle/
Maybe you're thinking of the Flay project and related modules:
http://ruby.sadi.st/Ruby_Sadist.html
Also you can try my mutant. Its AST based and currently runs under MRI and RBX in > 2.0 mode. It only has a killer for rspec3, but others are possible also.

Avoiding Groovy/Grails internals while debugging in IntelliJ Idea

I'm using IntelliJ Idea 8.1.2 for Grails development. The dynamic nature of Groovy is giving me a hard time debugging my code: I keep ending up in the internals of Groovy/Grails, i.e. CachedMethod, ExpandoMetaClass or the like.
Is there a way for example to tell the Idea debugger to completely skip the Groovy/Grails internals while debugging and only make steps in my own code? I did notice that there is a configuration option named "Do not step into specific Groovy classes" in Debugger > Groovy but so far I've noticed no difference.
If not, what is your workaround or how do you cope with the situation? Any help would be greatly appreciated.
File->Settings->Debugger->Stepping
Do not step into the classes...
Yeah, I suffer with this annoyance, too, and I don't have a good solution. My workaround once I'm lost in Groovy/Grails code is just to figure out where I should be back in my code, set a break point there, and hit Continue.

Resources