summaryrefslogtreecommitdiff
path: root/spec/nodes_spec.rb
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2016-01-04 18:50:54 +0200
committerytti <saku@ytti.fi>2016-01-04 18:50:54 +0200
commit0eeba91b426c8b4a6335a88da9c65ba38e5fac15 (patch)
tree02ba46c4f7d43b5721f3eb7de38599e0e019e5cf /spec/nodes_spec.rb
parentf112dfa0c604ae1c990f6411a002806924c00bf3 (diff)
parente41f7b429901eb38ad785ad1fc2527dd41f35959 (diff)
Merge pull request #250 from Shopify/master0.10.0
refactoring, test coverage and github hook
Diffstat (limited to 'spec/nodes_spec.rb')
-rw-r--r--spec/nodes_spec.rb35
1 files changed, 23 insertions, 12 deletions
diff --git a/spec/nodes_spec.rb b/spec/nodes_spec.rb
index 80ed300..5f2ef95 100644
--- a/spec/nodes_spec.rb
+++ b/spec/nodes_spec.rb
@@ -1,33 +1,44 @@
-require 'oxidized'
-Oxidized.mgr = Oxidized::Manager.new
+require 'spec_helper'
describe Oxidized::Nodes do
before(:each) do
+ Resolv.any_instance.stubs(:getaddress)
+ Oxidized.stubs(:asetus).returns(Asetus.new)
+ opts = {
+ input: 'ssh',
+ output: 'git',
+ model: 'junos',
+ username: 'alma',
+ password: 'armud',
+ prompt: 'test_prompt'
+ }
+
+ Oxidized::Node.any_instance.stubs(:resolve_output)
@nodes_org = %w(ltt-pe1.hel kes2-rr1.tku tor-peer1.oul
- hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel).map { |e| Oxidized::Node.new(:name=>e) }
- @nodes = Oxidized::Nodes.new @nodes_org.dup
+ hal-p2.tre sav-gr1-sw1.kuo psl-sec-pe1.hel).map { |e| Oxidized::Node.new(opts.merge(name: e)) }
+ @node = @nodes_org.delete_at(0)
+ @nodes = Oxidized::Nodes.new(nodes: @nodes_org.dup)
end
describe '#put' do
it 'adds node to top of queue' do
- node = Oxidized::Node.new(:name=>'kst-p1.sto')
- @nodes.put node
- expect(@nodes).to eq [node] + @nodes_org
+ @nodes.put @node
+ @nodes.must_equal [@node] + @nodes_org
end
end
describe '#get' do
it 'returns node from top of queue' do
- expect(@nodes.get).to eq @nodes_org.first
+ @nodes.get.must_equal @nodes_org.first
end
it 'moves node from top to bottom' do
@nodes.get
- expect(@nodes).to end_with [@nodes_org.first]
+ @nodes.last.must_equal @nodes_org.first
end
it 'does not change node count' do
before = @nodes.size
@nodes.get
- expect(before).to eq @nodes.size
+ before.must_equal @nodes.size
end
end
@@ -35,12 +46,12 @@ describe Oxidized::Nodes do
it 'moves node to top of queue' do
node = @nodes[3]
@nodes.next node.name
- expect(@nodes).to start_with [node]
+ @nodes.first.must_equal node
end
it 'does not change node count' do
before = @nodes.size
@nodes.next @nodes[3].name
- expect(before).to eq @nodes.size
+ before.must_equal @nodes.size
end
end
end