Sha256: b99a8633d9d195570121bf906029bc63a3e37b81c120bfa07bc46940dff1f3d5
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' module Notifiers describe Base do subject(:base) do Base.new end describe '.subclasses' do it { expect(Base.subclasses).to include(Growl, Knotify, NotifySend) } end describe '.installed?' do it 'returns false as default' do expect(Base).to_not be_installed end end describe '.darwin?' do context 'when the ruby platform is darwin' do it 'returns true' do expect(Base).to receive(:platform?).with(/darwin/).and_return(true) expect(Base.darwin?).to be true end end context 'when the ruby platform is not darwin' do it 'returns false' do expect(Base).to receive(:platform?).with(/darwin/).and_return(false) expect(Base.darwin?).to be false end end end describe '#notify' do before do expect(base).to receive(:to_s).and_return('example') end context 'when the notify command runs without error' do it 'calls system on #to_s method' do expect(base).to receive(:system).with('example').and_return(true) expect(base.notify).to be true end end context 'when the notify command runs with error' do it 'puts a install instruction if the system command returns false' do expect(base).to receive(:system).with('example').and_return(false) expect(base).to receive(:install_instructions).at_least(:once).and_return('Install') expect(base).to receive(:puts).with('Install') expect(base.notify).to be false end it 'do nothing when the instance does not have install instructions' do expect(base).to receive(:system).with('example').and_return(false) expect(base).to receive(:install_instructions).exactly(:once).and_return('') expect(base).to_not receive(:puts) expect(base.notify).to be false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
notifiers-1.2.2 | spec/notifiers/base_spec.rb |
notifiers-1.2.1 | spec/notifiers/base_spec.rb |