Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
51 views

In Rspec, how can I set a login token (http header) in every test without having to pass it as an argument to every http request

I'm writing an integration for an API that requires an authentication header. But authentication is not part of the test itself, and I would like to avoid setting the header in every single get/post I ...
Andre driem's user avatar
0 votes
0 answers
39 views

ERROR -- : Can't add attachment, no test, step or fixture is running (allure-rspec)

I'm integrating allure reports with my API test project using Rspec. I wanted to attach request and response details to the report after each testcase. The following is my response_parser to get ...
Mona101ma's user avatar
  • 764
1 vote
1 answer
67 views

Can I write one expectation in RSpec which demands a method is called only once with specific arguments?

I'm just finishing my first year writing production code in Rails, and I'm not really stuck here, but the non-rubyness of what I'm experiencing is weird, and I wanted to see if anyone had this problem....
Louis Pate's user avatar
1 vote
3 answers
79 views

Testing the contents of an array inside a hash

In Rspec I am testing a hash that contains an array like this: subject { described_class.call(build: build_one, user:) it 'returns the correct data' do response = subject expected_response = { ...
BluePrint's user avatar
  • 2,088
0 votes
3 answers
105 views

How to prevent password from being updated if empty in Rails Model and test it with RSpec?

I use Bcrypt gem for password encryption. User model: class User < ApplicationRecord has_secure_password validates :password, presence: true, length: { minimum: 6 }, confirmation: true # ... ...
Chiara Ani's user avatar
  • 1,015
0 votes
1 answer
45 views

Why does RSpec Rails generate mailer fixtures?

I executed this command: rails g mailer users/confirmations confirm_email It generated this file at spec/fixtures/users/confirmations/confirm_email: Users::Confirmations#confirm_email Hi, find me in ...
Chiara Ani's user avatar
  • 1,015
0 votes
2 answers
65 views

How to skip before_action for all rails specs

In my controller i have several before_actions. But I need to skip the specific before_action for all tests. I can't do this in every test. This should be done at the global level, perhaps in ...
Tanas's user avatar
  • 9
0 votes
2 answers
58 views

Rspec not able to trigger method inside after_commit callback

I am working on writing a test case for a model Benefit. The class file contains an after_commit callback which calls a method update_contract. It also has belongs_to :contract, touch: true. @contract ...
Bharat Kumar Anand's user avatar
0 votes
2 answers
53 views

Stubbing and extending a class "rspec style"

In a Rspec test, I'm creating and extending the "Queryable" class: let(:queryable) do class Queryable include FeatureQuery end.new end that class doesn't exist in the app, ...
aarkerio's user avatar
  • 2,309
2 votes
1 answer
70 views

Run skipped rspec tests and fail if they pass

Let's say I have a bunch of tests: spec/code_spec.rb: require "rails_helper" RSpec.describe Code do xit { Code.evaluate("Twitter.search") } xit { Code.evaluate("Slack....
Dorian's user avatar
  • 8,962
0 votes
0 answers
264 views

Error when running RSpec tests: "FrozenError: can't modify frozen Array"

I encountered an issue while running RSpec tests in my Rails application, and I'm seeking help in understanding and resolving it. When attempting to run RSpec tests, specifically the tests located in ...
Ellis Brookes's user avatar
0 votes
1 answer
157 views

How to fix a bundler error when upgrading Ruby from version 2.7.5 to version 3.0.6?

I was updating the Ruby version on my rails application. I updated from version 2.7.5 to version 3.0.6. I fixed all the broken dependencies and my project is successfully launched using the rails s ...
leonchik12's user avatar
0 votes
1 answer
73 views

RSpec superclass mismatch (Sinatra)

I have several spec files for my Sinatra API. They test a Module MysuperBlog and a class API within that Module. I have this in a RSpec config file : RSpec.shared_context 'Reset class' do after(:...
thiebo's user avatar
  • 1,405
-1 votes
2 answers
132 views

Is there a way to use Rspec let! with a scope so it can be used across multiple examples?

I'm trying to figure out a good way to handle setting rspec memoized variables that will be cleaned up after a set of tests, but not after an individual test. I'd like it to achieve something similar ...
Samuel Frost's user avatar
0 votes
2 answers
89 views

Rspec - how to test retries when raising error without using additional gem?

My code def make_error raise StandardError, 'err' end class Bob def bar(thing) puts thing end end def foo ['a', 'b'].each do |x| retry_counter = 5 begin bar(x) ...
mangocaptain's user avatar
  • 1,471

15 30 50 per page
1
2 3 4 5
537