# Testing

**URL:** https://www.ruby-forum.com/c/testing/36.md

[Latest](https://www.ruby-forum.com/latest.md) · [Categories](https://www.ruby-forum.com/categories.md) · [Tags](https://www.ruby-forum.com/tags.md)

---

## [About the Testing category](https://www.ruby-forum.com/t/about-the-testing-category/253040)

<div class="topic-metadata">

**Author:** [@how](https://www.ruby-forum.com/u/how)\
**Replies:** 0

</div>

---

## [Custom fail message on an around hook with a Timeout exception](https://www.ruby-forum.com/t/custom-fail-message-on-an-around-hook-with-a-timeout-exception/267563)

<div class="topic-metadata">

**Author:** [@gditrick](https://www.ruby-forum.com/u/gditrick)\
**Replies:** 0\
**Last updated:** [March 13, 2025, 3:35am UTC](https://www.ruby-forum.com/t/custom-fail-message-on-an-around-hook-with-a-timeout-exception/267563 "2025-03-13T03:35:48Z")

</div>

doing this which works to make sure that no infinite loop happens: RSpec.configure do |config| config.around(:example, finite: true) do |example| Timeout.timeout(wait\_time) do example.run end end end My desired e…

---

## [How can I write minitest for a method use resque job](https://www.ruby-forum.com/t/how-can-i-write-minitest-for-a-method-use-resque-job/264046)

<div class="topic-metadata">

**Author:** [@khoalarion](https://www.ruby-forum.com/u/khoalarion)\
**Replies:** 6\
**Last updated:** [January 30, 2024, 2:25pm UTC](https://www.ruby-forum.com/t/how-can-i-write-minitest-for-a-method-use-resque-job/264046 "2024-01-30T14:25:53Z")

</div>

This is my method How can I write minitest for this method, please help me

---

## [Can create resque job in test](https://www.ruby-forum.com/t/can-create-resque-job-in-test/264052)

<div class="topic-metadata">

**Author:** [@khoalarion](https://www.ruby-forum.com/u/khoalarion)\
**Replies:** 1\
**Last updated:** [June 29, 2023, 7:02am UTC](https://www.ruby-forum.com/t/can-create-resque-job-in-test/264052 "2023-06-29T07:02:04Z")

</div>

When I create job in console when I run minitest, but when i check it return 0, why

---

## [How can i write minitest for resque job](https://www.ruby-forum.com/t/how-can-i-write-minitest-for-resque-job/264044)

<div class="topic-metadata">

**Author:** [@khoalarion](https://www.ruby-forum.com/u/khoalarion)\
**Replies:** 2\
**Last updated:** [June 28, 2023, 1:52am UTC](https://www.ruby-forum.com/t/how-can-i-write-minitest-for-resque-job/264044 "2023-06-28T01:52:02Z")

</div>

I have a method in Controller, and in this method I create a job resque, example: def create at\_time =. Time.zone.now + 1.hour JobWorker.perform\_at(at\_time.seconds.from\_now) end How can I test this method in minit…

---

## [How can I find out unnecessary variable preparation in tests using some tools?](https://www.ruby-forum.com/t/how-can-i-find-out-unnecessary-variable-preparation-in-tests-using-some-tools/264029)

<div class="topic-metadata">

**Author:** [@guodah](https://www.ruby-forum.com/u/guodah)\
**Replies:** 1\
**Last updated:** [June 24, 2023, 6:52pm UTC](https://www.ruby-forum.com/t/how-can-i-find-out-unnecessary-variable-preparation-in-tests-using-some-tools/264029 "2023-06-24T18:52:34Z")

</div>

Suppose I have a set of tests like the following. Apparently, test1 and test2 should be separated so that the preparation of var1 or var2 will not be unnecessary in test2 or test1. Anyway I can use some static analysis t…

---

## [Ruby Watir - How to call methods from another file](https://www.ruby-forum.com/t/ruby-watir-how-to-call-methods-from-another-file/262643)

<div class="topic-metadata">

**Author:** [@pergega21](https://www.ruby-forum.com/u/pergega21)\
**Replies:** 0\
**Last updated:** [March 23, 2022, 10:58am UTC](https://www.ruby-forum.com/t/ruby-watir-how-to-call-methods-from-another-file/262643 "2022-03-23T10:58:03Z")

</div>

Hi, I’m using watir ruby for my testing I have many scripts written for a website so I don’t want to going to each file to change the @browser.goto “website” environment. I want to find out how can I call the setup and …

---

## [Testing an API I'm creating, need test server to be running](https://www.ruby-forum.com/t/testing-an-api-im-creating-need-test-server-to-be-running/215749)

<div class="topic-metadata">

**Author:** [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Replies:** 7\
**Last updated:** [June 18, 2013, 6:07pm UTC](https://www.ruby-forum.com/t/testing-an-api-im-creating-need-test-server-to-be-running/215749 "2013-06-18T18:07:49Z")

</div>

Hi, As I am writing a brand new API, I’d like to test it’s response. Obviously, controller tests are great and work like a charm but as I expose data which are not really resources, I’ve to make some DIY to provide r…

---

## [RSpec: How to generate test logs? I have tried but it re-writes it for every test](https://www.ruby-forum.com/t/rspec-how-to-generate-test-logs-i-have-tried-but-it-re-writes-it-for-every-test/259446)

<div class="topic-metadata">

**Author:** [@Jeeva](https://www.ruby-forum.com/u/Jeeva)\
**Replies:** 13\
**Last updated:** [November 4, 2021, 12:49pm UTC](https://www.ruby-forum.com/t/rspec-how-to-generate-test-logs-i-have-tried-but-it-re-writes-it-for-every-test/259446 "2021-11-04T12:49:18Z")

</div>

I have created this small sample code GitHub - jeevan1987cool/sample-rspec-logging: Sample example to generate logs. The issue with this is that it creates a new log file for every test. I have two tests in spec/first\_t…

---

## [Generic example or template for RSpec request tests for autogenerated scaffold code](https://www.ruby-forum.com/t/generic-example-or-template-for-rspec-request-tests-for-autogenerated-scaffold-code/259315)

<div class="topic-metadata">

**Author:** [@EthanS](https://www.ruby-forum.com/u/EthanS)\
**Replies:** 1\
**Last updated:** [November 4, 2021, 12:43pm UTC](https://www.ruby-forum.com/t/generic-example-or-template-for-rspec-request-tests-for-autogenerated-scaffold-code/259315 "2021-11-04T12:43:54Z")

</div>

I am just learning RSpec. I generated resources using rails generate scaffold … I am now creating RSpec tests for the generated code. This is a generic need. Does anyone have an example or template for testing basic …

---

## [Assert Method is Used? (ActiveRecord Scopes)](https://www.ruby-forum.com/t/assert-method-is-used-activerecord-scopes/261854)

<div class="topic-metadata">

**Author:** [@mball](https://www.ruby-forum.com/u/mball)\
**Replies:** 0\
**Last updated:** [September 21, 2021, 9:19am UTC](https://www.ruby-forum.com/t/assert-method-is-used-activerecord-scopes/261854 "2021-09-21T09:19:52Z")

</div>

Long time lurker… I fully admit: This is kind of an exceptional use case for rspec. I’m teaching a course which uses Rails, and as such I’ve got some tricky things I’d like to test for. How can I expect that a method ca…

---

## [When I put the cucumber data table, the description of the scenarios disappeared from the screen](https://www.ruby-forum.com/t/when-i-put-the-cucumber-data-table-the-description-of-the-scenarios-disappeared-from-the-screen/261675)

<div class="topic-metadata">

**Author:** [@ValeriaSantos](https://www.ruby-forum.com/u/ValeriaSantos)\
**Replies:** 0\
**Last updated:** [August 9, 2021, 4:54pm UTC](https://www.ruby-forum.com/t/when-i-put-the-cucumber-data-table-the-description-of-the-scenarios-disappeared-from-the-screen/261675 "2021-08-09T16:54:41Z")

</div>

A strange thing happened in my project, when I write the scenario without the cucumber data table, it shows on the screen the description of the steps, but when I put the data table the description of the steps doesn’t a…

---

## [How can enter the values in text box using python](https://www.ruby-forum.com/t/how-can-enter-the-values-in-text-box-using-python/260673)

<div class="topic-metadata">

**Author:** [@richards12](https://www.ruby-forum.com/u/richards12)\
**Replies:** 0\
**Last updated:** [December 21, 2020, 6:15am UTC](https://www.ruby-forum.com/t/how-can-enter-the-values-in-text-box-using-python/260673 "2020-12-21T06:15:21Z")

</div>

can anyone explain how can enter the values in textbox using python

---

## [Write model rspec for my application](https://www.ruby-forum.com/t/write-model-rspec-for-my-application/260353)

<div class="topic-metadata">

**Author:** [@AshwiniRane](https://www.ruby-forum.com/u/AshwiniRane)\
**Replies:** 0\
**Last updated:** [October 11, 2020, 1:21pm UTC](https://www.ruby-forum.com/t/write-model-rspec-for-my-application/260353 "2020-10-11T13:21:05Z")

</div>

I am a beginner in ruby and rails and struggling to write rspec code for my model methods as given below: Please help me write rspec implementation and test examples for my methods for me to have a basic understanding o…

---

## [Question about test FAIL](https://www.ruby-forum.com/t/question-about-test-fail/260118)

<div class="topic-metadata">

**Author:** [@Beto](https://www.ruby-forum.com/u/Beto)\
**Replies:** 2\
**Last updated:** [August 15, 2020, 10:42am UTC](https://www.ruby-forum.com/t/question-about-test-fail/260118 "2020-08-15T10:42:44Z")

</div>

Hi folks! I am a beginner stundent in Ruby and Rspec and I have a question about a test using be\_within Please, take a look the follow screen below. The error above shou not be occur. Right? Thanks in advance! …

---

## [How to write tests for respond\_to in controller?](https://www.ruby-forum.com/t/how-to-write-tests-for-respond-to-in-controller/259201)

<div class="topic-metadata">

**Author:** [@uAlmostGotMe](https://www.ruby-forum.com/u/uAlmostGotMe)\
**Replies:** 0\
**Last updated:** [April 9, 2020, 6:47pm UTC](https://www.ruby-forum.com/t/how-to-write-tests-for-respond-to-in-controller/259201 "2020-04-09T18:47:06Z")

</div>

I’m writing the rspec unit test for the update method of controller. The method is: def update @people = People.find(params\[:id\]) if @people.update(people\_params) respond\_to do |format| format.html {redire…

---

## [Testing rescue (tdd with rspec)](https://www.ruby-forum.com/t/testing-rescue-tdd-with-rspec/253118)

<div class="topic-metadata">

**Author:** [@juannodeb](https://www.ruby-forum.com/u/juannodeb)\
**Replies:** 1\
**Last updated:** [February 11, 2020, 6:50pm UTC](https://www.ruby-forum.com/t/testing-rescue-tdd-with-rspec/253118 "2020-02-11T18:50:06Z")

</div>

Hello. I’m getting into TDD, I’m using rspec and I’m having a hard time trying to test rescues(exceptions). Can anyone please advice me on how to test exceptions with RSpec 3.8? Thanks in advance

---

## [Get LinkedIn profiles information using web automation testing with Ruby/Watir](https://www.ruby-forum.com/t/get-linkedin-profiles-information-using-web-automation-testing-with-ruby-watir/253636)

<div class="topic-metadata">

**Author:** [@MohaBoonder](https://www.ruby-forum.com/u/MohaBoonder)\
**Replies:** 3\
**Last updated:** [January 28, 2020, 11:21am UTC](https://www.ruby-forum.com/t/get-linkedin-profiles-information-using-web-automation-testing-with-ruby-watir/253636 "2020-01-28T11:21:03Z")

</div>

Hello All, First of all, i apologize for my english and i hope it will be understandable. I am new in this forum and I want help. In fact, i want to develop automated tests with a chrome extension which we are developi…

---

## [Latest version of Ruby breaks minitest/rg on Mac OSX](https://www.ruby-forum.com/t/latest-version-of-ruby-breaks-minitest-rg-on-mac-osx/253494)

<div class="topic-metadata">

**Author:** [@SuziTech](https://www.ruby-forum.com/u/SuziTech)\
**Replies:** 1\
**Last updated:** [December 17, 2019, 8:55pm UTC](https://www.ruby-forum.com/t/latest-version-of-ruby-breaks-minitest-rg-on-mac-osx/253494 "2019-12-17T20:55:17Z")

</div>

Just upgraded my Ruby on my MacBook Pro, which is still on High Sierra, to 2.6.3 and now minitest/rg is broken. I get the following system message: Traceback (most recent call last): 2: from ruby\_functions\_practice\_spe…

---

## [How to sort div elements in Ruby? (Web Automation, Cucumber, Watir)](https://www.ruby-forum.com/t/how-to-sort-div-elements-in-ruby-web-automation-cucumber-watir/253428)

<div class="topic-metadata">

**Author:** [@Ruby\_Newbie](https://www.ruby-forum.com/u/Ruby_Newbie)\
**Replies:** 0\
**Last updated:** [December 6, 2019, 7:08pm UTC](https://www.ruby-forum.com/t/how-to-sort-div-elements-in-ruby-web-automation-cucumber-watir/253428 "2019-12-06T19:08:22Z")

</div>

I have the following problem - I don’t know how I can sort div elements, which have the same class, same id’s, same name, etc. The only thing that differentiates them are the tags inside them. I am currently learning we…

---

## [Can Rspec take in a variable from the Command Line and use that variable in all tests?](https://www.ruby-forum.com/t/can-rspec-take-in-a-variable-from-the-command-line-and-use-that-variable-in-all-tests/252887)

<div class="topic-metadata">

**Author:** [@GeorgeTWalters](https://www.ruby-forum.com/u/GeorgeTWalters)\
**Replies:** 2\
**Last updated:** [August 18, 2019, 5:44am UTC](https://www.ruby-forum.com/t/can-rspec-take-in-a-variable-from-the-command-line-and-use-that-variable-in-all-tests/252887 "2019-08-18T05:44:32Z")

</div>

I have a variable that comes in from the command line. . . rspec spec spec/boxing/kata/boxing\_kata\_spec.rb \<spec/fixtures/family\_preferences.csv The variable. . . family\_file = $stdin. . .can be seen by the first test …

---

## [How to parse json and access a value in Ruby](https://www.ruby-forum.com/t/how-to-parse-json-and-access-a-value-in-ruby/252104)

<div class="topic-metadata">

**Author:** [@ameha](https://www.ruby-forum.com/u/ameha)\
**Replies:** 1\
**Last updated:** [March 18, 2019, 10:52am UTC](https://www.ruby-forum.com/t/how-to-parse-json-and-access-a-value-in-ruby/252104 "2019-03-18T10:52:10Z")

</div>

How can I get the value of id, description and count. I did JSON.parse(response) but I am not sure how to get the value. { “students”: \[ { “name”: “test1”, “id”: 1, “created\_at”: “2019-03-13T21:34:30Z”, “updated\_a…

---

## [Scripts fails to identify objects using Ruby version 2.2.6 and RubyMine version 2018 on VM with windows 7](https://www.ruby-forum.com/t/scripts-fails-to-identify-objects-using-ruby-version-2-2-6-and-rubymine-version-2018-on-vm-with-windows-7/251757)

<div class="topic-metadata">

**Author:** [@Priya.asfriend](https://www.ruby-forum.com/u/Priya.asfriend)\
**Replies:** 0\
**Last updated:** [January 29, 2019, 8:28am UTC](https://www.ruby-forum.com/t/scripts-fails-to-identify-objects-using-ruby-version-2-2-6-and-rubymine-version-2018-on-vm-with-windows-7/251757 "2019-01-29T08:28:08Z")

</div>

Scripts fails to identify objects using Ruby version 2.2.6 and RubyMine version 2018 on VM with windows 7. But same scripts works fine on Windows 10 Scripts are failing to identify object and thus fails on very first st…

---

## [Mocking or stubbing an external database](https://www.ruby-forum.com/t/mocking-or-stubbing-an-external-database/237320)

<div class="topic-metadata">

**Author:** [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Replies:** 1\
**Last updated:** [October 18, 2018, 6:07pm UTC](https://www.ruby-forum.com/t/mocking-or-stubbing-an-external-database/237320 "2018-10-18T18:07:24Z")

</div>

I’m working on a system that requires me to attach to an external (readonly) database. In order to prevent Rails establishing a connection to the external database for every test, I’ve written something like this: m…

---

## [\[Rspec\] How do you nest before(:all) or after(:all) blocks?](https://www.ruby-forum.com/t/rspec-how-do-you-nest-before-all-or-after-all-blocks/159407)

<div class="topic-metadata">

**Author:** [@johnk](https://www.ruby-forum.com/u/johnk)\
**Replies:** 8\
**Last updated:** [October 24, 2013, 8:39pm UTC](https://www.ruby-forum.com/t/rspec-how-do-you-nest-before-all-or-after-all-blocks/159407 "2013-10-24T20:39:56Z")

</div>

Hi all, I’m new to Rspec but loving it so far and looking to use it as a replacement for a Test::Unit framework I have which drives a web app via Watir. So far, things have worked very well with Rspec but I can’t get…

---

## [Template Scaffold syntax error](https://www.ruby-forum.com/t/template-scaffold-syntax-error/236457)

<div class="topic-metadata">

**Author:** [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Replies:** 1\
**Last updated:** [October 23, 2013, 12:19pm UTC](https://www.ruby-forum.com/t/template-scaffold-syntax-error/236457 "2013-10-23T12:19:22Z")

</div>

I inherited a project from another developer. I ran rspec . and I and getting the following error and I need help figuring it out asap. ~/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.r…

---

## [RSpec with devise test helpers](https://www.ruby-forum.com/t/rspec-with-devise-test-helpers/236982)

<div class="topic-metadata">

**Author:** [@alcina](https://www.ruby-forum.com/u/alcina)\
**Replies:** 0\
**Last updated:** [October 16, 2013, 9:17pm UTC](https://www.ruby-forum.com/t/rspec-with-devise-test-helpers/236982 "2013-10-16T21:17:24Z")

</div>

I’ve set my Rails (engine) project to include devise and other tools like FactoryGirl. I’d like to write some tests with contexts around anon/authenticated users. In my spec\_helper.rb’s RSpec.configure block, I have …

---

## [How to write “Destroy kid” in cucumber](https://www.ruby-forum.com/t/how-to-write-destroy-kid-in-cucumber/236711)

<div class="topic-metadata">

**Author:** [@alcina](https://www.ruby-forum.com/u/alcina)\
**Replies:** 0\
**Last updated:** [September 27, 2013, 9:37am UTC](https://www.ruby-forum.com/t/how-to-write-destroy-kid-in-cucumber/236711 "2013-09-27T09:37:25Z")

</div>

how to write “Destroy kid” in cucumber Scenario: User can delete kids Given I am on the kids page When I Destroy kid Then I should see “Kid deleted successfully” Then one kid should not exist Listing kids Kid nam…

---

## [Take screenshot even if the test case get passed](https://www.ruby-forum.com/t/take-screenshot-even-if-the-test-case-get-passed/236486)

<div class="topic-metadata">

**Author:** [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Replies:** 1\
**Last updated:** [September 6, 2013, 1:43pm UTC](https://www.ruby-forum.com/t/take-screenshot-even-if-the-test-case-get-passed/236486 "2013-09-06T13:43:51Z")

</div>

Hi, I am using selenium webdriver and rspec so when a test case fail a screenshot is taken. But is there any way to take a screenshot for all test cases so even when the test case pass? Thanks in advance! Mattias

---

## [How to catch the mocked infinite loop behavior and handle it with a rescue block using RSpec](https://www.ruby-forum.com/t/how-to-catch-the-mocked-infinite-loop-behavior-and-handle-it-with-a-rescue-block-using-rspec/235868)

<div class="topic-metadata">

**Author:** [@alcina](https://www.ruby-forum.com/u/alcina)\
**Replies:** 0\
**Last updated:** [July 20, 2013, 7:19pm UTC](https://www.ruby-forum.com/t/how-to-catch-the-mocked-infinite-loop-behavior-and-handle-it-with-a-rescue-block-using-rspec/235868 "2013-07-20T19:19:37Z")

</div>

I have a Book Model which is a ruby script that assigns prices to certain predefined Book titles mentioned in the program. I’m using Ruby 1.9.3-p327 and rspec 2.11.0 #class RspecLoopStop \< Exception; end class Book …

[Next page](https://www.ruby-forum.com/c/testing/36.md?page=1)
