# Generated from mock_proxy-0.4.6.gem by gem2rpm -*- rpm-spec -*- %global gem_name mock_proxy Name: rubygem-%{gem_name} Version: 0.4.6 Release: 1%{?dist} Summary: A proxy that can be used to stub method chains and more! License: MIT URL: https://github.com/matrinox/MockProxy Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby >= 2.3.0 BuildArch: noarch %description Remember when RSpec had stub_chain? They removed it for good reasons but sometimes you just need it. Well, here it is, a proxy object. It doesn't actually mock anything for you (the name is just catchy) so you need to do that. But that actually comes with a lot of benefits: 1) It's compatable with any testing framework 2) You can use it for purposes other than testing, e.g. prototyping, code stubs 3) Flexibility in how you use it without overloading the number of methods you have to remember Here's an example usage: let(:model_proxy) do MockProxy.new(email_client: { create_email: { receive: proc {} } }) end before { allow(Model).to receive(:new).and_return model_proxy } it 'should call receive' do proc = MockProxy.get(model_proxy, 'email_client.create_email.receive') expect(proc).to receive(:call) run_system_under_test MockProxy.update(mock_proxy, 'email_client.create_email.validate!') { true } MockProxy.observe(mock_proxy, 'email_client.create_email.send') do |to| expect(to).to eq 'stop@emailing.me' end run_system_under_test2 end As you can see, the proc - which ends the proxy by calling the proc - can be used for anything. You can spy on the call count and arguments, mock methods, or just stub out code you don't want executed. Because it doesn't make any assumptions, it becomes very flexible. Simple, yet powerful, it's uses are infinite. Enjoy. %package doc Summary: Documentation for %{name} Requires: %{name} = %{version}-%{release} BuildArch: noarch %description doc Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} %build # Create the gem as gem install only works on a gem file gem build ../%{gem_name}-%{version}.gemspec # %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir # by default, so that we can move it into the buildroot in %%install %gem_install %install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* \ %{buildroot}%{gem_dir}/ %check pushd .%{gem_instdir} # Run the test suite. popd %files %dir %{gem_instdir} %exclude %{gem_instdir}/.gitignore %{gem_instdir}/CODE_OF_CONDUCT.md %license %{gem_instdir}/LICENSE %license %{gem_instdir}/LICENSE.txt %{gem_instdir}/bin %{gem_libdir} %exclude %{gem_cache} %{gem_spec} %files doc %doc %{gem_docdir} %{gem_instdir}/Gemfile %doc %{gem_instdir}/README.md %{gem_instdir}/Rakefile %{gem_instdir}/mock_proxy.gemspec %changelog * Tue Sep 14 2021 mockbuilder - 0.4.6-1 - Initial package