Sikuli IDE can't import cucumber gem in JRuby? - ruby

I'm using SikuliX IDE 1.1.2 (with JRuby support enabled), and I'm trying to get cucumber working from within the Sikuli IDE.
I have found this article which just covers what I need:
http://www.jmest.org/wp-content/uploads/JMESTN42350420.pdf
I have also found the related github and I am now trying to run a sample script in Ruby that I found here: https://github.com/rssdev10/sikulix-ide-templates/blob/master/examples/libreoffice-writer-test/test-cucumber.sikuli
But when I try to run this script from the Sikuli IDE, I get:
LoadError: no such file to load -- cucumber/rspec/disable_option_parser require at org/jruby/RubyKernel.java:939 require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54 start_cucumber at C:/Users/at080olimath/Downloads/sikulix-ide-templates-master/examples/libreoffice-writer-test/test-cucumber.sikuli:31 cucumber_test at C:/Users/at080olimath/Downloads/sikulix-ide-templates-master/examples/libreoffice-writer-test/test-cucumber.sikuli:56 SikulixCucumber at C:/Users/at080olimath/Downloads/sikulix-ide-templates-master/examples/libreoffice-writer-test/test-cucumber.sikuli:62 <top> at C:/Users/at080olimath/Downloads/sikulix-ide-templates-master/examples/libreoffice-writer-test/test-cucumber.sikuli:67
[error] script [ test-cucumber ] stopped with error in line 31
[error] LoadError ( (LoadError) no such file to load -- cucumber/rspec/disable_option_parser )
On a Google Drive link, I was able to find a .jar file which contains all the gems needed (cucumber etc.), but the archive is old (2014) and contains a beta verison of the Sikuli IDE:
https://drive.google.com/drive/folders/0Bwx0cbtdU5K6STg2T0l5UWlIRXc
As per my understanding, I would need a way to build the sikulix.jar with the Cucumber gem included... But I cannot manage to figure out where to get started.
On this documentation page, I can also find that this is possible to include cucumber in sikuli.jar:
https://github.com/RaiMan/SikuliX1
If you want to experiment with the special JRuby support (rSpec,
cucumber, ...) you have to look into the modules JRubyAddOns and
JRubyGem. Both have to be built manually if needed (not contained in
the local developement build).
While I was able to find the JRubyGem, I am unable to find the JRubyAddOns anywhere... And I don't know what to do next :(
How should I proceed to get cucumber working from within the SikuliX IDE 1.1.2?
Thank you for your help

I think stock Cucumber Gem has C-dependencies that won't execute VM-side for Jruby. This here: https://rubygems.org/gems/cucumber-jvm/versions/2.0.1-java might be more what you're looking for. Good luck!

Related

Can a ruby gem/module be added just like a java jar file?

I use Eclispse Kepler with DLTK plugin for ruby. I am unable to "require" nokogiri module because it cannot be found by eclipse. I tried some gem install command from some website and that did not help. Now, I don't want to use commandline until I first master Ruby programming.
I learned that I can add java jars to my project by creating a lib folder, copying jars to that folder and then adding them all to the build path. So easy, right ?
Can I do the same thing for ruby gems and modules ? Ideally, I'd like to use only the IDE for this instead of using commandline and complext install scripts.
Please help.
If this gem already installed with all dependencies, then you can add it with simple require command:
require "/path_to_gems/gem_name/lib/gem_name"
In my case the command is:
require '/Users/yukke/.rvm/gems/ruby-2.1.1/gems/nokogiri-1.6.1/lib/nokogiri'
Otherwise you can try to require rubygems first:
require "rubygems"
require "gem-name"
I would suggest maybe using a different IDE with better Ruby support, such as Aptana, which is Eclipse-based but has a lot of additional addons to support Ruby development. You can install Ruby gems in it on the start page, or through the integrated terminal.
If you run the command gem which bundler you will see the folder gems are installed on your system.
You can copy executables there but it's highly recommended you use gem install on the command line.
I have find the answer to this question. I not sure if this is the best way to do it, but it works for me. Pro developers, can you please review this answer ? So, for now let me give quick guide for this.
1 - Install Eclipse DLTK plugin for Ruby as suggested here - Preferred Ruby plugin for Eclipse?
See the answer with photo, by James.
2 - Next, lets pick a random gem such as nokogiri and download it from rubygems.org. The file name of the Gem tells you which OS its meant for. I use windows 7 64bits. So, I take version with x64-mingw32. Here is a sample list of downloads:
1.6.4.1 November 7, 2014 java (2.37 MB)
1.6.4.1 November 7, 2014 x64-mingw32 (2.86 MB)
1.6.4.1 November 7, 2014 (8.81 MB)
1.6.4.1 November 7, 2014 x86-mingw32 (3.91 MB)
1.6.4 November 5, 2014 java (2.37 MB)
Show all versions (271 total)
3 - AFAIK, eclipse cannot use the gem file as is. You need to unpack it first. Lets say you kept the gem file in c:\RubyGems\extras, and you want to unpack it there itself.
open windows cmd > cd into the above directory > gem unpack nokogiri-1.6.4.1-x64-mingw32.gem > press enter !!!
Now, your gem will be unpacked into a folder nokogiri-1.6.4.1-x64-mingw32.
4 - Locate the nokogiri.rb file inside the unpacked folder. Its in the lib folder.
Copy the full path of this folder - c:\RubyGems\extras\nokogiri-1.6.4.1-x64-mingw32\lib. We need this for eclipse.
5 - Eclipse > create new ruby project > right click project > build path > configure build path > libraries tab > add external source folder > enter the path from step 4 > Ok > ok. You can now use the gem in your project.
6 - Testing if the steps work. Use the code in your project !
require 'nokogiri'
puts "Chenqui ! It is work!!!"
If the message prints without error, then you are a success ! To see the error you get when the required modules can't be found, add something like this require 'restclient'.

Using JRuby+Sikuli on Windows

This video shows JRuby+Sikuli working on Windows 7 or higher. There we have to require "java"; require "sikuli".
So I've installed SikuliX using sikuli-setup.jar and did some practice in Sikuli IDE.
However the \jruby-1.7.15\bin\gem install java gives java requires Ruby version >= 2.1.0., since the latest JRuby installer is jruby 1.7.15 (1.9.3p392), so I had to ... install-fjava.
Then I had to manually set ENV variable SIKULI_HOME, but now I have this error:
irb> require "sikuli"
LoadError: Failed to load 'C:\Users\admin\Downloads\nakilon\sikuli/sikuli-script.jar'
Is Sikuli installed?
And yes, I have no sikuli-script.jar in my SikuliX folder.
So what is the proper way to make JRuby+Sikuli[X] to work on Windows 7/8?
UPD:
I just realized, that gem install sikuli installs a 2 years old stuff, that isn't a Sikuli X.
So I did a hack -- renamed sikuli-ide.jar to sikuli-script.jar.
Trying to execute some lines from that video: screen = Sikuli::Screen.new goes fine.
But since script = org.sikuli.script.SikuliScript.new gives:
cannot load Java class org.sikuli.script.SikuliScript
I checked github sources -- there is really no SikuliScript class, so now I'm lost (
Current official JRuby gem way
This question posted as GitHub issue, with solution
Google Drive shared folder with stack of files that seems to work for me
Checksums of files in it:
MD5 (jruby_windows_1_7_15.exe) = 61600abdb47177dc50c4ec887dc6c3f1
MD5 (sikulixsetup-1.1.0-Beta4.jar) = 7b836f4dad2e6817fd599f91cb1b9e7f
MD5 (sikulix-1.1.0.3.gem) = e1083cf09b55c917b62a34cc45cdded0
Google Drive doesn't allow to share .exe, so you'll see only two files.

Unable to run cucumber test on intellij idea 12

I have followed all necessary steps an installed ruby and bundle.
which ruby
/Users/v-bpurkayastha/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
which gem
/Users/v-bpurkayastha/.rvm/rubies/ruby-1.9.3-p194/bin/gem
but on intellij idea while running it say
Cucumber support disabled because 'cucumber-rails' gem or Cucumber Rails plugin
are missing. Install gem and add it to the Gemfile
On run configuration it says
No cucumber gem found in sdk
even after selecting sdk.
Please help me out.
many thanks,
I have had a similar issue with my IntelliJ Idea 14 where it was incorrectly assigning the path for Gems bin directory under project settings' SDK for Ruby.
I changed it to /.rvm/gems/ruby-2.1.4/bin and when running the cucumber tests it picks it up and run the acceptance tests.
I had the same problem. When I viewed the module settings it did show the cucumber gem in the list. I clicked on the cucumber gem and clicked 'update gems'. It did find a newer version of the cucumber gem (1.3.15 instead of 1.3.14) and updated it. I was able to run my cucumber tests after that with no error.
For my version (IntelliJ 2018.3 Ultimate), since my project is consisted of java modules as well as cucumber test module (in the "test/func" folder). I had to
Set up ruby and its gem
Import the test folder as a module
Project Setting -> Modules, add a module by import existing source
Add the Ruby SDK to that module

Building CompassApp (jruby app) executable from source on Windows

I would like to build the executable of CompassApp, a GUI application that lets webdesigners compile stylesheets by using SASS and Compass without using the command line.
The source can be found on GitHub here: https://github.com/handlino/CompassApp.
CompassApp is a an application developed in Jruby.
From the GitHub webpage of the project:
If you want to build your own copy, you will need JRuby and rawr
I am using Windows 7 as operating system for my webdesign projects. I never built a jruby app from source. It seems on linux it's easier to install the required things, anyway i'm using Windows now.
First i cloned the GitHub repository.
Then i installed jruby.
Now i should install rawr (https://github.com/rawr/rawr)
It seems that rawr also requires javac and rake
I saw that rawr and rake are 2 ruby gems.
So how do i install those 2 ruby gems for jruby on Windows?
And how do i build CompassApp from source after i have everything i need?
I would need a step by step guide from the install of the requirements
to the build of the application.
(i never used jruby in the past).
If someone of you develops apps in jruby i think that can help me easily.
I thank you in advance.
#Fabio Hi, we made Compass.app and Fire.app :-)
It is easy to build Compass.app on OS X or Linux. We have a (almost) step by step guide about building Fire.app on the GitHub wiki and it can be applied to Compass.app too: https://github.com/handlino/FireApp/wiki
We have never tried to build it on Windows, and do not think it can be done easily.
I'm trying to do a similar thing, but in my case only package the gems in a self-contained executable jar. the docs are not very descriptive and some are outdated.
I tried rawr but managed to get further with warbler
here's what I did: I created a folder named jrcompass and installed compass into it:
c:\test\jrcompass>%JRUBY%\jruby -S gem install compass -i .
I installed warbler and then ran the warble command in that folder:
C:\test\jrcompass>c:\apps\jruby\bin\jruby -S warble
that created a ~20MB jar file named jrcompass.jar which is farther than I got with rawr.
now I'm trying to execute the jar with:
C:\test\jrcompass>java -jar jrcompass.jar
and I get the following error below. I hope that this will help you make progress. please let me know if you figure it out.
Gem::LoadError: Could not find compass (>= 0) amongst [rake-0.9.2.2]
to_specs at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb:247
to_spec at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb:256
gem at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems.rb:1231
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/jrcompass/bin/compass:22
load at org/jruby/RubyKernel.java:1046
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/META-INF/main.rb:1
require at org/jruby/RubyKernel.java:1027
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/META-INF/main.rb:1
(root) at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1

Cucumber with Ruby: Can it be used from a gem?

I'd like to develop some reusable step definitions and scenario outlines for Cucumber in Ruby.
I've scoured the Cucumber wiki but there seems to be no info on use of Cucumber with Ruby gems.
Is there support for execution of a feature from an installed Gem?
Or would a user have to manually change to the gem installation directory and explicitly referenced the feature(s) to run from there?
If I understood your question correctly, all you need is to create some lib for reusable definitions and steps, and then require this lib(or gem) in features/support/env.rb
Here is a gem does exactly the same as you need, you can use it as a reference: https://github.com/jayzes/cucumber-api-steps
Look at the features this gem provide: https://github.com/jayzes/cucumber-api-steps/blob/master/features/request.feature The gem created some reusable parts.
Turns out cucumber --help shows the way:
cucumber -r gem-name feature-name.feature
UPDATE: This doesn't work. Any other suggestions?
There is a cucumber gem which installs the binary cucumber.
Running this command, will assume default settings. This means it will look under ./features relative to the current path for files with the .feature extension. It will expect ./features/step_definitions to hold files with *_step.rb, where it will search for steps.
Edit: never mind, I misread your question and thought you wanted to know about the cucumber gem and its default paths.

Resources