Getting started with Ruby, Watir and Ruby Mine? - ruby

I want to automate testing of an e-commerce website. I installed Ruby, Watir, Gems and Ruby Mine.
Though I played around with RubyMine I could not figure how to start writing a simple script:
How do I start writing a simple script using RubyMine? I created a project. What is the next step? Do I have to create an rspec file now? And probably search for a sample program, and run it?
Can someone give me a sample of opening a website and maybe clicking a link so that I can see it running?
I would be grateful for simple documentation which helps me.

Did you even check Watir web site? There is plenty of documentation on how to get started there.

Here is the sample project that is using Cucumber and Watir to open a search page, send a query and verify the results.
Gemfile specifies the required gems, make sure they are installed or can be installed in your environment. If you are on Windows you need to install DevKit.

Related

How to setup ruby profiler in IntelliJ

There seems to have been a recent update for to ruby mine that allows you to attach a rbspy profiler to a rails app. I have found a ton of guides on the internet (for instance this one) that explain what changes need to be updated in ruby mine to allow you to attach the profiler to the ruby process, but i have not been able to find the same steps for intellij with the ruby plugin.
Is there a way to perform the steps linked in the guide above in the Intellij IDE?
At the moment Ruby profiler isn't available via Ruby plugin in IDEA but it's planned to be in 2019.2:
https://youtrack.jetbrains.com/issue/RUBY-23977
UPD: it seems to be available in the last IDEA 2019.2 EAPs (starting from 192.5118.30)

How to get Processing to work on Cloud9 using Ruby language?

I am currently working on a personal project using the Ruby language in Cloud9 IDE. Recently, I came across an environment/programming language called Processing. My goals is to make Processing available for my use in Cloud9 IDE.
I am a complete novice and have no clue what I am doing. I followed directions from the following website: Directions for setting up Processing
I entered the following commands into Cloud9's terminal:
rvm install jruby
rvm use jruby
gem install ruby-processing
PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
Entering in PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
outputted message bash: PROCESSING_ROOT:: command not found
I wasn't too surprised by this, since the last entry probably needs information specific to my setup. Here are my questions:
1.) Are these directions correct for what I am trying to do? (get Processing to work in Cloud9 IDE). If they are not correct, can someone please point me to the correct directions, or give me directions?
2.) If these directions are correct, how can I successfully finish the last step? I tried running DrawRuby.rb, a simple program copied from the internet that supposedly made use of Processing. When I ran the code, the message "You need to set PROCESSING_ROOT in ~/.rpsrc" appeared. I am not sure if this piece of information is relevant or not, but I figured I would add it.
This is where I am at, and I am completely stuck. If someone could give me some help, I would be very grateful. Also, please make your explanation easy to understand. I am relatively new to the programming world, and may not necessarily understand terminology or how things should work.
Cheers!
*** Edit: I created a new workspace in Cloud9 IDE and tried Jed's suggestion. This is what happened:echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc
:~/workspace $ rp5 run Draw.rb
WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc
NameError: uninitialized constant Processing::RP_CONFIG
Did you mean? Config
RbConfig
const_missing at org/jruby/RubyModule.java:3344
spin_up at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:188
run at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:105
execute! at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:67
execute at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:61
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/bin/rp5:10
load at org/jruby/RubyKernel.java:979
<eval> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/rp5:1
eval at org/jruby/RubyKernel.java:1000
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/jruby_executable_hooks:15
You need to add a file to your home directory (~/) called .rpsrc and then add that environmental setting (PROCESSING_ROOT) to your file. The following should work from the command line in your cloud9 environment:
echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc
I know it might be a bit late for you but ruby-processing is now deprecated, and will only work with processing-2.2.1. For processing-3.3.7 use either JRubyArt or propane latter does not even require processing install.

rhotoalbum for ruby on rails

Anyone knows about Rhotoalbum : http://rhotoalbum.rubyforge.org/ . This gallery examples looks very good, but in the website isn't good information how to add this gallery to my ruby on rails project. I am beginner in ruby on rails, so could someone help or point to good information source? By the way I am using ruby on rails 3.2.1.
Thank you very much.
I would probably run Rhotoalbum locally, then store your pictures in public/pictures directory. Then run Rhotoalbum to create the thumbnails and such. Add them to your Rails project with Git, then the next time you deploy your Rails app, it will have the pictures available at http://hostname.com/pictures/

Ruby standalone app deployment/distribution

What's the best way to distribute a simple command-line Ruby app to clients in a way that would not require them to manually install Ruby and required Gems?
In my understanding this task boils down just to a couple of lines of SH/BAT code that does Ruby/Gems checks and if not found goes on with Ruby installation with RVM.
So do these lines of code exist already somewhere or will I need to write something on my own?
I've used this project for small scripts in the past, without any issues
http://www.erikveen.dds.nl/rubyscript2exe/
It creates an EXE file out of your ruby script.
If you need something cross-platform, the BAT/sh option is probably best. You could grab RVM, have RVM install ruby, use bundler for your gems, and then launch the script.
The closest I've found is (I believe) releasy: https://github.com/Spooner/releasy
I failed to find any way of producing a Ruby cross platform installation.
I've created a RubyAnywhere script that tries to solve this task.

Sinatra requires restart

I'm just getting started with Sinatra. I'm running Ruby 1.9.2 on Ubuntu. After my first issue, I've run into another one:
When I follow the simple sample application instructions at sinatra.rubyforge.org/doc/, I modify my source file, but the changes aren't apparent until I restart Sinatra - even though the tutorial mentions there is no need to restart.
How can I edit my source and view the results without having to restart Sinatra every time?
The book has something on the topic now: http://sinatra-book.gittr.com/#automatic_code_reloading

Resources