snitch 0.1.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,21 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/snitch.rb'
3
+ require 'mocha'
4
+ require 'stubba'
5
+
6
+ class << Test::Unit::TestCase
7
+ def test(name, &block)
8
+ test_name = :"test_#{name.gsub(' ','_')}"
9
+ raise ArgumentError, "#{test_name} is already defined" if self.instance_methods.include? test_name.to_s
10
+ define_method test_name, &block
11
+ end
12
+
13
+ def expect(expected_value, &block)
14
+ define_method :"test_#{caller.first.split("/").last}" do
15
+ assert_equal expected_value, instance_eval(&block)
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ CONFIG = Snitch::Config::load
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class BaseTest < Test::Unit::TestCase
4
+ def setup
5
+ @snitch = Snitch::Base.new('/Volumes/ndwebgroup-app.railsmachina.com/var/www/apps/conductor/repos', 100)
6
+ end
7
+
8
+ test 'should add services from config file' do
9
+ assert_equal 2, @snitch.services.size
10
+ end
11
+
12
+ # Remote test, uncomment to run
13
+ # TODO: move these to remote folder so that remote and not are seperate
14
+ # test 'should be able to tattle to each service that is being used' do
15
+ # puts 'Be sure to check the live services in the config file'
16
+ # @snitch.tattle
17
+ # end
18
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ServiceTest < Test::Unit::TestCase
4
+ def setup
5
+ @s = Snitch::Service.new(:login => 'john', :password => 'secret')
6
+ end
7
+
8
+ test 'should have attributes' do
9
+ assert_equal({:login => 'john', :password => 'secret'}, @s.attributes)
10
+ end
11
+
12
+ test 'should be able to access keys in the attributes hash like reader methods' do
13
+ assert_equal 'john', @s.login
14
+ assert_equal 'secret', @s.password
15
+ end
16
+
17
+ test 'should be able to change key values in the attributes hash like writer methods' do
18
+ @s.login = 'jdog'
19
+ assert_equal 'jdog', @s.login
20
+ end
21
+
22
+ test 'should be able to set key values in the attributes hash that were not in initialize' do
23
+ @s.fart = 't'
24
+ assert_equal('t', @s.fart)
25
+ end
26
+
27
+ test 'should be able to create new instance from name' do
28
+ assert_kind_of Snitch::Services::Twitter, Snitch::Service.new_from_name(:twitter, {})
29
+ assert_kind_of Snitch::Services::Campfire, Snitch::Service.new_from_name(:campfire, {})
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class CampfireTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = CONFIG[:services][:campfire]
6
+ @service = Snitch::Services::Campfire.new(@config)
7
+ end
8
+
9
+ test 'should have attributes' do
10
+ assert_equal @config, @service.attributes
11
+ end
12
+
13
+ test 'should have a class instance attribute for the message length' do
14
+ assert_equal :long, Snitch::Services::Campfire.message_length
15
+ end
16
+
17
+ test 'should connect to campfire room' do
18
+ assert_kind_of Tinder::Room, @service.connection
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class TwitterTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = CONFIG[:services][:twitter]
6
+ @service = Snitch::Services::Twitter.new(@config)
7
+ end
8
+
9
+ test 'should have attributes' do
10
+ assert_equal @config, @service.attributes
11
+ end
12
+
13
+ test 'should have a class instance attribute for the message length' do
14
+ assert_equal :short, Snitch::Services::Twitter.message_length
15
+ end
16
+
17
+ test 'should connect to campfire room' do
18
+ assert_kind_of Twitter::Base, @service.connection
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ # TODO: move this test to remote folder
4
+
5
+ class SvnlookTest < Test::Unit::TestCase
6
+ def setup
7
+ @svnlook = Snitch::SvnLook.new(CONFIG[:sshfs_repo], 100, '/usr/local/bin/svnlook')
8
+ end
9
+
10
+ test 'should be able to build long message' do
11
+ cmt_msg = <<EOF
12
+ [conductor] Revision 100 Committed by deploy:
13
+ - Drop additions
14
+
15
+ Changed Files:
16
+ - U trunk/app/controllers/conductor_controller.rb
17
+ - A trunk/app/drops/page_drop.rb
18
+ - U trunk/app/drops/site_drop.rb
19
+ - U trunk/app/models/page.rb
20
+ EOF
21
+ assert_equal cmt_msg, @svnlook.to_s(:long)
22
+ end
23
+
24
+ test 'should be able to build short message' do
25
+ cmt_msg = "[conductor] Revision 100 Committed by deploy: - Drop additions "
26
+ assert_equal cmt_msg, @svnlook.to_s(:short)
27
+ end
28
+
29
+ test 'should be able to find author' do
30
+ assert_equal 'deploy', @svnlook.author
31
+ end
32
+
33
+ test 'should be able to find project' do
34
+ assert_equal 'conductor', @svnlook.project
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: snitch
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-03-25 00:00:00 -04:00
8
+ summary: Makes tattling on your svn commits to other services simple
9
+ require_paths:
10
+ - lib
11
+ email: nunemaker@gmail.com
12
+ homepage: http://snitch.rubyforge.org
13
+ rubyforge_project: snitch
14
+ description: Makes tattling on your svn commits to other services simple
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - John Nunemaker
31
+ files:
32
+ - Rakefile
33
+ - README.txt
34
+ - CHANGELOG.txt
35
+ - setup.rb
36
+ - lib/snitch.rb
37
+ - lib/snitch/base.rb
38
+ - lib/snitch/config.rb
39
+ - lib/snitch/exceptions.rb
40
+ - lib/snitch/patches/hash.rb
41
+ - lib/snitch/patches/tinder.rb
42
+ - lib/snitch/service.rb
43
+ - lib/snitch/services/campfire.rb
44
+ - lib/snitch/services/twitter.rb
45
+ - lib/snitch/svnlook.rb
46
+ - lib/snitch/version.rb
47
+ - test/test_helper.rb
48
+ - test/unit/base_test.rb
49
+ - test/unit/service_test.rb
50
+ - test/unit/services/campfire_test.rb
51
+ - test/unit/services/twitter_test.rb
52
+ - test/unit/svnlook_test.rb
53
+ - bin/snitch
54
+ test_files:
55
+ - test/unit/base_test.rb
56
+ - test/unit/service_test.rb
57
+ - test/unit/svnlook_test.rb
58
+ - test/unit/services/campfire_test.rb
59
+ - test/unit/services/twitter_test.rb
60
+ rdoc_options: []
61
+
62
+ extra_rdoc_files: []
63
+
64
+ executables:
65
+ - snitch
66
+ extensions: []
67
+
68
+ requirements: []
69
+
70
+ dependencies: []
71
+