rspec-rails Questions
5
Solved
I tried SecureRandom.random_number(9**6) but it sometimes returns 5 and sometimes 6 numbers. I'd want it to be a length of 6 consistently. I would also prefer it in the format like SecureRandom.ran...
Dunigan asked 17/5, 2017 at 17:20
1
I am trying to upload a file in rspec and use that file in my controller. Everything worked fine in Rails 4 but now in Rails 6, the Rack::Test::UploadedFile hash when received in controller, my tem...
Hodgkins asked 22/1, 2020 at 4:39
2
Solved
currently I'm running more than 1k examples and it's taking a long time to complete (more than 20 minutes!!!).
I'd like to identify which examples are the ones taking more time to complete, is the...
Shorn asked 31/1, 2011 at 21:46
2
I am trying to make parallel tests using rspec and rails 6.
According to their documentation, it is just required to add PARALLEL_WORKERS=15 where 15 is the number of workers. However, this works f...
Affright asked 27/7, 2021 at 17:53
4
Solved
I am current developing an API endpoint in rails. I want to be sure the endpoint response with the correct error status if the data I need is invalid. I need an array of ids. One of the invalid val...
Envoi asked 18/7, 2018 at 7:36
6
Solved
I have been attempting to test this method for the past few days with no luck.
Another thing I'd like to be able to do is rescue the error that bubbles up after the final retry attempt is made.
P...
Lecture asked 9/8, 2018 at 18:40
3
Solved
I've read through every similar question I could find and still can't figure out my problem.
# routes.rb
Rails.application.routes.draw do
resources :lists, only: [:index, :show, :create, :update,...
Holierthanthou asked 31/8, 2015 at 21:24
3
I want to start with TDD, but I am having this error, I am working with rvm - ruby 3.0.0 and rails 6.1.1
An error occurred while loading ./spec/models/user_spec.rb. - Did you mean?
rspec ./spec/sp...
Coppery asked 26/1, 2021 at 1:47
1
I have a simple test but the describe keyword is not working in Sorbet tests.
The error I'm receiving on these methods:
Method `describe` does not exist on `T.class_of(<root>)`7003
RSpec.des...
Tribade asked 18/12, 2022 at 16:17
4
Solved
I have the following validation in my ActiveRecord.
validates :active, :inclusion => {:in => ['Y', 'N']}
I am using the following to test my model validations.
should_not allow_value('A')...
Prohibit asked 14/9, 2011 at 11:34
2
Running rspec after upgrading Rails results in an uninitialized constant error: RSpec::Rails::Railtie::SourceAnnotationExtractor.
The backtrace points to the "rails_helper.rb" file.
I alr...
June asked 9/4, 2021 at 22:46
3
Can anybody point it out, - what is the best approach to run RSpec tests on a Rails API app inside a Docker container (during the container build/run) ?
The aim is to be able to separate the develo...
Reincarnation asked 12/7, 2019 at 13:46
4
Solved
I'm trying to test a JSON response with rspec (in Rails) by equality between [the original object].to_json and the response body. The problem is that the updated_at and created_at fields in the res...
Micronesia asked 1/10, 2013 at 22:11
3
Solved
I am writing a unit test using rspec.
I would like to mock Rails.env.develepment? to return true. How could I achieve this?.
I tried this
Rails.env.stub(:development?, nil).and_return(true)
i...
Bluefish asked 16/1, 2014 at 5:0
2
Solved
I'm trying to verify the response code of a page by using capybara. I used the expect statement as -
expect(page.status_code).to eq(404)
I'm getting the error as -
Capybara::NotSupportedByDr...
Lehman asked 5/12, 2018 at 7:8
4
Solved
I'm trying to test a method on the application controller that will be used as a before filter. To do this I have setup an anonymous controller in my test with the before filter applied to ensure t...
Edessa asked 28/2, 2011 at 21:24
2
I have to migrate some data and I'd like to test some models that use a different connection, i.e. other than one defined in database.yml develoment, test groups.
So I added a new database connecti...
Yarrow asked 27/6, 2018 at 15:44
5
Solved
Capybara is not finding my checkbox's label, and I know I'm referencing it correctly by it's label. What am I doing wrong, or is this a bug in Capybara?
According to http://rubydoc.info/github/jni...
Tournai asked 24/4, 2014 at 21:58
4
Solved
Shouldn't I be able to see instance variables which are created in a controller action from within my rspect tests?
# /app/controllers/widget_controller.rb
...
def show
@widget = ...
puts "in co...
Bennion asked 17/9, 2015 at 16:26
2
Solved
Up front, I'm using:
Ruby 2.3.1
Rails 5
rspec-rails 3.5
I've set up a mountable Rails engine with a polymorphic model that I want to use in other engines. The model class looks like this:
mo...
Otiliaotina asked 15/11, 2016 at 16:36
6
I'm trying to pass a cookie when doing a GET request, using rspec 2 and rails 3.
I've tried the following so far.
get "/", {}, {"Cookie" => "uuid=10"} # cookies[:uuid] is nil
request.cookies[:...
Cuevas asked 3/7, 2012 at 0:9
3
Solved
I am trying to get started in testing ActiveAdmin, in particular I need to test a member_action from one of the ActiveAdmin controllers.
Do you guys know any good tutorials on this topic?
Thank y...
Basildon asked 30/5, 2012 at 9:37
2
Solved
I upgraded an app to Rails 6.1.0 (from 6.0.3.3, by creating a new api-only app, adding RSpec, then copying needed files over manually).
I am seeing the following warning when I run RSpec:
DEPRECATI...
Correct asked 26/12, 2020 at 17:45
4
Solved
Given the code below:
(1) How would you go about writing a spec to test the :allow_nil => false option?
(2) Is it even worth writing a spec to test?
class Event < ActiveRecord::Base
belongs_...
Marked asked 3/2, 2012 at 3:7
6
Solved
If I add:
config.include FactoryBot::Syntax::Methods
under
RSpec.configure do |config|
and run rspec, I see this error:
/Users/perry_mac/rails_projects/mymri/spec/spec_helper.rb:21:in ...
Affenpinscher asked 3/9, 2014 at 15:39
1 Next >
© 2022 - 2025 — McMap. All rights reserved.