Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
933 views

Write a RSpec test for method that takes a single argument

I need to write the RSpec test case for a module that has a private method and takes a single Argument. module x private def fun(para) end end I have a spec file where I tried to write a case ...
luffy's user avatar
  • 15
0 votes
1 answer
253 views

Rspec test fails while rendering

For my user controller, while running the test cases I am facing render issue. It is redirecting to http://test.host/sign_in instead of rendering new. Controller code def create @...
Sarvgna Bachchuwar's user avatar
0 votes
2 answers
1k views

How to get Host and Port configuration for Test Environment in Rspec 3.10 Rails

Hi I have a controller file at app/controllers/lti_controller.rb and I need to add Test for the POST #launch endpoint which is defined as /lti/launch in routes.rb and working as intended. Problem I ...
AYAN BISWAS's user avatar
0 votes
1 answer
1k views

Failure/Error: expect(response.status).to eq(200) rspec

i always get 302 redirect after sign_in user with in sessions request test Failure/Error: expect(response.status).to eq(200) expected: 200 got: 302 spec/requests/...
Almokhtar's user avatar
  • 144
0 votes
1 answer
115 views

Example.txt file not getting updated if test is failed in before(:all) in Rspec

Im facing an issue currently, I have my test suite written Rspec. Lets say the spec get failed in before(:all) itself, then the example.txt file is not getting updated with the failed cases. Can you ...
Lux's user avatar
  • 103
0 votes
1 answer
477 views

Rspec Testing: Coverage for controllers which accept api requests from another server not working

Attempting to write Rspec tests for a controller which accepts api requests from another server/service. The code below accepts a request launched from another service for an authenticated user in the ...
ConnemaraCartel's user avatar
1 vote
1 answer
469 views

Testing method that needs to sort hash by value in RSpec

I am trying to test my method that takes a hash and re-orders it. I currently have: def sort_views help = view_counter.sort_by { |route, length| length }.reverse.to_h p help #just so ...
Tigiras's user avatar
  • 57
0 votes
1 answer
659 views

How to mock the data from a helper method call while performing an Rspec test on a main method?

I'm trying to get the data suppose an array [1,2,3,4] from a method say helper, that is called by a main ruby method called basic, which is supposed to use that array that is being returned. How do i ...
Anu2121's user avatar
1 vote
1 answer
915 views

Cannot get shared_contexts to work in rspec 3.9.0 / rspec-rails 4

In previous versions of rspec, I could do something like: spec/models/test_spec.rb require 'rails_helper' describe 'something', :foobar do it 'does not seem to be working' do puts lol end ...
patrick's user avatar
  • 9,772
1 vote
0 answers
394 views

How to fix ActionController::UnknownFormat error for json rendered reponse in RSpec

Some of the specs are failing While upgrading ruby, rails versions. More often for the controller actions which are rendering JSON and XML responses. Old versions: ruby -v (1.9.3p551), rails -v (3.0....
Aravind Aytha's user avatar
0 votes
1 answer
730 views

When Running Rspec and Sinatra, I keep getting ArgumentError: wrong number of arguments (given 2, expected 0)

I've got a class method called authenticate, which works on the User class. def self.authenticate(email:, password:) result = DatabaseConnection.query("SELECT * FROM users WHERE email = '#{email}'"...
Bart_Judge's user avatar
0 votes
0 answers
108 views

Michael Hartl - Chapter 6 - User class becomes nil and throws undefined method `authenticate' for nil:NilClass

I'm learning Ruby on rails using http://railstutorial.org/ . While going through chapter 6 in his book. I came across my user fields becoming nil. Which in turn causes the authenticate method to fail. ...
Kaushik Vijayakumar's user avatar
0 votes
2 answers
465 views

In Rails 5.2 with Capybara, it doesn't seem like my assets are being loaded

I am attempting to run integration tests on Rails using RSpec Capybara and selenium-chrome driver. I am also using the capybara-angular gem. I'm a little confused about exactly whats going on as I ...
GGizmos's user avatar
  • 3,783
0 votes
1 answer
1k views

Rspec: How to test an exception which is getting raised in private method?

In my public method #recalculate, calling the private method1. This method throw exception 'ActiveRecord::StaleObjectError'. def recalculate method_1 self.save! end private def method_1 ...
Neelabh Singh's user avatar
1 vote
1 answer
889 views

RSpec: How to write unit test case to receive an exception which is getting raised in private method

I have implemented Optimistic Locking for Race Condition. For that, I added an extra column lock_version in the Product. Method: recalculate is calling private method_1 then it saves (save!) the ...
Neelabh Singh's user avatar

15 30 50 per page
1
2 3 4 5
77