diff options
Diffstat (limited to 'spec')
| -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 | 
4 files changed, 27 insertions, 30 deletions
| 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 | 
