[RAILS] How to test a private method with RSpec for yourself

Conclusion

send with send

calculate_average_score is a private method

let!(:user) { create(:user) }
context 'calculate_average_score' do
  subject { user.send(:calculate_average_score) }
  it      { is_expected.to eq ** }
end

Recommended Posts

How to test a private method with RSpec for yourself
How to test private scope with JUnit
[Java] How to test for null with JUnit
How to test a private method in Java and partially mock that method
How to create a method
How to erase test image after running Rspec test with CarrierWave
[RSpec] How to write test code
[Java] How to compare with equals method
[Note] How to get started with Rspec
How to create a Maven repository for 2020
How to write an RSpec controller test
[SpringBoot] How to write a controller test
[Java] How to search for a value in an array (or list) with the contains method
How to test private methods with arrays or variadic arguments in JUnit
[Java] How to turn a two-dimensional array with an extended for statement
[Rspec] Flow from introducing Rspec to writing unit test code for a model
I want to test Action Cable with RSpec test
How to create a database for H2 Database anywhere
How to test interrupts during Thread.sleep with JUnit
How to use "sign_in" in integration test (RSpec)
How to create pagination for a "kaminari" array
How to make a lightweight JRE for distribution
How to write test code with Basic authentication
How to use nginx-ingress-controller with Docker for Mac
How to avoid exceptions with Java's equals method
How to make a judgment method to search for an arbitrary character in an array
How to test a class that handles application.properties with SpringBoot (request: pointed out)
[Rails] Test with RSpec
Test Nokogiri with Rspec.
[RSpec] I wrote a test for uploading a profile image.
How to make a factory with a model with polymorphic association
How to use an array for a TreeMap key
How to build docker environment with Gradle for intelliJ
How to unit test with JVM with source using RxAndroid
How to delete a new_record object built with Rails
How to deal with No template for interactive request
I made a method to ask for Premium Friday
How to manually generate a JWT with Rails Knock
[How to insert a video in haml with Rails]
How to mock a super method call in PowerMock
How to make Laravel faster with Docker for Mac
How to make a mod for Slay the Spire
Introduction to RSpec 4. Create test data with Factory Bot
How to get started with creating a Rails app
[RSpec] How to test error messages set by Shoulda-Matchers
[Java] How to start a new line with StringBuilder
Rspec: I want to test the post-execution state when I set a method on subject
(Java) How to implement equals () for a class with value elements added by inheritance
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
How to take a screenshot with the Android Studio emulator
How to request a CSV file as JSON with jMeter
Tutorial to create a blog with Rails for beginners Part 1
SDWebImage: How to clear the cache for a particular UIImageView
How to create a lightweight container image for Java apps
How to divide a two-dimensional array into four with ruby
How to use a foreign key with FactoryBot ~ Another solution
How to run only specific files with gem's rake test
How to leave a comment
Test Active Strage with RSpec
Learning Ruby with AtCoder 13 How to make a two-dimensional array