spec/lib/cli_spec.rb in zabbix-ruby-client-0.0.17 vs spec/lib/cli_spec.rb in zabbix-ruby-client-0.0.18

- old
+ new

@@ -2,12 +2,50 @@ require 'spec_helper' require "zabbix-ruby-client/cli" describe ZabbixRubyClient::Cli do - - pending "init creates a working directory" - pending "show displays the list of data collected" - pending "upload collects and uploads the data from system" - pending "when a custom config file is specified it's taken in account" -end \ No newline at end of file + before :each do + @cli = ZabbixRubyClient::Cli.new( + [], + { + 'configfile' => 'config.yml', + 'taskfile' => 'minutely.yml' + } + ) + @testdir = File.join('spec','files','test-client') + @cli.shell.mute do + @cli.init(@testdir) + end + @oldpwd = Dir.pwd + Dir.chdir @testdir + end + + after :each do + Dir.chdir @oldpwd + FileUtils.rm_rf @testdir if Dir.exists? @testdir + end + + it "init creates a working directory" do + expect(File.file? 'Gemfile').to be_true + end + + it "show displays the list of data collected" do + ZabbixRubyClient::Runner.stub(:new).and_return(Object) + Object.stub(:collect) + Object.stub(:show) + @cli.shell.mute do + @cli.show + end + end + + it "upload collects and uploads the data from system" do + ZabbixRubyClient::Runner.stub(:new).and_return(Object) + Object.stub(:collect) + Object.stub(:upload) + @cli.shell.mute do + @cli.upload + end + end + +end