ruby

  • ruby padding an array 2017-12-03

    I'm getting the following error when I run my code from my rspec file: pad pads element to the end of an array Failure/Error: expect(pad(array,array.length + pad_size, 'apple')).to eq(array+Array.new(pad_size, 'apple')) expected: ["apple", "

    Tags: ruby, padding
  • Uploading a file using the Ruby SDK to Amazon S3 2017-12-01

    I am trying to upload a file. A simple hello.txt. I was following the docs, and I am unable to upload it to my bucket. # START AWS CLIENT s3 = Aws::S3::Resource.new bucket = s3.bucket(BUCKET_NAME) begin s3.buckets[BUCKET_NAME].objects[KEY].write(:fil

    Tags: ruby, amazon web services
  • Unable to open Locknote on Windows 7 using Ruby 2.0 2017-11-17

    I ran this code, and all it did was take me to the folder of the executable. I had to click on the application exectable to open it. Isn't this supposed to open automatically? require 'Win32API' def user32(name, param_types, return_value) Win32API.ne

    Tags: ruby, winapi
  • How are hashes with identical keys used to relate menu items with order item prices in the following tutorial? 2017-11-10

    I am working on the problem of 'Orders and costs' https://rubymonk.com/learning/books/1-ruby-primer/problems/155-restaurant. Problem Statement is: A restaurant has incoming orders for which you need to compute the costs based on the menu. You might g

    Tags: ruby, hash
  • Ruby Curses getch in cbreak mode doesn't handle Ctrl+C automatically on Windows 2017-08-30

    In cbreak mode terminal should handle some control characters automatically, but it does not: require 'curses' Curses.init_screen() Curses.cbreak() loop { Curses.getch() } On GNU/Linux Ctrl+C interrupts the program. On Windows Ctrl+C just prints ^C a

    Tags: ruby, windows, curses
  • Trying to install ruby on rails on windows for three days now 2017-08-04

    This is how it goes: 1) I go to rubyinstaller.org everything is good here 2) I download the installer and devkit everything is good here 3) I install both in that order then run command to link to devkit to ruby. everything is good here 4) I create a

    Tags: ruby, sqlite3, ruby on rails 3
  • Improving algorithm execution time and prime numbers 2017-08-02

    I am trying to find the largest prime value of a big number, but it takes far too long. For example, to find the largest prime of 999999999, it takes about 55 seconds. How can I improve this? require 'prime' def highestprime num i = 1 counter = 0 cou

    Tags: ruby, algorithm, primes
  • Modularizing Test Script in Ruby(MiniTest Framework ) 2017-06-04

    Working script File name : test_data.rb" class TotalSample < MiniTest::Test @name = 'Arg1' @period = 'Arg2' @usage = 'Arg3' @siteName = Site.new(@name) test1_activedata = @siteName.getActiveData(@period) test1_sample = test1_activedata["sampl

    Tags: ruby, junit, minitest
  • Ruby: variable acting as nul when set to integer 2016-09-28

    After a good 10 minutes of trying to come up with a more informative title, I ran out of ideas. I have 2 prolems. The first is that whenever I try to input a position for pos_in, it registers as nul when run through the case statement that determines

    Tags: ruby, variables
  • RSpec thinks created file is empty 2016-09-21

    I've created a class that creates a new text file. When I try to compare it with an existing file it seems that RSpec thinks the created file is empty. expect(open @expected).to eq(open @result) The result: (compared using ==) Diff: @@ -1,2 +1,2 @@ -

    Tags: ruby, rspec
  • Travis CI is faling to run tests with **/*_test.rb pattern 2016-09-09

    My micro Ruby project tests works on my machine, on private VM, but fails on Travis CI bulid Project uses both rspec (+rspec-given) and minitest Full trace here: https://travis-ci.org/equivalent/code_katas/jobs/61321482 $ bundle exec rake MiniTest::U

    Tags:
  • Chris Pine Ch. 6 Deaf Grandma 2016-08-16

    I am following Chris Pine tutorial. In one of the exercises I have to write to "Grandma" BYE three times in a row to shut the program. But my program can shut even if I don't type "bye" three times in a row. Why? puts "Do you need

    Tags: ruby
  • if page has selector - Capybara 2016-08-02

    Im trying to implement a simple piece of logic that says if element exists on page do something The issue I am facing is that if the element doesnt exist then the find method provided returns an exception and will fail my test. (Capybara::ElementNotF

    Tags: ruby, rspec, capybara
  • How to stub whole module using Mocha? 2016-06-27

    I have a complex module used in my implementation with some functions in it. module A def function some_params #returns some chain object end end #implementation class SomeImplementation def some_function some_params A.function(some_params_other).fun

    Tags: unit testing, ruby
  • Chef conditional resource argument 2016-06-07

    I'm creating a user via Chef. His properties are stored in data bag: { "id": "developer", "home": "/home/developer", "shell": "/bin/zsh", "password": "s3cr3t" } The recipe is:

    Tags: ruby, chef, chef recipe
  • How to get option values from second select list?

    How to get option values from second select list? 2016-05-27

    I have a problem with Mechanize/Ruby. I can't get the second select list options when I am selecting the first ones. If I understood correctly from Google, there are some Ajax magic there. At the moment I have something like this: require 'rubygems'

    Tags: ruby, mechanize, web scraping
  • Ruby - Active Record Query - Comparing Variables Producing False Positive 2016-05-02

    Be warned this a newbie question as its first time using active recored and oracle db.Trying to get my head around active record returned values and its comparison operators. To summarise I want to get a offer id and then compare to the offer value s

    Tags: ruby, database, activerecord, watir webdriver
  • Gem Charlock_holmes installation error on Windows 7 2016-04-15

    I am using Ruby DevKit to install and build gems. A 3rd party tool requires the charlock_holmes gem. I get this error: C:\usr\dsc_test\environments\production\modules\dsc>bundle install Fetching https://github.com/msutter/librarian-repo.git Fetching

    Tags: ruby, gem, icu, windows 7 x64
  • Ruby short Socket.gethostname in RHEL6 2016-04-11

    in RHEL5, the default Ruby's Socket::gethostname returns short hostname without domain name. In RHEL6 it returns the hostname including the domain name. This is caused by different system hostname functionality in RHEL6 which can be fixed in SH scrip

    Tags: ruby, hostname, rhel6
  • aggregate values from specific key in an array of hashes 2016-03-25

    I'm trying to build an array of values that come from an array of hashes, at the moment my code looks like this: ids = array_of_hashes.inject([]) do |result,instance| result << instance[:id] result end I just want to know if there's a more efficient

    Tags: ruby

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.290 (s). 7 q(s)