rspec3 Questions
2
Solved
I am testing file upload i.e CSV. In my code as well as browser HTML I found file field but while testing the capybara is unable to find the file field. I tried hard and different approaches but un...
Nuzzi asked 13/8, 2014 at 5:33
4
I want to stub first two calls to HTTParty with raised exception and then, the third call, should return value.
before do
allow(HTTParty).to receive(:get).exactly(2).times.with(url).and_raise(H...
Cutcliffe asked 3/6, 2016 at 8:4
3
Solved
When I run this RSpec example, it passes but I'm getting a deprecation warning.
context "should have valid detail for signup" do
it "should give error for invalid confirm password" do
find("#use...
Demetri asked 13/2, 2016 at 11:57
2
Solved
I am doing the Rails Tutorial for the second time. When I enter this
rails generate integration_test static_pages
I get spec/rails_helper.rb and spec/spec_helper.rb instead of just spec/spec_he...
Paddle asked 10/6, 2014 at 15:45
2
Solved
I know there is a way to know which specs are taking the most time, but my doubt is about the loading of the RSpec. The specs itself are not taking too much time, but the load is.
There is a way to...
Tatiania asked 20/4, 2019 at 13:3
0
I have a very short function to test:
def my_fn
if some_condition
super(@my_attr)
end
end
And I want my spec to do verify that super gets called, but I can't do the following because :super a...
Tynishatynwald asked 11/10, 2019 at 18:58
2
Solved
I have this code that I want to reuse in several specs:
RSpec.shared_context "a UserWorker" do |user|
let(:mock_context_user) {{
id: 1,
brand: user.brand,
backend_token: user.backend_token
}...
Bias asked 5/8, 2016 at 16:2
3
I can test if arguments are passed like:
RSpec.describe do
it do
obj = double
expect(obj).to receive(:method).with(1, 2, 3)
obj.method(1, 2, 3)
end
end
How should I do about a block paramet...
1
I have one subject block that I want to reuse in various places.
subject(:stubbed_data) do
expect(response.body).to eq(dynamic_var)
end
The dynamic_var variable will be different for different...
Sieber asked 13/3, 2018 at 7:43
1
Solved
I'm new to Rspec and I am trying to test my controller methods for basic functionality. I know I'm not supposed to test basic functionality, but I'm doing it more for learning purposes than to buil...
Adamandeve asked 10/10, 2017 at 21:40
1
Solved
I want to test my method which runs method Temp::Service.run two times inside it:
module Temp
class Service
def self.do_job
# first call step 1
run("step1", {"arg1"=> "v1", "arg2"=>"v2"...
Toliver asked 16/5, 2017 at 13:42
3
Solved
I am developing iOS app using turbolinks-ios and Rails variant.
In my iOS app, I set custom user agent iPadApp and detect that on Rails application controller is using request.user_agent.try(:ind...
Seigneur asked 23/8, 2016 at 9:1
1
I am trying to read in Rspec 3.1 a cookie received after get call.
I see it is returned but the last_response.cookies doesn't exist.
How can I read response's cookie?
it "doesn't signs in" do
ge...
1
I'm in the process of converting my Capybara test suite from capybara-webkit to poltergeist.
-require 'capybara/webkit'
+require 'capybara/poltergeist'
-Capybara.javascript_driver = :webkit
+Capy...
Scurvy asked 26/10, 2015 at 21:36
3
Solved
I am trying to write a Git pre-commit hook that would not let the user commit if there is an example that is tagged with :focus.
Using RSpec's API (okay even if it is private), is there any way to...
3
Solved
I have a few slower specs that I would like to optimise.
The example of such spec looks like:
require 'rspec'
class HeavyComputation
def compute_result
sleep 1 # something compute heavy here
...
Hi asked 3/9, 2014 at 1:6
1
Solved
Here is my error
Failure/Error: @queue = FactoryGirl.create(model.to_s.underscore.to_sym)
RuntimeError:
let declaration `model` accessed in a `before(:context)` hook at:
/var/www/html/SQ-UI/sp...
Aryn asked 22/4, 2016 at 13:35
2
Solved
Some attributes in my model have presence validation and I wanted to add tests in my spec to check if an error is generated when the attribute is blank.
I'm using this code:
it 'should have a nam...
Acetal asked 6/6, 2015 at 14:18
1
Solved
In Ruby on Rails 4, with RSpec 3.1, how do I set the values of the params hash when testing a Rails helper method?
I want to set params[:search] = 'my keyword search' for use in my helper method a...
Sod asked 4/12, 2014 at 1:53
1
I have an option defined in application config. My class I want to test is defined in a gem (not written by me). I want to reopen the class:
Myclass.class_eval do
if Rails.application.config.myo...
Fledgling asked 7/11, 2014 at 5:5
1
Solved
I have a factory defined in <Rails-root>/spec/factories/models.rb:
FactoryGirl.define do
factory :model do
id 1
association :organization, factory: :aureso
name "Default Model"
factory...
Exemplification asked 10/1, 2016 at 5:4
5
Solved
I'm trying to set the header for some RSpec requests that require authentication. The header is ACCESS_TOKEN. No matter how I attempt to set the header, it never gets set. I know the app works beca...
Westberry asked 12/9, 2014 at 19:46
3
Solved
Since I updated my Gemfile and moved to rspec 3, in many tests, I'm getting a error for: way:
it "should reject attribute that are too short" do
short = "a" * 3
hash = @attr.merge(:details =>...
Repentance asked 7/6, 2014 at 10:32
2
Solved
I'm currently creating an object in subject and need to test if this raises an exception. The following code illustrates what I'm trying to achieve:
describe MyClass do
describe '#initialize' do
...
3
Solved
I have a rake task that guards against dangerous Rails rake rasks, based on the environment. It works fine. When I test each individual dangerous method in RSpec, the test passes. When I test multi...
Martimartial asked 4/8, 2015 at 23:50
1 Next >
© 2022 - 2024 — McMap. All rights reserved.