diff options
-rw-r--r-- | .rubocop_todo.yml | 28 | ||||
-rw-r--r-- | spec/githubrepo_spec.rb | 31 | ||||
-rw-r--r-- | spec/input/ssh_spec.rb | 15 | ||||
-rw-r--r-- | spec/node_spec.rb | 7 | ||||
-rw-r--r-- | spec/nodes_spec.rb | 4 |
5 files changed, 27 insertions, 58 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 81776bd..55642fc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -29,16 +29,6 @@ Layout/AccessModifierIndentation: Exclude: - 'lib/oxidized/output/gitcrypt.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: - Exclude: - - 'spec/input/ssh_spec.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -150,8 +140,6 @@ Layout/EmptyLinesAroundBlockBody: - 'lib/oxidized/model/audiocodes.rb' - 'lib/oxidized/model/ciscosma.rb' - 'lib/oxidized/model/tplink.rb' - - 'spec/input/ssh_spec.rb' - - 'spec/node_spec.rb' # Offense count: 158 # Cop supports --auto-correct. @@ -220,8 +208,6 @@ Layout/IndentHash: - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/input/ssh.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/node_spec.rb' # Offense count: 21 # Cop supports --auto-correct. @@ -381,8 +367,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'lib/oxidized/output/git.rb' - 'lib/oxidized/output/gitcrypt.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' # Offense count: 9 # Cop supports --auto-correct. @@ -697,9 +681,6 @@ Style/BracesAroundHashParameters: - 'lib/oxidized/input/telnet.rb' - 'lib/oxidized/model/procurve.rb' - 'lib/oxidized/output/http.rb' - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' - - 'spec/node_spec.rb' # Offense count: 3 Style/CaseEquality: @@ -850,13 +831,6 @@ Style/LineEndConcatenation: Exclude: - 'lib/oxidized/hook.rb' -# Offense count: 9 -# Cop supports --auto-correct. -Style/MethodCallWithoutArgsParentheses: - Exclude: - - 'spec/githubrepo_spec.rb' - - 'spec/input/ssh_spec.rb' - # Offense count: 131 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -968,7 +942,6 @@ Style/PercentLiteralDelimiters: - 'lib/oxidized/config.rb' - 'lib/oxidized/input/ssh.rb' - 'oxidized.gemspec' - - 'spec/nodes_spec.rb' # Offense count: 22 # Cop supports --auto-correct. @@ -1134,7 +1107,6 @@ Style/TrailingUnderscoreVariable: Exclude: - 'lib/oxidized/node.rb' - 'lib/oxidized/output/git.rb' - - 'spec/node_spec.rb' # Offense count: 3 # Cop supports --auto-correct. diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb index e676534..baa9a14 100644 --- a/spec/githubrepo_spec.rb +++ b/spec/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..2d1f5ce 100644 --- a/spec/input/ssh_spec.rb +++ b/spec/input/ssh_spec.rb @@ -14,23 +14,22 @@ 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, :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) 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 |