2018-10-22         Moira

Is there something similar to the selenium grid when using cucumber/capybara?

So I'm trying to get an environment set up that acts like a selenium grid in that:1) It runs the tests in parallel across a distributed set of clients2) I can specify tests to run on specific clients (which are running on different OS's, with different browsers), or tests to run once on all the clients or any combination thereof. The problem is that capybara actually currently uses WebDriver, not selenium, so as far as I know I can't specify a selenium grid for the tests to hook up to and have it work.I've looked into things such as DeepTest and Testjour, but neither scrat...

 ruby                     2 answers                     59 view
 2018-10-22         Glenn

Testing React native with appium

I have made sript test for appium with ruby :require 'rubygems'require 'appium_lib'require 'selenium-webdriver'capabilities = { 'appium-version': '1.0', 'platformName': 'Android', 'platformVersion': '4.4', 'deviceName': 'TestAppium', 'app': '/Users/AwesomeProject/android/app/build/outputs/apk/app-debug.apk',}server_url = "http://0.0.0.0:4723/wd/hub"Appium::Driver.new(caps: capabilities).start_driverAppium.promote_appium_methods Objectfind_element(:xpath, "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view...

 ruby                     2 answers                     54 view
 2018-10-22         Lauren

how to get class from which a method has been defined in ruby?

Having the snippet below:class Foo def initialize puts self.class endendclass Bar < Foo def bark puts self.class endendclass Fizz < BarendFizz.new.barkThis snippet will output two times Fizz (live example). I would like to find something to replace self.class which allows this program to output Foo (from initialize) and then Bar (from bark).My current solution is to hardcode function name, but I'd like something more dynamic. This works. (There's probably a better way, though.)class Foo def initialize puts method(__callee__).owner endendclass Bar <...

 ruby                     1 answers                     3 view
 2018-10-22         Hiram

Ruby date-time string to epoch time local

I have date-time represented in string format like below in the input data I'm getting. I need to convert this to epoch time local. How do I go about this ? example date-time stringstr = "Aug 23 2018 03:49:17:017 PM IST" Maybe this can put you on track.Please refer to http://ruby-doc.org/stdlib-2.5.0//libdoc/date/rdoc/DateTime.html.This is a usage example.require 'date'str = "Aug 23 2018 03:49:17:017 PM IST"d = DateTime.strptime(str, '%b %d %Y %I:%M:%S:%L %p %z')# Maybe you need %e - Day of the month, blank-padded ( 1..31) instead of %d - Day of the month, zero-padded ...

 ruby                     1 answers                     89 view
 2018-10-22         Tracy

Is there a way to attach Ruby Net::HTTP request to a specific IP address / network interface?

Im looking a way to use different IP addresses for each GET request with standard Net::HTTP library. Server has 5 ip addresses and assuming that some API`s are blocking access when request limit per IP is reached. So, only way to do it - use another server. I cant find anything about it in ruby docs. For example, curl allows you to attach it to specific ip address (in PHP):$req = curl_init($url)curl_setopt($req, CURLOPT_INTERFACE, 'ip.address.goes.here';$result = curl_exec($req);Is there any way to do it with Net::HTTP library? As alternative - CURB (ruby curl binding). But...

 ruby                     3 answers                     57 view
 2018-10-22         Franklin

Best Practices for storing passwords in Ruby. Xml, source or other?

I have a Ruby script that sends an email, but I need to store the smtp account credentials in order for the email to get sent. Currently, I have an xml file that I'm storing the password in, however I'm encoding the password using Bas64 in the xml and then decoding in my script. I packaged the script into an .exe as well.I'm trying to figure out what the best practice is in terms of storing credentials. Should I be storing the password in the actual script instead of the xml? Is there some other method that I should be using? The script isn't going to be running on a server...

 ruby                     1 answers                     62 view
 2018-10-22         Georgia

how can you express multiple <options> in xpath?

for multiple selectdown form, how can you express multiple options selected ? <select name="sweets" multiple="multiple"> <option>Chocolate</option> <option selected="selected">Candy</option> <option>Taffy</option> <option selected="selected">Caramel</option> <option>Fudge</option> <option>Cookie</option> </select>/html/body/form/select/option[1],option[2],option[3] ? Not tested, but wouldn't this be:/html/body/form/select/option[@selected='selected']Update: Based on yo...

 ruby                     3 answers                     78 view
 2018-10-22         Bradley

Adding new args to a function while still maintaining backward compatibility in Ruby

I have an old function that is called many times in my application. I would like to update it a bit, which involves adding some new arguments. When I wrote the function, I did not understand the benefits has making a hash the only parameter (mentioned here: http://www.skorks.com/2009/08/more-advanced-ruby-method-arguments-hashes-and-blocks/)I have:def old_function(some_arg) puts some_argendI'd like to rewrite this to take a hash like so:def old_function(some_arg, hash) puts hash[:new_stuff] + "--" + some_argendAll while this does not break:puts old_function('greetings') ...

 ruby                     1 answers                     101 view
 2018-10-22         Gavin

How to count duplicates in Ruby Arrays

How do you count duplicates in a ruby array?For example, if my array had three a's, how could I count that This will yield the duplicate elements as a hash with the number of occurences for each duplicate item. Let the code speak:#!/usr/bin/env rubyclass Array # monkey-patched version def dup_hash inject(Hash.new(0)) { |h,e| h[e] += 1; h }.select { |k,v| v > 1 }.inject({}) { |r, e| r[e.first] = e.last; r } endend# unmonkeey'ddef dup_hash(ary) ary.inject(Hash.new(0)) { |h,e| h[e] += 1; h }.select { |_k,v| v > 1 }.inject({}) { |r, e| r[e.first] = e.l...

 ruby                     13 answers                     65 view
 2018-10-22         Quintina

grouping strings by similarity

I have an array of strings, not many (maybe a few hundreds) but often long (a few hundred chars).Those string are, generally, nonsense and different one from the other.. but in a group of those string, maybe 5 out of 300, there's a great similarity. In fact they are the same string, what differs is formatting, punctuation and a few words..How can I work out that group of string?By the way, I'm writing in ruby, but if nothing else an algorithm in pseudocode would be fine.thanks There are many ways to compare strings for similarity.Here is a site with various similarity me...

 ruby                     4 answers                     30 view
 2018-10-22         Bard

Get Stripe charge information rails 5 create order

So I'm implementing Stripe and users are able to purchase successfully, however, I would like to get the charge information, last 4 card numbers, card type etc so I can generate receipts using https://github.com/excid3/receipts.Here is what I have so far:PaymentsControllerclass PaymentsController < ApplicationController before_action :authenticate_user! def create token = params[:stripeToken] @course = Course.find(params[:course_id]) @user = current_user begin charge = Stripe::Charge.create( amount: (@course.price*100).to_i, currency: "gb...

 ruby                     2 answers                     94 view
 2018-10-22         Iris

Only show button if purchased Stripe

So I'm trying to have my app where when a user purchases a course they see a view modules button because when they purchase the course an order gets created so I'm checking whether an order exists.However, currently when a course gets purchased the view modules get shown on all courses but I want it to only show on the course that is purchased.Here is what I have so far:schema.rb create_table "courses", force: :cascade do |t| t.string "title" t.text "summary" t.text "description" t.string "trailer" t.integer "price" t.datetime "created_at", null: false ...

 ruby                     1 answers                     96 view
 2018-10-22         Zebulon

Why is `9.3 == 9.3.to_d` false?

I just ran into an interesting case during TDD: Failure/Error: expect(MoneyManager::CustomsCalculator.call(price: 31, weight: 1.12)).to eq 9.3 expected: 9.3 got: 0.93e1I investigated further and found:require 'bigdecimal' => true2.4.2 :005 > require 'bigdecimal/util' => true...2.4.2 :008 > 1 == 1.to_d => true2.4.2 :009 > 2 == 2.to_d => true2.4.2 :010 > 2.0 == 2.0.to_d => true2.4.2 :011 > 1.3 == 1.3.to_d => true2.4.2 :012 > 9.3 == 9.3.to_d => falseWhy is 9.3 == 9.3.to_d false?PS, I am well aware of what a Float and a BigD...

 ruby                     2 answers                     90 view
 2018-10-22         Yvonne

Use issue_closing_pattern variable to close multiple issues in gitlab

I'd like to have the ability to close multiple issues with one commit by referencing multiple issues with the default pattern ^([Cc]loses|[Ff]ixes) +#\d+a. I know that this will only affect fixes #number-patterns at the beginning of lines and that's what I want.But I wasn't yet able to get it to work.I'm currently using Gitlab 6.1, installed it according to the installation readme on github and didn't change anything other then the codesnippet below.Here's what I tried:First I changed in {gitlab-directory}/app/models/commit.rb the following (original code commented out):def...

 ruby                     1 answers                     87 view
 2018-10-22         Roberta

Bundler::GemNotFound Issue after installing Redmine on Debian

I am trying to install Remine on Debian server. Apache is the Http Server and MySql as database. Installation is complete. Its shows an error Could not find nokogiri-1.8.4 in any of the sources (Bundler::GemNotFound). I haven't hosted an Ruby application before. Tried most of the commands found on internet about this issue. This is the URL where you can see the issue. During the deployment of the app, there should be a step bundle install. This step is performed by a gem called bundler, that needs to be installed prior to this step. Add gem install bundler to install it...

 ruby                     1 answers                     27 view
 2018-10-22         Bishop

Create a virtual machine from a managed image

I have created azure VMs successfully using the ruby sdk but I can't find any example for creating from a managed image. I want to do something like this but with SDK:az image create --name fedora-75-20180724 --resource-group myteam --source https://eastusimg.blob.core.windows.net/images/fedora-28-20180724.vhd --os-type linux# create vm without option "--use-unmanaged-disk, --os-type, --storage-account"az vm create -g myteam -n managed-master --image fedora28-20180724 --size Standard_DS2_V2 --nics managed-master --os-disk-size-gb 40 --public-ip-address-dns-name managed-mast...

 ruby                     1 answers                     68 view

Page 1 of 540  |  Show More Pages:  Top Prev Next Last