spec/tty/system/platform_spec.rb in tty-0.0.11 vs spec/tty/system/platform_spec.rb in tty-0.1.0

- old
+ new

@@ -1,27 +1,46 @@ -# -*- encoding: utf-8 -*- +# encoding: utf-8 require 'spec_helper' describe TTY::System, '#platform' do - subject { described_class } + subject(:system) { described_class } - it { should respond_to(:windows?) } + it { is_expected.to respond_to(:windows?) } - it { should respond_to(:unix?) } + it { is_expected.to respond_to(:unix?) } - it { should respond_to(:which) } + it { is_expected.to respond_to(:which) } - it { should respond_to(:exists?) } + it { is_expected.to respond_to(:exists?) } - it { should respond_to(:editor) } + it { is_expected.to respond_to(:editor) } - it 'checks if windows' do - RbConfig::CONFIG.stub(:[]).with('host_os').and_return 'windows' - subject.windows?.should be_true + context 'windows?' do + it 'is on windows' do + allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('windows') + expect(system.windows?).to eq(true) + end + + it 'is on windows ignoring case' do + allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('Windows') + expect(system.windows?).to eq(true) + end + + it 'is not on windows' do + allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('unknown') + expect(system.windows?).to eq(false) + end end - it 'checks if unix' do - RbConfig::CONFIG.stub(:[]).with('host_os').and_return 'darwin' - subject.unix?.should be_true + context 'unix?' do + it 'checks if unix' do + allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('darwin') + expect(system.unix?).to eq(true) + end + + it 'checks if unix' do + allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('unknown') + expect(system.unix?).to eq(false) + end end end