Skip to content
This repository was archived by the owner on Sep 15, 2018. It is now read-only.

Commit 7e5a5ea

Browse files
committed
Adding some actual tests. Crazy.
1 parent 164971a commit 7e5a5ea

File tree

8 files changed

+74
-3
lines changed

8 files changed

+74
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
coverage
44
rdoc
55
pkg
6+
tmp

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ require 'spec/rake/spectask'
5656
Spec::Rake::SpecTask.new(:spec) do |spec|
5757
spec.libs << 'lib' << 'spec'
5858
spec.spec_files = FileList['spec/**/*_spec.rb']
59+
spec.spec_opts = ['--colour', '--format specdoc', '--loadby mtime', '--reverse']
5960
end
6061

6162
Spec::Rake::SpecTask.new(:rcov) do |spec|

lib/captured.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def self.run_once!(options)
2121
end
2222
end
2323

24+
# Depricated this is now handeled by launchd
2425
def self.run_and_watch!(options)
2526
require 'captured/fs_events'
2627
watch_path = options[:watch_path] || "#{ENV['HOME']}/Desktop/"

spec/bin/mockgrowlnotify

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env ruby
2+
puts " Grrrr!"

spec/captured_spec.rb

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
22

3-
describe "Captured" do
4-
it "fails" do
5-
fail "hey buddy, you should probably rename this file and start specing for real"
3+
describe "File Uploader" do
4+
before(:all) do
5+
# This is run once and only once, before all of the examples
6+
7+
#Make a backup of the clipboard
8+
$pb_backup = `pbpaste`
9+
10+
system "mkdir -p #{File.dirname(__FILE__) + '/../tmp/watch_path'}"
11+
@options = {:config_file => File.dirname(__FILE__) + '/fixtures/scp_config.yml',
12+
:watch_path => File.dirname(__FILE__) + '/../tmp/watch_path',
13+
:watch_pattern => Captured.guess_watch_path,
14+
:growl_path => "/usr/local/bin/growlnotify" }
15+
end
16+
17+
after(:all) do
18+
# This is run once and only once, after all of the examples
19+
# Restore the clipboard contents
20+
FileUploader.new(@options).pbcopy $pb_backup
21+
end
22+
23+
24+
it "should copy text to the system clipboard" do
25+
fu = FileUploader.new @options
26+
str = "Testing captured is fun for you"
27+
fu.pbcopy str
28+
`pbpaste`.should == str
629
end
730
end

spec/file_uploader_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2+
3+
describe "File Uploader" do
4+
before(:all) do
5+
# This is run once and only once, before all of the examples
6+
7+
#Make a backup of the clipboard
8+
$pb_backup = `pbpaste`
9+
10+
system "mkdir -p #{File.dirname(__FILE__) + '/../tmp/watch_path'}"
11+
@options = {:config_file => File.dirname(__FILE__) + '/fixtures/scp_config.yml',
12+
:watch_path => File.dirname(__FILE__) + '/../tmp/watch_path',
13+
:watch_pattern => Captured.guess_watch_path,
14+
:growl_path => File.dirname(__FILE__) + '/bin/mockgrowlnotify'}
15+
end
16+
17+
after(:all) do
18+
# This is run once and only once, after all of the examples
19+
# Restore the clipboard contents
20+
FileUploader.new(@options).pbcopy $pb_backup
21+
end
22+
23+
24+
it "should copy text to the system clipboard" do
25+
fu = FileUploader.new @options
26+
str = "Testing captured is fun for you"
27+
fu.pbcopy str
28+
`pbpaste`.should == str
29+
end
30+
it "should call growl" do
31+
fu = FileUploader.new @options
32+
str = "Testing captured is fun for you"
33+
fu.growl str
34+
end
35+
end

spec/fixtures/scp_config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
upload:
2+
type: scp
3+
user: user
4+
host: example.com
5+
path: example.com/captured/
6+
url: "http://example.com/captured/"
7+

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'rubygems'
12
require 'spec'
23

34
$LOAD_PATH.unshift(File.dirname(__FILE__))

0 commit comments

Comments
 (0)