spectate 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Spectate::Encode do
4
+ include Spectate::Encode
5
+ describe "encoding" do
6
+ it "changes spaces to underscores" do
7
+ encode("I am the very model of a modern Major General").should == "I_am_the_very_model_of_a_modern_Major_General"
8
+ end
9
+
10
+ it "changes underscores to double underscores" do
11
+ encode("snake_case is too_cool").should == "snake__case_is_too__cool"
12
+ end
13
+
14
+ it "CGI-encodes everything else" do
15
+ encode("2 + 1 is equal_to 5 & that's a fact!").should == "2_%2B_1_is_equal__to_5_%26_that%27s_a_fact%21"
16
+ end
17
+ end
18
+
19
+ describe "decoding" do
20
+ it "changes underscores to spaces" do
21
+ decode("I_am_the_very_model_of_a_modern_Major_General").should == "I am the very model of a modern Major General"
22
+ end
23
+
24
+ it "changes double underscores to spaces" do
25
+ decode("snake__case_is_too__cool").should == "snake_case is too_cool"
26
+ end
27
+
28
+ it "CGI-encodes everything else" do
29
+ decode("2_%2B_1_is_equal__to_5_%26_that%27s_a_fact%21").should == "2 + 1 is equal_to 5 & that's a fact!"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ # Basic server settings
3
+ rackup: true
4
+ server: webrick
5
+ host: localhost
6
+ port: 47502 # The inverse of 20574, the production port
7
+ env: test
@@ -0,0 +1,27 @@
1
+ require 'tmpdir'
2
+ require 'fileutils'
3
+
4
+ module Spectate
5
+ module Spec
6
+ module ConfigHelpers
7
+ def set_tempdir
8
+ @tempparent = Dir.mktmpdir
9
+ @tempdir = File.join(@tempparent, '.spectate')
10
+ @configfile = File.join(@tempdir, 'config.yml')
11
+ end
12
+
13
+ def create_config
14
+ @tempdir = Dir.mktmpdir
15
+ @configfile = File.join(@tempdir, 'config.yml')
16
+ FileUtils.cp File.join(File.dirname(__FILE__), '..', 'files', 'config.yml'), @configfile
17
+ FileUtils.cp File.join(File.dirname(__FILE__), '..', '..', 'generators', 'config.ru'), @tempdir
18
+ FileUtils.ln_s File.expand_path(File.join(File.dirname(__FILE__), '..','..')), File.join(@tempdir,'src')
19
+ ENV['SPECTATE_DIR'] = @tempdir
20
+ end
21
+
22
+ def remove_config
23
+ FileUtils.rm_r @tempdir, :force => true, :secure => true
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ require 'helpers/config_helpers'
2
+
3
+ module Spectate
4
+ module Spec
5
+ module ServerHelpers
6
+ include ConfigHelpers
7
+
8
+ def start_server
9
+ create_config
10
+ call = `spectate`
11
+ puts call unless call =~ /Starting Spectate on \S+:\d+\.\.\.\s*$/m
12
+ end
13
+
14
+ def stop_server
15
+ `spectate --stop`
16
+ remove_config
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Spectate, "ping method" do
4
+ include Spectate::Spec::ServerHelpers
5
+
6
+ include Spectate::Ping
7
+
8
+ it "returns nil if no Spectate server is running" do
9
+ create_config
10
+ ping.should be_nil
11
+ remove_config
12
+ end
13
+
14
+ it "returns a Status object if a Spectate server is running" do
15
+ start_server
16
+ ping.should be_a_kind_of(Spectate::Status)
17
+ stop_server
18
+ end
19
+
20
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'net/http'
3
+ require 'rufus-tokyo'
4
+
5
+ describe Spectate::Server do
6
+ include Spectate::Spec::ServerHelpers
7
+ before(:all) do
8
+ start_server
9
+ end
10
+ it "responds to GET" do
11
+ response = Net::HTTP.get_response('localhost','/',47502)
12
+ response.code.to_i.should == 200
13
+ end
14
+
15
+ it "responds to a GET with its name and version number" do
16
+ response = Net::HTTP.get_response('localhost','/',47502)
17
+ response.body.should =~ /Spectate v#{Spectate::VERSION}/
18
+ end
19
+ after(:all) do
20
+ stop_server
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,25 @@
1
+ require 'spec'
2
+
3
+ SPECDIR = File.dirname(__FILE__)
4
+
5
+ $LOAD_PATH.unshift(SPECDIR)
6
+ $LOAD_PATH.unshift(File.join(SPECDIR, '..', 'lib'))
7
+
8
+ # Make sure the binary is in our path
9
+ ENV['PATH'] = File.expand_path(File.join(SPECDIR, '..', 'bin')) + ':' + ENV['PATH']
10
+
11
+ require 'spectate'
12
+ # Get rid of the pre-set base directory, because we don't want to test on live configurations
13
+ Spectate.send(:remove_const, :ROOT_DIR)
14
+ Spectate.const_set(:ROOT_DIR,nil)
15
+
16
+ require 'helpers/config_helpers'
17
+ require 'helpers/server_helpers'
18
+
19
+ Spec::Runner.configure do |config|
20
+
21
+ # "And how do you take your coffee, Agent Cooper?"
22
+ # "Black as midnight on a moonless night."
23
+ config.mock_with :mocha
24
+
25
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Spectate" do
4
+
5
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Spectate::RootSpectator do
4
+ before(:each) do
5
+
6
+ end
7
+ it "does not have a parent" do
8
+
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Spectate::Spectator do
4
+ it "fails without a path" do
5
+ lambda{Spectate::Spectator.new(nil)}.should raise_error(Spectate::CreationError)
6
+ end
7
+
8
+ it "fails if the parent doesn't exist" do
9
+ pending
10
+ Spectate::Spectator.clear_all!
11
+ lambda{Spectate::Spectator.new("/foo")}.should raise_error(Spectate::CreationError)
12
+ end
13
+
14
+ describe "root node" do
15
+ it "creates the Spectator tree if it didn't already exist" do
16
+ pending
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Spectate::Status do
4
+
5
+ before(:each) do
6
+ @this = Spectate::Status.new("http://localhost:47502", '/test/foo/bar_camp', :foo => 'bar', :yoo => 'yar')
7
+ end
8
+
9
+ it "behaves like a hash" do
10
+ @this[:foo].should == 'bar'
11
+ end
12
+
13
+ it "behaves like a struct" do
14
+ @this.yoo.should == 'yar'
15
+ end
16
+
17
+ it "cannot be altered" do
18
+ lambda{@this[:foo] = 5}.should raise_error
19
+ end
20
+
21
+ it "knows its source" do
22
+ @this.source.should == '/test/foo/bar_camp'
23
+ end
24
+
25
+ it "knows its name" do
26
+ @this.name.should == 'bar camp'
27
+ end
28
+
29
+ it "knows its parent" do
30
+ @this.parent.should == '/test/foo'
31
+ end
32
+
33
+ it "knows its server" do
34
+ @this.server.should == 'http://localhost:47502'
35
+ end
36
+
37
+ it "knows its other properties" do
38
+ @this.properties.should have(2).elements
39
+ @this.properties.should include(:foo, :yoo)
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Spectate::Tree do
4
+ class Dummy
5
+ include Spectate::Tree
6
+ end
7
+
8
+ before(:all) do
9
+ create_config
10
+ @dbfile = File.join(@tempdir, 'spectate.tcb')
11
+ @this = Dummy.new
12
+ end
13
+
14
+ it "creates the Tokyo Cabinet tree if it didn't exist" do
15
+ File.exists?(@dbfile).should be_true
16
+ end
17
+
18
+ it "initializes the root if it wasn't already" do
19
+ root = nil
20
+ Rufus::Tokyo::Cabinet.open(@dbfile, :mode => 'r') do |db|
21
+ root = db['/']
22
+ end
23
+ root.should == 'RootSpectator'
24
+ end
25
+
26
+ after(:all) do
27
+ remove_config
28
+ end
29
+ end
@@ -0,0 +1,68 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{spectate}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Stephen Eley"]
9
+ s.date = %q{2009-05-31}
10
+ s.default_executable = %q{spectate}
11
+ s.email = %q{sfeley@gmail.com}
12
+ s.executables = ["spectate"]
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".document",
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "bin/spectate",
25
+ "features/command.feature",
26
+ "features/step_definitions/command_steps.rb",
27
+ "features/step_definitions/spectate_steps.rb",
28
+ "features/support/env.rb",
29
+ "lib/spectate.rb",
30
+ "lib/spectate/command.rb",
31
+ "spec/command_spec.rb",
32
+ "spec/spec_helper.rb",
33
+ "spec/spectate_spec.rb"
34
+ ]
35
+ s.has_rdoc = true
36
+ s.homepage = %q{http://github.com/SFEley/spectate}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.requirements = ["Tokyo Cabinet (easily installed from apt, MacPorts, etc.)"]
40
+ s.rubyforge_project = %q{spectate}
41
+ s.rubygems_version = %q{1.3.1}
42
+ s.summary = %q{General event framework for testing and monitoring}
43
+ s.test_files = [
44
+ "spec/command_spec.rb",
45
+ "spec/config_spec.rb",
46
+ "spec/spec_helper.rb",
47
+ "spec/spectate_spec.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 2
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
56
+ s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
57
+ s.add_runtime_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 1.2.6"])
60
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
61
+ s.add_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 1.2.6"])
65
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
66
+ s.add_dependency(%q<rufus-tokyo>, [">= 0.1.12"])
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spectate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Eley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-20 00:00:00 -04:00
13
+ default_executable: spectate
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.6
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.5
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rufus-tokyo
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.12
44
+ version:
45
+ description:
46
+ email: sfeley@gmail.com
47
+ executables:
48
+ - spectate
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - api.mdown
62
+ - bin/spectate
63
+ - features/command.feature
64
+ - features/step_definitions/command_steps.rb
65
+ - features/step_definitions/spectate_steps.rb
66
+ - features/support/env.rb
67
+ - generators/config.ru
68
+ - lib/spectate.rb
69
+ - lib/spectate/client.rb
70
+ - lib/spectate/command.rb
71
+ - lib/spectate/config.rb
72
+ - lib/spectate/encode.rb
73
+ - lib/spectate/ping.rb
74
+ - lib/spectate/server.rb
75
+ - lib/spectate/status.rb
76
+ - spec/client_spec.rb
77
+ - spec/command_spec.rb
78
+ - spec/config_spec.rb
79
+ - spec/encode_spec.rb
80
+ - spec/files/config.yml
81
+ - spec/helpers/config_helpers.rb
82
+ - spec/helpers/server_helpers.rb
83
+ - spec/ping_spec.rb
84
+ - spec/server_spec.rb
85
+ - spec/spec.opts
86
+ - spec/spec_helper.rb
87
+ - spec/spectate_spec.rb
88
+ - spec/status_spec.rb
89
+ - spectate.gemspec
90
+ has_rdoc: true
91
+ homepage: http://github.com/SFEley/spectate
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ version:
111
+ requirements:
112
+ - Tokyo Cabinet (easily installed from apt, MacPorts, etc.)
113
+ rubyforge_project: spectate
114
+ rubygems_version: 1.3.5
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: General event framework for testing and monitoring
118
+ test_files:
119
+ - spec/client_spec.rb
120
+ - spec/command_spec.rb
121
+ - spec/config_spec.rb
122
+ - spec/encode_spec.rb
123
+ - spec/helpers/config_helpers.rb
124
+ - spec/helpers/server_helpers.rb
125
+ - spec/ping_spec.rb
126
+ - spec/server_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/spectate_spec.rb
129
+ - spec/spectators/root_spec.rb
130
+ - spec/spectators/spectator_spec.rb
131
+ - spec/status_spec.rb
132
+ - spec/tree_spec.rb