rspec Questions
2
Solved
I would like to be able to know that my code is run under rspec or not. Is this possible?
The reason is that I am loading some error loggers that would be cluttered with deliberate errors (expect{...
Keane asked 24/7, 2014 at 11:32
7
How can I tell VCR that I want it to completely ignore a spec file?
I've read a post on Google Groups that suggests either allowing real HTTP requests, or turning VCR off explicitly.
What would b...
3
I want to stub sending email and return sample email result for further process.
Given I have:
message = GenericMailer.send_notification(id).deliver!
I want to do something like:
allow(Generic...
Guava asked 26/10, 2018 at 5:28
4
I would like my background jobs to run inline for certain marked tests. I can do it by wrapping the test with perform_enqueued do but I'd like to just be able to tag them with metadata and it happe...
Neocolonialism asked 17/5, 2016 at 16:24
4
Solved
I am new to RSPEC. I have wrote a RSPEC code named result_spec.rb as below:
describe '#grouped_scores' do
subject { result.grouped_scores }
let(:result) { create(:result, user: user) }
its(:keys...
5
Solved
I am trying to stub Time.now in RSpec as follows:
it "should set the date to the current date" do
@time_now = Time.now
Time.stub!(:now).and_return(@time_now)
@thing.capture_item("description")...
4
Solved
Say I have a method MyKlass#do_thing that I want to call exactly once in a test (because it might change a state), and that should return true on successful state change and false otherwise. I want...
5
Solved
I'm making a big change in my system, so I changed one of my main tables into a STI, and create subclasses to implement the specific behavior.
class MainProcess < ApplicationRecord
end
class P...
Ruminant asked 15/8, 2019 at 3:8
3
Solved
In my application we have few test cases which are configured with GitHub workflow,Even I do have only space related changes on file but still getting below error. Not sure why my specs are still f...
Kenn asked 19/10, 2021 at 14:40
2
How does one run rspec-mode in emacs? What I have tried is:
Go to spec file in Emacs
Run M-x rspec-verify-all
I get the following output in *rspec-compilation* buffer
-*- mode: rspec-compilati...
21
I recently upgraded to Rails 5.1 from v4.3 and am now getting this error when running tests:
An error occurred while loading
./spec/controllers/admin/capacity_charges_controller_spec.rb.
Failure...
Kraul asked 16/11, 2017 at 2:52
9
I'm trying to build an rspec test that sends JSON (or XML) via POST. However, I can't seem to actually get it working:
json = {.... data ....}.to_json
post '/model1.json',json,{'CONTENT_TYPE'=&g...
3
Solved
A user has many comments, so I would like to have a factory user with a comment associated to it (user_with_comment):
factory :user, class: User do |t|
...
factory :user_with_comment do |t|
aft...
Aircraft asked 12/2, 2015 at 16:31
3
Solved
I want to check that an array contains only objects of a specific class, let's say Float.
A working example at the moment:
it "tests array_to_test class of elements" do
expect(array_to_test.coun...
3
I have defined after_commit callback on update. It doesn't trigger in rspec.
Here is my callback :
after_commit :notify_trip, :if => Proc.new { |trip| trip.can_send_schedule_notification? }, o...
Suntan asked 26/11, 2015 at 13:44
2
Solved
How can I test rescue_from is RSpec? I'd like to make sure that if one of the exceptions is raised, that the controller correctly sets the flash and does the redirect. Is there a way to simulate th...
4
Solved
I'm starting a new app and notice some missing documentation from the last time I built a MongoID app from scratch. Namely they used to suggest on a page that no longer exists (http://mongoid.org/d...
Burchfield asked 28/4, 2011 at 22:13
4
I have a simple link_to_function in my view template
<%= link_to_function "add new category", "$('#category_name').focus()" %>
and I want to test this with capybara using request specs. Ba...
Stormie asked 29/10, 2011 at 17:34
4
Solved
Is there a way (maybe some key) to tell rspec to skip pending tests and don't print information about them?
I have some auto generated tests like
pending "add some examples to (or delete) #{__FI...
5
Solved
I have a controller based on MHartl's RoR4 Tutorial
And just like MHartl, I'm not using Devise, I rolled my own authentication system
Having trouble with the RSpec for UsersController#Edit since ...
Dyer asked 2/7, 2014 at 3:13
4
Solved
I am using Rspec in my project where I would like to print the time taken by each testcase, Is there any way Rspec is providing any prebuilt function? I can take the starting time of the testcase b...
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
5
Solved
How to test a controller action that sends a file?
If I do it with controller.should_receive(:send_file) test fails with "Missing template" because nothing gets rendered.
Obed asked 15/1, 2011 at 17:43
4
Solved
I'm new to writing tests in capybara and I'm having trouble getting the current URL of a page. I wrote it like this:
url = page.current_url + page.current_path
Somehow its just returning the bas...
11
Solved
I have a rails application which acts differently depending on what domain it's accessed at (for example www.myapp.com will invoke differently to user.myapp.com). In production use this all works f...
Sabulous asked 1/3, 2009 at 0:5
1 Next >
© 2022 - 2025 — McMap. All rights reserved.