-
-
Save paulsonkoly/27e3fdd9e2cddcd809cebd7145525f2e to your computer and use it in GitHub Desktop.
private stub
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
require 'rspec/autorun' | |
class X | |
def call | |
fund_query | |
end | |
private | |
def fund_qeuery | |
raise 'DB acces' | |
end | |
end | |
RSpec.describe X do | |
let(:x) { X.new } | |
before do | |
# allow(x).to receive(:foo).and_call_original | |
allow(x).to receive(:fund_query).and_return(13) | |
end | |
it 'is 13' do | |
expect(x.call).to eq 13 | |
end | |
end | |
# >> | |
# >> Randomized with seed 49010 | |
# >> . | |
# >> | |
# >> Top 1 slowest examples (0.00634 seconds, 52.3% of total time): | |
# >> X is 13 | |
# >> 0.00634 seconds /var/folders/6h/wj2by4nn7716wzgzgdbh7twmt3k49g/T/seeing_is_believing_temp_dir20200127-89638-1byy5jg/program.rb:23 | |
# >> | |
# >> Finished in 0.01212 seconds (files took 0.12542 seconds to load) | |
# >> 1 example, 0 failures | |
# >> | |
# >> Randomized with seed 49010 | |
# >> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment