Sha256: fcdfb6200e22c9708dd8731cc681db0a56954b40243b264ac19c75e1d5c7420a
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Receptacle module TestSupport # provides helpful method to toggle strategies during testing # # can be used in rspec like this # # require 'receptacle/test_support'y # RSpec.configure do |c| # c.include Receptacle::TestSupport # end # # RSpec.describe(UserRepository) do # around do |example| # with_strategy(strategy){example.run} # end # let(:strategy) { UserRepository::Strategy::MySQL } # ... # end # # or similar with minitest # # require 'receptacle/test_support' # class UserRepositoryTest < Minitest::Test # def described_class # UserRepository # end # def repo_exists(strategy) # with_strategy(strategy) do # assert described_class.exists(id: 5) # end # end # def test_mysql # repo_exists(UserRepository::Strategy::MySQL) # end # def test_fake # repo_exists(UserRepository::Strategy::Fake) # end # end def with_strategy(strategy, repo = described_class) original_strategy = repo.strategy repo.strategy strategy yield repo.strategy original_strategy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
receptacle-0.1.0 | lib/receptacle/test_support.rb |