How do I prevent Watir from auto closing firefox?

I am automating test cases using Ruby and Watir. One of my methods opens the web browser, but as soon as my script leaves the “open browser” method and goes to the next method (filling out forms within the browser), the browser auto closes. When I automate using the IE browser it will not close […]

Iterate through an Ruby Array and get(yield or return) each item in the array

I have an array and I need to create a class method named “each” to yield or return (not sure what the difference is of those or which I need to use if any) each item in the array when the method is called. Do I need to use return instead of yield or neither? […]

Ruby combine hashes?

Is there a method in ruby to combine two hashes into one? Specifically, given A = {:a => :b} and B = {:b => :c} I want AB = combine(A,B) => {:a => :c} I can make my own if there isn’t one in ruby’s standard library but I’d rather not reinvent the wheel.

Comparing a string with an array of strings and printing the count

I’m comparing a string to an array of strings using: arry.include? (mystring) and it returns a boolean value. How can I print out how many strings in that array equaled to mystring?

How does the === work in ruby?

This question already has an answer here: === vs. == in Ruby 3 answers

Create own Array#map like method

I want to create an instance method like Array#my_map and that method should behavior of the original Array#map method. I want to same output from new method as below: arr = [1, 2, 3, 4] arr.new_map_method do |x| x + 1 end # => [2, 3, 4, 5] arr.new_map_method(&:to_s) # => [“1”, “2”, “3”, “4”]

How get user info from twitter via API?

I’m developing API to integrate rails app with twitter. I receive from client only: { provider: ‘twitter’, user_id: ‘USER_ID’, access_token: ‘ACCESS_TOKEN’ } But I need create user and save it into database if user is not registered etc. I have models user and authentication (user has many authentications): class User validate :first_name, :last_name, :email, presense: […]

Trying to write my own all? method in Ruby

There is a method called all? in Enumerable. I’m trying to learn all the methods of Enumberable’s library by writing them myself. This is what I’ve come up so far for the all? method. I sorta understand it but I got stumped when trying to pass initialized values to my method. EDIT for the record, […]

Ruby On Rails Returning Array NoMethodError

We’ve been continuously working on this issue for a few months and not getting far with it. Since this was first asked, we changed the code (based on what the original developer for the site suggested), but we are still not getting where we need to be. I’m relatively new to Ruby and am currently […]

Speeding up solution to algorithm

Working on the following algorithm: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. For example: A = [2,3,1,1,4], return true. A = [3,2,1,0,4], […]

Ruby is the best programming language in the world - Ruby on Rails.