Last active
January 3, 2022 17:20
-
-
Save vovimayhem/eee54dd4d1b65c0a633955274eb11d48 to your computer and use it in GitHub Desktop.
Spec mocks failing on ruby 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem 'rspec', github: 'rspec/rspec-metagem', ref: 'main' | |
gem 'rspec-core', github: 'rspec/rspec-core', ref: 'main' | |
gem 'rspec-expectations', github: 'rspec/rspec-expectations', ref: 'main' | |
gem 'rspec-mocks', github: 'rspec/rspec-mocks', ref: 'main' | |
gem 'rspec-support', github: 'rspec/rspec-support', ref: 'main' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module MyExample | |
def self.my_method(argument_one, keword_argument_one: nil) | |
return true | |
end | |
def self.my_failing_method | |
my_method(a: 1) | |
end | |
def self.my_working_method | |
my_method({a: 1}) | |
end | |
end | |
RSpec.describe MyExample do | |
describe '.my_failing_method' do | |
it "doesn't call my_method with a hash" do | |
expect(described_class).not_to receive(:my_method).with({a: 1}) | |
described_class.my_failing_method | |
end | |
it 'calls my_method with keywords' do | |
expect(described_class).to receive(:my_method).with(a: 1) | |
described_class.my_failing_method | |
end | |
end | |
describe '.my_working_method' do | |
it 'calls my_method with a hash' do | |
expect(described_class).to receive(:my_method).with({a: 1}) | |
described_class.my_failing_method | |
end | |
it "doesn't call my_method with keywords" do | |
expect(described_class).not_to receive(:my_method).with(a: 1) | |
described_class.my_failing_method | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment