spec/blocks_spec.rb in sloe-0.8.7 vs spec/blocks_spec.rb in sloe-0.8.9

- old
+ new

@@ -1,52 +1,41 @@ require 'spec_helper' describe Sloe do - context "invoked with block" do - before(:all) do - @login = { - :target => 'capella', - :username => 'netconf', - :password => 'netconf' - } - @hostname = '' - end + let(:host) { ENV['hosts'].split(':').first } + let(:login) do + { + target: Envyable.load('/tmp/env.yaml', host)['ip_address'], + username: 'root', + password: 'Juniper', + port: Envyable.load('/tmp/env.yaml', host)['ssh_port'], + snmp_port: 1161 + } + end - it "calls Netconf RPC" do - Sloe::Device.new( @login ) { |dut| - sw_info = dut.rpc.get_system_information - @hostname = sw_info.xpath('//host-name').text - } - @hostname.should include @login[:target] + context 'invoked with block' do + it 'calls Netconf RPC' do + hostname = '' + Sloe::Device.new(login) do |dut| + hostname = dut.rpc.get_system_information.xpath('//host-name').text + end + expect(hostname).to include host end - it "calls SNMP RPC" do - Sloe::Device.new ( @login ) { |dut| - @hostname = dut.snmp.get_value( 'sysName.0' ).to_s - } - @hostname.should include @login[:target] + it 'calls SNMP RPC' do + hostname = '' + Sloe::Device.new(login) do |dut| + hostname = dut.snmp.get_value('sysName.0').to_s + end + expect(hostname).to include host end - end - context "Junos extensions" do - before(:all) do - @login = { - :target => 'capella', - :username => 'netconf', - :password => 'netconf' - } + context 'Junos extensions' do + it 'Sloe::Junos responds to Junos specific RPCs' do + expect(Sloe::Junos.new(login).rpc).to respond_to(:lock_configuration) end - - it "Sloe::Junos responds to Junos specific RPCs" do - Sloe::Junos.new ( @login ) { |dut| - dut.rpc.respond_to?(:lock_configuration).should be true - } + it 'Sloe::Device does not respond to Junos specific RPCs' do + expect(Sloe::Device.new(login).rpc).to_not respond_to(:lock_configuration) end - it "Sloe::Device does not respond to Junos specific RPCs" do - Sloe::Device.new ( @login ) { |dut| - dut.rpc.respond_to?(:lock_configuration).should be false - } - end - end -end \ No newline at end of file +end