spec/lib/myfinance/client_spec.rb in myfinance-1.2.1 vs spec/lib/myfinance/client_spec.rb in myfinance-1.3.0
- old
+ new
@@ -1,10 +1,20 @@
require "spec_helper"
describe Myfinance::Client do
subject { client }
+ shared_examples :resource do |method, type|
+ describe "##{method}" do
+ it "instantiates a new #{type}" do
+ allow(type).to receive(:new)
+ subject.send(method)
+ expect(type).to have_received(:new).with(subject.http)
+ end
+ end
+ end
+
describe "#initialize" do
it "instantiates a new Myfinance::Http object" do
expect(Myfinance::Http).to receive(:new).with("abc", nil)
Myfinance::Client.new("abc")
end
@@ -143,6 +153,10 @@
it "instantiates a new Myfinance::Resources::Reconcile" do
expect(Myfinance::Resources::Reconcile).to receive(:new).with(subject.http)
subject.reconciles
end
end
+
+ include_examples :resource, :sales, Myfinance::Resources::Sale
+ include_examples :resource, :sale_accounts, Myfinance::Resources::SaleAccount
+ include_examples :resource, :sale_rules, Myfinance::Resources::SaleRule
end