overwatch 0.0.3.pre → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Overwatch
4
- describe Client do
5
- let(:server_url) { "http://api.overwatchapp.com" }
6
- let(:client_key) { "asdf1234" }
7
-
8
- describe "#load_config" do
9
- let(:client) { Overwatch::Client.new }
10
-
11
- before do
12
- File.open(Overwatch.config_file_path, "w") do |file|
13
- file.puts "server_url: http://api.overwatchapp.com"
14
- file.puts "client_key: asdf1234"
15
- end
16
- end
17
-
18
- it "loads up the configuration file" do
19
- client.load_config
20
- client.server_url.should == "http://api.overwatchapp.com"
21
- client.client_key.should == "asdf1234"
22
- end
23
- end
24
-
25
- describe "#get_plugin_manifest" do
26
- let(:client) { Overwatch::Client.new }
27
-
28
- before do
29
- stub_get_plugin_manifest
30
- end
31
-
32
- it "retrieves a plugins manifest from the server" do
33
- client.get_plugin_manifest
34
- client.plugin_manifest.should == plugin_manifest_response
35
- end
36
- end
37
-
38
- describe "#sync_plugins" do
39
- let(:client) { Overwatch::Client.new }
40
-
41
- before do
42
- Overwatch.install
43
- stub_get_plugin_manifest
44
- stub_sync_plugins
45
- client.get_plugin_manifest
46
- end
47
-
48
- it "downloads plugins to the cache directory" do
49
- client.sync_plugins
50
- File.exist?(File.join(Overwatch.plugin_dir, "foo_plugin.rb")).should be_true
51
- File.exist?(File.join(Overwatch.plugin_dir, "bar_plugin.rb")).should be_true
52
- File.open(File.join(Overwatch.plugin_dir, "bar_plugin.rb")).read.should include("class BarPlugin")
53
-
54
- end
55
- end
56
- end
57
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Overwatch do
4
- before do
5
- ENV['HOME'] = "/home/user"
6
- end
7
-
8
- describe '.run' do
9
- let(:config_file) { mock('config_file') }
10
-
11
- before do
12
- end
13
-
14
- it "creates the required application files" do
15
- FileUtils.should_receive(:mkdir_p).with(Overwatch.base_dir)
16
- FileUtils.should_receive(:touch).with(Overwatch.log_file_path)
17
- FileUtils.should_receive(:mkdir_p).with(Overwatch.cache_dir)
18
- FileUtils.should_receive(:mkdir_p).with(Overwatch.plugin_dir)
19
- FileUtils.should_receive(:mkdir_p).with(Overwatch.config_dir)
20
-
21
- File.should_receive(:open).
22
- with(Overwatch.config_file_path, "w").
23
- and_yield(config_file)
24
- config_file.should_receive(:puts).
25
- with('server_url: http://api.overwatchapp.com')
26
- config_file.should_receive(:puts).
27
- with('client_key: CHANGEME')
28
- Overwatch.install
29
- end
30
- end
31
-
32
- context "logging" do
33
- describe '.log_file_path' do
34
- it "returns '/home/user/.overwatch/client.log'" do
35
- Overwatch.log_file_path.should == "/home/user/.overwatch/client.log"
36
- end
37
- end
38
-
39
- describe '.log_file_path=' do
40
- it "sets @log_file_path" do
41
- Overwatch.log_file_path = "/tmp/something.log"
42
- Overwatch.log_file_path.should == "/tmp/something.log"
43
- end
44
- end
45
-
46
- describe '.log' do
47
- it "functions as a logger" do
48
- Overwatch.log.should be_an_instance_of(Logger)
49
- lambda { Overwatch.log.info "TEST" }.should_not raise_error
50
- end
51
- end
52
- end
53
-
54
- context "environment" do
55
- describe '.env=' do
56
- it "sets the @env variable" do
57
- Overwatch.env = "pants"
58
- Overwatch.env.should == "pants"
59
- end
60
- end
61
-
62
- describe '.env' do
63
- it "returns 'test' inside specs" do
64
- Overwatch.env.should == "test"
65
- end
66
- end
67
- end
68
- end
@@ -1,8 +0,0 @@
1
- # class BarPlugin # < Overwatch::Plugin
2
- # name = "bar_plugin"
3
- # desc = "A test plugin to determine whether plugin sync works"
4
- #
5
- # def run
6
- # { :bar => 'bar' }
7
- # end
8
- # end
@@ -1,65 +0,0 @@
1
- def stub_get_plugin_manifest
2
- stub_request(:get, "#{server_url}/nodes/#{client_key}/plugins").
3
- to_return(
4
- :status => 200,
5
- :body => %Q{
6
- [
7
- {
8
- "name": "foo_plugin",
9
- "checksum": "qwer5678"
10
- },
11
- {
12
- "name": "bar_plugin",
13
- "checksum": "hjkl4321"
14
- }
15
- ]
16
- }
17
- )
18
- end
19
-
20
- def plugin_manifest_response
21
- [
22
- {
23
- "name" => "foo_plugin",
24
- "checksum" => "qwer5678"
25
- },
26
- {
27
- "name" => "bar_plugin",
28
- "checksum" => "hjkl4321"
29
- }
30
- ]
31
- end
32
-
33
- def stub_sync_plugins
34
- stub_request(:get, "#{server_url}/plugins/foo_plugin").
35
- to_return(:body => stub_foo_plugin)
36
-
37
- stub_request(:get, "#{server_url}/plugins/bar_plugin").
38
- to_return(:body => stub_bar_plugin)
39
- end
40
-
41
- def stub_foo_plugin
42
- %|
43
- class FooPlugin < Overwatch::Plugin
44
- name "foo_plugin"
45
- desc "A test plugin to determine whether plugin sync works"
46
-
47
- def run
48
- { :foo => 'foo' }
49
- end
50
- end
51
- |
52
- end
53
-
54
- def stub_bar_plugin
55
- %|
56
- class BarPlugin < Overwatch::Plugin
57
- name "bar_plugin"
58
- desc "A test plugin to determine whether plugin sync works"
59
-
60
- def run
61
- { :bar => 'bar' }
62
- end
63
- end
64
- |
65
- end
@@ -1,8 +0,0 @@
1
- # class FooPlugin # < Overwatch::Plugin
2
- # name = "foo_plugin"
3
- # desc = "A test plugin to determine whether plugin sync works"
4
- #
5
- # def run
6
- # { :foo => 'foo' }
7
- # end
8
- # end
@@ -1,3 +0,0 @@
1
- def test
2
- puts "Is it working? :("
3
- end