Category "rspec"

RSpec: how to chain receive().with()?

I've been writing tests with instance_doubles to stand in for message chains when I need more granularity in the midst of the chain. But, I'm wondering if I'm d

How to have a factory in multiple files

I have a model that is used by multiple libs, each of these libs is using it with different approaches. For the moment I made a factory file, which contains mul

Emulating a clipboard copy/paste with Selinum + Capybara

I have a "Copy Link" button in my frontend UI. When clicked, the URL inside an input box is copied to the user's clipboard with this JS: const copyTextarea = d

Custom RSpec argument matcher spec output

I am trying to get a good output for a custom matcher I wrote: RSpec::Matchers.define :scope_limited_to do |expected| match do |actual| @actual = actual.l

rspec describe a rake task namespace

I want to test a specific namespace of rake tasks and I am getting an error from rubocop. desc 'This namespace is test' namespace :test_namespace do task tes

Can we actually do rspec testing on ruby if my methods don't have parameters?

I have a method but doesn't have a parameter, for example def goodbye puts "" puts "Thank you, #{name} for using our service." puts "Good luck with

"Undefined method `build'" when using Rspec + FactoryBotRails

I'm trying this gem called FactoryBotRails. For some reason, when I try it on one of my models unit tests, the following error is thrown. Failure/Error: my_

How to test react-rails components in rspec feature tests using Cuprite & Webdrivers

I am updating an older app's Ruby and Rails versions and attempting to get all of the feature tests passing. Most of them were failing due to still relying on c

Rspec Capybara Failure/Error: DatabaseCleaner.clean

I am using rails 6.1.4 (Ubuntu 20.04) and am running tests with rspec, factorybot, and capybara. I also got database_cleaner where I'm using :truncation to star

Rspec 3 how to test flash messages

I want to test controller's action and flash messages presence with rspec. action: def create user = Users::User.find_by_email(params[:email]) if user

Capybara and Factorybot - created data does not appear

I am facing a wired issue, factoryBot is creating a record in Db, but when capybara try to access it, there is no record in HTML. I tried debugging with "byebu

Testing login flow with RSpec in Rails app

I'm using RSpec to test controller behavior in rails. One of the expectations I have is the following scenario: User attempts to access a protected (requires l

rspec testing carrierwave

I'm making a rails 3.1 app using carrierwave to upload files to aws s3. I've followed the instructions on the carrierwave github repository and am now able to

Rails/Rspec - testing a redirect in the controller

So I am currently writing a test for a controller in an existing controller that just didn't have one before. What I want to test is a redirect that happens whe