summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKodApa85 <parsons151185@gmail.com>2018-04-27 13:48:47 +0100
committerGitHub <noreply@github.com>2018-04-27 13:48:47 +0100
commita40bb72e78755891ec84f5a4378c30114dae8316 (patch)
tree5e057527f163fa1bea10cbdc7318b035ff939200 /spec
parentdbbe6af563072b62e373a9824c6a23482d20896e (diff)
parentf530a50a949310aa9996d764eeaaba7458b7d6b6 (diff)
Merge branch 'master' into xgs4600-cli
Diffstat (limited to 'spec')
-rw-r--r--spec/cli_spec.rb10
-rw-r--r--spec/hook/githubrepo_spec.rb (renamed from spec/githubrepo_spec.rb)31
-rw-r--r--spec/input/ssh_spec.rb20
-rw-r--r--spec/node_spec.rb7
-rw-r--r--spec/nodes_spec.rb4
-rw-r--r--spec/spec_helper.rb8
6 files changed, 45 insertions, 35 deletions
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb
index bf6058a..8b9b792 100644
--- a/spec/cli_spec.rb
+++ b/spec/cli_spec.rb
@@ -2,11 +2,11 @@ require 'spec_helper'
require 'oxidized/cli'
describe Oxidized::CLI do
- before(:each) do
- @original = ARGV
- Oxidized.asetus = Asetus.new
+ before(:each) do
+ @original = ARGV
+ Oxidized.asetus = Asetus.new
end
-
+
after(:each) do
ARGV.replace @original
end
@@ -21,7 +21,7 @@ describe Oxidized::CLI do
File.expects(:expand_path)
Kernel.expects(:exit)
- assert_output("#{Oxidized::VERSION}\n") { Oxidized::CLI.new }
+ assert_output("#{Oxidized::VERSION_FULL}\n") { Oxidized::CLI.new }
end
end
end
diff --git a/spec/githubrepo_spec.rb b/spec/hook/githubrepo_spec.rb
index e676534..67c99f0 100644
--- a/spec/githubrepo_spec.rb
+++ b/spec/hook/githubrepo_spec.rb
@@ -3,11 +3,11 @@ require 'rugged'
require 'oxidized/hook/githubrepo'
describe GithubRepo do
- let(:credentials) { mock() }
- let(:remote) { mock() }
- let(:remotes) { mock() }
- let(:repo_head) { mock() }
- let(:repo) { mock() }
+ let(:credentials) { mock }
+ let(:remote) { mock }
+ let(:remotes) { mock }
+ let(:repo_head) { mock }
+ let(:repo) { mock }
let(:gr) { GithubRepo.new }
before do
@@ -44,15 +44,15 @@ describe GithubRepo do
gr.fetch_and_merge_remote(repo).must_equal nil
end
describe "when there is update considering conflicts" do
- let(:merge_index) { mock() }
- let(:their_branch) { mock() }
+ let(:merge_index) { mock }
+ let(:their_branch) { mock }
before(:each) do
- repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns({total_deltas: 1})
+ repo.expects(:fetch).with('origin', ['refs/heads/master'], credentials: credentials).returns(total_deltas: 1)
their_branch.expects(:target_id).returns(1)
repo_head.expects(:target_id).returns(2)
repo.expects(:merge_commits).with(2, 1).returns(merge_index)
- repo.expects(:branches).returns({"origin/master" => their_branch})
+ repo.expects(:branches).returns("origin/master" => their_branch)
end
it "should not try merging when there's conflict" do
@@ -70,12 +70,11 @@ describe GithubRepo do
repo_head.expects(:target).returns("our_target")
merge_index.expects(:write_tree).with(repo).returns("tree")
merge_index.expects(:conflicts?).returns(false)
- Rugged::Commit.expects(:create).with(repo, {
- parents: ["our_target", "their_target"],
- tree: "tree",
- message: "Merge remote-tracking branch 'origin/master'",
- update_ref: "HEAD"
- }).returns(1)
+ Rugged::Commit.expects(:create).with(repo,
+ parents: ["our_target", "their_target"],
+ tree: "tree",
+ message: "Merge remote-tracking branch 'origin/master'",
+ update_ref: "HEAD").returns(1)
gr.fetch_and_merge_remote(repo).must_equal 1
end
end
@@ -101,7 +100,7 @@ describe GithubRepo do
Oxidized.config.output.git.repo = '/foo.git'
remote.expects(:url).returns('https://github.com/username/foo.git')
remote.expects(:push).with(['refs/heads/master'], credentials: credentials).returns(true)
- repo.expects(:remotes).returns({'origin' => remote})
+ repo.expects(:remotes).returns('origin' => remote)
Rugged::Repository.expects(:new).with('/foo.git').returns(repo)
end
diff --git a/spec/input/ssh_spec.rb b/spec/input/ssh_spec.rb
index 7be9139..3c33cd8 100644
--- a/spec/input/ssh_spec.rb
+++ b/spec/input/ssh_spec.rb
@@ -14,23 +14,27 @@ describe Oxidized::SSH do
model: 'junos',
username: 'alma',
password: 'armud',
- vars: {ssh_proxy: 'test.com'})
-
+ vars: { ssh_proxy: 'test.com' })
end
describe "#connect" do
it "should use proxy command when proxy host given" do
ssh = Oxidized::SSH.new
- model = mock()
- model.expects(:cfg).returns({'ssh' => []})
+ model = mock
+ model.expects(:cfg).returns('ssh' => [])
@node.expects(:model).returns(model).at_least_once
- proxy = mock()
+ proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W %h:%p").returns(proxy)
- Net::SSH.expects(:start).with('93.184.216.34', 'alma', {:port => 22, :password => 'armud', :timeout => Oxidized.config.timeout,
- :paranoid => Oxidized.config.input.ssh.secure, :auth_methods => ['none', 'publickey', 'password', 'keyboard-interactive'],
- :number_of_password_prompts => 0, :proxy => proxy})
+ Net::SSH.expects(:start).with('93.184.216.34', 'alma', port: 22,
+ timeout: Oxidized.config.timeout,
+ paranoid: Oxidized.config.input.ssh.secure,
+ keepalive: true,
+ proxy: proxy,
+ password: 'armud',
+ number_of_password_prompts: 0,
+ auth_methods: %w[none publickey password])
ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index 829e05a..f769751 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -14,7 +14,6 @@ describe Oxidized::Node do
username: 'alma',
password: 'armud',
prompt: 'test_prompt')
-
end
describe '#new' do
@@ -39,7 +38,7 @@ describe Oxidized::Node do
it 'should fetch the configuration' do
stub_oxidized_ssh
- status, _ = @node.run
+ status, = @node.run
status.must_equal :success
end
end
@@ -52,9 +51,9 @@ describe Oxidized::Node do
let(:group) { nil }
let(:node) do
- Oxidized::Node.new({
+ Oxidized::Node.new(
ip: '127.0.0.1', group: group, model: 'junos'
- })
+ )
end
it 'when there are no groups' do
diff --git a/spec/nodes_spec.rb b/spec/nodes_spec.rb
index 6fa4b41..a801107 100644
--- a/spec/nodes_spec.rb
+++ b/spec/nodes_spec.rb
@@ -17,8 +17,8 @@ describe Oxidized::Nodes do
Oxidized::Node.any_instance.stubs(:resolve_repo)
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(opts.merge(name: e)) }
+ @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(opts.merge(name: e)) }
@node = @nodes_org.delete_at(0)
@nodes = Oxidized::Nodes.new(nodes: @nodes_org.dup)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2b49a6c..fc5167f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,11 @@
+require 'simplecov'
+SimpleCov.start
+
+if ENV['CI'] == 'true'
+ require 'codecov'
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
+end
+
require 'minitest/autorun'
require 'mocha/minitest'
require 'oxidized'