providence 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ree@providence
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'growl'
4
+ gem 'rb-fsevent'
5
+ gem 'watchr'
6
+
7
+ group :development do
8
+ gem 'bundler', '~> 1.0.0'
9
+ gem 'cucumber'
10
+ gem 'jeweler', '~> 1.5.2'
11
+ gem 'mocha'
12
+ gem 'rcov'
13
+ gem 'rspec'
14
+ end
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ builder (3.0.0)
5
+ cucumber (0.10.2)
6
+ builder (>= 2.1.2)
7
+ diff-lcs (>= 1.1.2)
8
+ gherkin (>= 2.3.5)
9
+ json (>= 1.4.6)
10
+ term-ansicolor (>= 1.0.5)
11
+ diff-lcs (1.1.2)
12
+ gherkin (2.3.6)
13
+ json (>= 1.4.6)
14
+ git (1.2.5)
15
+ growl (1.0.3)
16
+ jeweler (1.5.2)
17
+ bundler (~> 1.0.0)
18
+ git (>= 1.2.5)
19
+ rake
20
+ json (1.5.1)
21
+ mocha (0.9.12)
22
+ rake (0.8.7)
23
+ rb-fsevent (0.4.0)
24
+ rcov (0.9.9)
25
+ rspec (2.5.0)
26
+ rspec-core (~> 2.5.0)
27
+ rspec-expectations (~> 2.5.0)
28
+ rspec-mocks (~> 2.5.0)
29
+ rspec-core (2.5.1)
30
+ rspec-expectations (2.5.0)
31
+ diff-lcs (~> 1.1.2)
32
+ rspec-mocks (2.5.0)
33
+ term-ansicolor (1.0.5)
34
+ watchr (0.7)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ bundler (~> 1.0.0)
41
+ cucumber
42
+ growl
43
+ jeweler (~> 1.5.2)
44
+ mocha
45
+ rb-fsevent
46
+ rcov
47
+ rspec
48
+ watchr
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Chuck Collins
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ Providence
2
+ ==========
3
+
4
+ Ready made [watchr](https://github.com/mynyml/watchr) files for rails projects using [rspec](https://github.com/rspec/rspec) and [cucumber](https://github.com/aslakhellesoy/cucumber). Beware the [growl](http://growl.info/). Only tested with OSX.
5
+
6
+ Overview
7
+ --------
8
+
9
+ To get started with providence add it to your gemfile:
10
+
11
+ gem 'providence'
12
+
13
+ And type prov from the root of your project to start testing:
14
+
15
+ >$ prov
16
+
17
+ If you want to bypass providence and use watchr functionality, run the 'prov' command in the same directory as a .watchr file. Providence will pick this up and use this script instead of its own rails.watchr.
18
+
19
+ There is also a new driver for [rb-fsevent](https://github.com/thibaudgg/rb-fsevent) that seems to be more stable in ruby 1.9.x then the fsevent driver watchr is using. Hopefully this will clear up some of the file event issues with watchr.
20
+
21
+ Contributing to providence
22
+ --------------------------
23
+
24
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
25
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
26
+ * Fork the project
27
+ * Start a feature/bugfix branch
28
+ * Commit and push until you are happy with your contribution
29
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
30
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
31
+
32
+ Copyright
33
+ ---------
34
+
35
+ Copyright (c) 2011 Chuck Collins
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ "Software"), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
51
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
52
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
53
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
54
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55
+
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "providence"
16
+ gem.homepage = "http://github.com/ccollins/providence"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Ready made watchr files for rails projects using rspec and cucumber}
19
+ gem.description = %Q{Ready made watchr files for rails projects using rspec and cucumber. Beware the growl. Only tested on OSX.}
20
+ gem.email = "chuck.collins@gmail.com"
21
+ gem.authors = ["Chuck Collins"]
22
+ gem.bindir = "bin"
23
+ gem.executables = "prov"
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
+
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = "providence #{version}"
33
+ rdoc.rdoc_files.include('README*')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ require 'watchr'
3
+ require 'pathname'
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'providence')
5
+
6
+ system('clear')
7
+ puts 'Watching files...'
8
+
9
+ module Providence
10
+ def Providence.find_watchr_file
11
+ if File.exists?(File.join(Dir.pwd, '.watchr'))
12
+ File.join(Dir.pwd, '.watchr')
13
+ else
14
+ File.join(File.dirname(__FILE__), '..', 'watchrs', 'rails.watchr')
15
+ end
16
+ end
17
+ end
18
+
19
+ Watchr::Controller.new(Watchr::Script.new(Pathname.new(Providence.find_watchr_file)), Providence::EventHandler::Darwin.new).run
File without changes
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ require 'growl'
2
+ require 'open3'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ require 'providence/eye'
6
+ require 'providence/base_watchr'
7
+ require 'providence/cucumber_watchr'
8
+ require 'providence/rspec_watchr'
9
+ require 'providence/event_handlers/darwin'
@@ -0,0 +1,41 @@
1
+ module Providence
2
+ class BaseWatchr
3
+ class << self
4
+ def run(path)
5
+ cmd = "#{command} #{path}"
6
+
7
+ Eye.growl "Running #{name}"
8
+ system('clear')
9
+ puts(cmd)
10
+
11
+ status = parse_test_status(run_command(cmd))
12
+ Eye.growl send("#{status}_message".to_sym), Eye.send("#{status}_image".to_sym)
13
+ end
14
+
15
+ def run_command(cmd)
16
+ last_output = []
17
+ stdin, stdout, stderr = Open3.popen3(cmd)
18
+ while !stdout.eof? || !stderr.eof
19
+ err = stderr.gets
20
+ puts err unless err.nil? || err.strip.empty?
21
+
22
+ line = stdout.gets
23
+ last_output.replace([]) if line.nil? || line.strip.empty?
24
+ last_output.push(line)
25
+ puts line
26
+ end
27
+
28
+ stdin.close
29
+ stdout.close
30
+ stderr.close
31
+
32
+ last_output
33
+ end
34
+
35
+ def pass_message; 'Passed'; end
36
+ def fail_message; 'Failed'; end
37
+ def pending_message; 'Pending further work'; end
38
+ def alert_message; 'Cannot determine test status'; end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,33 @@
1
+ module Providence
2
+ class CucumberWatchr < BaseWatchr
3
+ #order matters here, top is last to match, bottom is first
4
+ def watch(ec)
5
+ ec.watch('features/support/.*') { |m| Providence::CucumberWatchr.run_all }
6
+ ec.watch('features/.*\.feature') { |m| Providence::CucumberWatchr.run m[0] }
7
+ end
8
+
9
+ class << self
10
+ def parse_test_status(status)
11
+ status = status.join('').gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/, '')
12
+
13
+ if status.match(/failed/)
14
+ :fail
15
+ elsif status.match(/passed/)
16
+ :pass
17
+ elsif status.match(/undefined/)
18
+ :pending
19
+ else
20
+ :alert
21
+ end
22
+ end
23
+
24
+ def run_all
25
+ run 'features'
26
+ end
27
+
28
+ def command
29
+ "cucumber --color --drb --require features/step_definitions --require features/support"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,74 @@
1
+ require 'rb-fsevent'
2
+ require 'watchr/event_handlers/base'
3
+
4
+ module Providence
5
+ module EventHandler
6
+ # Uses ruby-fsevents (https://github.com/thibaudgg/rb-fsevent)
7
+ class Darwin < FSEvent
8
+ attr_accessor :watched_paths
9
+ include Watchr::EventHandler::Base
10
+
11
+ def initialize
12
+ super
13
+ end
14
+
15
+ def listen(monitored_paths)
16
+ watch_paths(monitored_paths)
17
+ run
18
+ end
19
+
20
+ def refresh(monitored_paths)
21
+ stop
22
+ listen(monitored_paths)
23
+ end
24
+
25
+ private
26
+ def watch_paths(paths)
27
+ @watched_paths = paths
28
+ watch(dirs_in(paths)) do |dirs|
29
+ process_changes(dirs)
30
+ end
31
+ update_reference_times
32
+ end
33
+
34
+ def dirs_in(paths)
35
+ paths.map {|path| path.dirname.to_s }.uniq
36
+ end
37
+
38
+ def process_changes(dirs)
39
+ dirs.each do |dir|
40
+ paths = monitored_paths_for(dir)
41
+ type = nil
42
+ path = paths.find {|path| type = event_type(path) }
43
+ notify(path, type) unless path.nil?
44
+ end
45
+
46
+ update_reference_times
47
+ end
48
+
49
+ def monitored_paths_for(dir)
50
+ dir = Pathname(dir).expand_path
51
+ @watched_paths.select {|path| path.dirname.expand_path == dir }
52
+ end
53
+
54
+ def event_type(path)
55
+ return :deleted if !path.exist?
56
+ return :modified if path.mtime > @reference_times[path][:mtime]
57
+ return :accessed if path.atime > @reference_times[path][:atime]
58
+ return :changed if path.ctime > @reference_times[path][:ctime]
59
+ nil
60
+ end
61
+
62
+ def update_reference_times
63
+ @reference_times = {}
64
+ now = Time.now
65
+ @watched_paths.each do |path|
66
+ @reference_times[path] = {}
67
+ @reference_times[path][:atime] = now
68
+ @reference_times[path][:mtime] = now
69
+ @reference_times[path][:ctime] = now
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,36 @@
1
+ module Providence
2
+ class Eye
3
+ attr_accessor :watchrs, :ec
4
+
5
+ class << self
6
+ def get_image(image_name)
7
+ File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'images', 'glass', "#{image_name}.png")
8
+ end
9
+
10
+ def method_missing(sym, *arguments, &block)
11
+ if sym.to_s =~ /^(.*)_image$/
12
+ get_image($1)
13
+ else
14
+ super
15
+ end
16
+ end
17
+
18
+ def growl(message, image=info_image, title='Providence')
19
+ Growl.notify message, :title => title, :icon => image
20
+ end
21
+ end
22
+
23
+ def initialize eval_context, *args
24
+ @ec = eval_context
25
+ @watchrs = args || []
26
+ end
27
+
28
+ def run_suite
29
+ watchrs.each {|w| w.class.run_all }
30
+ end
31
+
32
+ def watch
33
+ watchrs.each {|w| w.watch(ec) }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ module Providence
2
+ class RspecWatchr < BaseWatchr
3
+ #order matters here, top is last to match, bottom is first
4
+ def watch(ec)
5
+ ec.watch('app/.*\.rb') { |m| Providence::RspecWatchr.related(m[0]).map {|tf| Providence::RspecWatchr.run tf } }
6
+ ec.watch('lib/.*\.rb') { |m| Providence::RspecWatchr.related(m[0]).map {|tf| Providence::RspecWatchr.run tf } }
7
+ ec.watch('spec/support/.*') { Providence::RspecWatchr.run_all }
8
+ ec.watch('spec/.*_spec\.rb') { |m| Providence::RspecWatchr.run m[0] }
9
+ end
10
+
11
+ class << self
12
+ def parse_test_status(status)
13
+ status = status.join('').gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/, '')
14
+
15
+ if status.match(/\s0\s(errors|failures)/)
16
+ status.match(/pending/) ? :pending : :pass
17
+ elsif status.match(/(error|failure)/)
18
+ :fail
19
+ else
20
+ :alert
21
+ end
22
+ end
23
+
24
+ def run_all
25
+ run 'spec'
26
+ end
27
+
28
+ def related(path)
29
+ Dir['spec/**/*.rb'].select { |file| file =~ /#{File.basename(path).split(".").first}_spec.rb/ }
30
+ end
31
+
32
+ def command
33
+ if Gem.searcher.find('rspec').nil?
34
+ "env RSPEC_COLOR=true spec --drb --colour --format nested"
35
+ else
36
+ "rspec --tty --drb --colour --format nested"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,103 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{providence}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Chuck Collins"]
12
+ s.date = %q{2011-04-30}
13
+ s.default_executable = %q{prov}
14
+ s.description = %q{Ready made watchr files for rails projects using rspec and cucumber. Beware the growl. Only tested on OSX.}
15
+ s.email = %q{chuck.collins@gmail.com}
16
+ s.executables = ["prov"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rvmrc",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.markdown",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/prov",
31
+ "features/startup.feature",
32
+ "images/glass/alert.png",
33
+ "images/glass/fail.png",
34
+ "images/glass/info.png",
35
+ "images/glass/pass.png",
36
+ "images/glass/pending.png",
37
+ "lib/providence.rb",
38
+ "lib/providence/base_watchr.rb",
39
+ "lib/providence/cucumber_watchr.rb",
40
+ "lib/providence/event_handlers/darwin.rb",
41
+ "lib/providence/eye.rb",
42
+ "lib/providence/rspec_watchr.rb",
43
+ "providence.gemspec",
44
+ "spec/lib/providence/base_watchr_spec.rb",
45
+ "spec/lib/providence/cucumber_watchr_spec.rb",
46
+ "spec/lib/providence/event_handlers/darwin_spec.rb",
47
+ "spec/lib/providence/eye_spec.rb",
48
+ "spec/lib/providence/rspec_watchr_spec.rb",
49
+ "spec/spec_helper.rb",
50
+ "watchrs/rails.watchr"
51
+ ]
52
+ s.homepage = %q{http://github.com/ccollins/providence}
53
+ s.licenses = ["MIT"]
54
+ s.require_paths = ["lib"]
55
+ s.rubygems_version = %q{1.3.7}
56
+ s.summary = %q{Ready made watchr files for rails projects using rspec and cucumber}
57
+ s.test_files = [
58
+ "spec/lib/providence/base_watchr_spec.rb",
59
+ "spec/lib/providence/cucumber_watchr_spec.rb",
60
+ "spec/lib/providence/event_handlers/darwin_spec.rb",
61
+ "spec/lib/providence/eye_spec.rb",
62
+ "spec/lib/providence/rspec_watchr_spec.rb",
63
+ "spec/spec_helper.rb"
64
+ ]
65
+
66
+ if s.respond_to? :specification_version then
67
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
+ s.specification_version = 3
69
+
70
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
+ s.add_runtime_dependency(%q<growl>, [">= 0"])
72
+ s.add_runtime_dependency(%q<rb-fsevent>, [">= 0"])
73
+ s.add_runtime_dependency(%q<watchr>, [">= 0"])
74
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
76
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
77
+ s.add_development_dependency(%q<mocha>, [">= 0"])
78
+ s.add_development_dependency(%q<rcov>, [">= 0"])
79
+ s.add_development_dependency(%q<rspec>, [">= 0"])
80
+ else
81
+ s.add_dependency(%q<growl>, [">= 0"])
82
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
83
+ s.add_dependency(%q<watchr>, [">= 0"])
84
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
+ s.add_dependency(%q<cucumber>, [">= 0"])
86
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
87
+ s.add_dependency(%q<mocha>, [">= 0"])
88
+ s.add_dependency(%q<rcov>, [">= 0"])
89
+ s.add_dependency(%q<rspec>, [">= 0"])
90
+ end
91
+ else
92
+ s.add_dependency(%q<growl>, [">= 0"])
93
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
94
+ s.add_dependency(%q<watchr>, [">= 0"])
95
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
96
+ s.add_dependency(%q<cucumber>, [">= 0"])
97
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
98
+ s.add_dependency(%q<mocha>, [">= 0"])
99
+ s.add_dependency(%q<rcov>, [">= 0"])
100
+ s.add_dependency(%q<rspec>, [">= 0"])
101
+ end
102
+ end
103
+
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module Providence
4
+ describe BaseWatchr do
5
+ it "should respond to run" do
6
+ BaseWatchr.respond_to?(:run).should be_true
7
+ end
8
+
9
+ it "should respond to run_command" do
10
+ BaseWatchr.respond_to?(:run_command).should be_true
11
+ end
12
+
13
+ context "#messages" do
14
+ it "should return a string for passing" do
15
+ message = BaseWatchr.pass_message
16
+ message.is_a?(String).should be_true
17
+ message.should_not be_empty
18
+ end
19
+
20
+ it "should return a string for failing" do
21
+ message = BaseWatchr.fail_message
22
+ message.is_a?(String).should be_true
23
+ message.should_not be_empty
24
+ end
25
+
26
+ it "should return a string for pending" do
27
+ message = BaseWatchr.pending_message
28
+ message.is_a?(String).should be_true
29
+ message.should_not be_empty
30
+ end
31
+
32
+ it "should return a string for alert" do
33
+ message = BaseWatchr.alert_message
34
+ message.is_a?(String).should be_true
35
+ message.should_not be_empty
36
+ end
37
+ end
38
+
39
+ context "#run" do
40
+ before(:each) do
41
+ BaseWatchr.stubs(:command).returns('test')
42
+ BaseWatchr.stubs(:puts)
43
+ BaseWatchr.stubs(:system)
44
+ Eye.stubs(:growl)
45
+ end
46
+
47
+ it "should growl and output command and status" do
48
+ BaseWatchr.expects(:run_command).with("test #{Dir::tmpdir}").returns('run_command')
49
+ BaseWatchr.expects(:parse_test_status).with('run_command').returns(:pass)
50
+ BaseWatchr.expects(:pass_message)
51
+ BaseWatchr.run(Dir::tmpdir)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module Providence
4
+ describe CucumberWatchr do
5
+ it "should respond to watch" do
6
+ subject.respond_to?(:watch).should be_true
7
+ end
8
+
9
+ it "should run all features" do
10
+ CucumberWatchr.expects(:run).with('features')
11
+ CucumberWatchr.run_all
12
+ end
13
+
14
+ it "should return cucumber in command" do
15
+ CucumberWatchr.command =~ /cucumber/
16
+ end
17
+
18
+ context "#parse_test_status" do
19
+ it "should return :fail" do
20
+ CucumberWatchr.parse_test_status(['failed']).should == :fail
21
+ end
22
+
23
+ it "should return :pass" do
24
+ CucumberWatchr.parse_test_status(['passed']).should == :pass
25
+ end
26
+
27
+ it "should return :pending" do
28
+ CucumberWatchr.parse_test_status(['undefined']).should == :pending
29
+ end
30
+
31
+ it "should return :alert" do
32
+ CucumberWatchr.parse_test_status(['hrrrgrrrrrbrbrlrllrl']).should == :alert
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ def tempfile(name)
4
+ file = Tempfile.new(name)
5
+ Pathname(file.path)
6
+ ensure
7
+ file.close
8
+ end
9
+
10
+ module Providence
11
+ module EventHandler
12
+ describe Darwin do
13
+ before(:each) do
14
+ @foo = tempfile('foo').expand_path
15
+ @bar = tempfile('bar').expand_path
16
+ subject.stubs(:run)
17
+ subject.stubs(:stop)
18
+ end
19
+
20
+ context "#listen" do
21
+ it "should trigger listening state" do
22
+ subject.expects(:run)
23
+ subject.expects(:watch_paths)
24
+ subject.listen([])
25
+ end
26
+
27
+ it "should listen for events on monitored files" do
28
+ subject.listen([@foo, @bar])
29
+ subject.watched_paths.include?(@foo).should be_true
30
+ subject.watched_paths.include?(@bar).should be_true
31
+ end
32
+
33
+ it "should reattach to new monitored files" do
34
+ subject.listen([@foo, @bar])
35
+
36
+ @baz = tempfile('baz').expand_path
37
+ @bax = tempfile('bax').expand_path
38
+ subject.refresh([@baz, @bax])
39
+
40
+ subject.watched_paths.include?(@baz).should be_true
41
+ subject.watched_paths.include?(@bax).should be_true
42
+ subject.watched_paths.include?(@foo).should be_false
43
+ subject.watched_paths.include?(@bar).should be_false
44
+ end
45
+ end
46
+
47
+ context "#process_changes" do
48
+ it "should notify deleted event" do
49
+ @foo.stubs(:exist?).returns(false)
50
+ subject.listen([@foo, @bar])
51
+ subject.expects(:notify).with(@foo, :deleted)
52
+ subject.send(:process_changes, [Dir::tmpdir])
53
+ end
54
+
55
+ it "should notify modified event" do
56
+ @foo.stubs(:mtime).returns(Time.now + 100)
57
+ subject.listen([@foo, @bar])
58
+ subject.expects(:notify).with(@foo, :modified)
59
+ subject.send(:process_changes, [Dir::tmpdir])
60
+ end
61
+
62
+ it "should notify accessed event" do
63
+ @foo.stubs(:atime).returns(Time.now + 100)
64
+ subject.listen([@foo, @bar])
65
+ subject.expects(:notify).with(@foo, :accessed)
66
+ subject.send(:process_changes, [Dir::tmpdir])
67
+ end
68
+
69
+ it "should notify changed file event" do
70
+ @foo.stubs(:ctime).returns(Time.now + 100)
71
+ subject.listen([@foo, @bar])
72
+ subject.expects(:notify).with(@foo, :changed)
73
+ subject.send(:process_changes, [Dir::tmpdir])
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ module Providence
4
+ describe Eye do
5
+ before(:each) do
6
+ @eye = Eye.new(mock())
7
+ end
8
+
9
+ it "should not have an image for asdf" do
10
+ File.exists?(Eye.asdf_image).should_not be_true
11
+ end
12
+
13
+ it "should have an image for passing tests" do
14
+ File.exists?(Eye.pass_image).should be_true
15
+ end
16
+
17
+ it "should have an image for failing tests" do
18
+ File.exists?(Eye.fail_image).should be_true
19
+ end
20
+
21
+ it "should have an image for pending" do
22
+ File.exists?(Eye.pending_image).should be_true
23
+ end
24
+
25
+ it "should have an image for alert" do
26
+ File.exists?(Eye.alert_image).should be_true
27
+ end
28
+
29
+ it "should have an image for info" do
30
+ File.exists?(Eye.info_image).should be_true
31
+ end
32
+
33
+ it "should return the image" do
34
+ Eye.get_image('pending').should =~ /pending\.png/
35
+ end
36
+
37
+ context "#initialize" do
38
+ it "should take accept context and no args" do
39
+ eye = Eye.new(mock())
40
+ eye.watchrs.count.should == 0
41
+ end
42
+
43
+ it "should take context and multiple args" do
44
+ eye = Eye.new(mock(), Object.new, Object.new, Object.new)
45
+ eye.watchrs.count.should == 3
46
+ end
47
+ end
48
+
49
+ context "#watchrs" do
50
+ it "should accept multiple objects" do
51
+ @eye.watchrs << Object.new << Object.new
52
+ @eye.watchrs.count.should == 2
53
+ end
54
+ end
55
+
56
+ context "#run_suite" do
57
+ it "should call watch on each watchr" do
58
+ 5.times do
59
+ @eye.watchrs << RspecWatchr.new
60
+ end
61
+ RspecWatchr.expects(:run_all).times(5)
62
+ @eye.run_suite
63
+ end
64
+ end
65
+
66
+ context "#watch" do
67
+ it "should call watch on each watchr" do
68
+ 5.times do
69
+ watchr = mock()
70
+ watchr.expects(:watch).once
71
+ @eye.watchrs << watchr
72
+ end
73
+
74
+ @eye.watch
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ module Providence
4
+ describe RspecWatchr do
5
+ it "should respond to watch" do
6
+ subject.respond_to?(:watch).should be_true
7
+ end
8
+
9
+ it "should run all features" do
10
+ RspecWatchr.expects(:run).with('spec')
11
+ RspecWatchr.run_all
12
+ end
13
+
14
+ context "#command" do
15
+ it "should return rspec if rspec gem is found" do
16
+ Gem.stubs(:searcher).returns(mock(:find => true))
17
+ RspecWatchr.command =~ /rspec/
18
+ end
19
+
20
+ it "should return spec without rspec gem" do
21
+ Gem.stubs(:searcher).returns(mock(:find => nil))
22
+ command = RspecWatchr.command
23
+ command =~ /spec/ and command =~ /env/
24
+ end
25
+ end
26
+
27
+ context "#parse_test_status" do
28
+ it "should return :fail" do
29
+ RspecWatchr.parse_test_status(['5 examples, 1 failure']).should == :fail
30
+ end
31
+
32
+ it "should return :pass" do
33
+ RspecWatchr.parse_test_status(['5 examples, 0 failures']).should == :pass
34
+ end
35
+
36
+ it "should return :pending" do
37
+ RspecWatchr.parse_test_status(['5 examples, 0 failures, 1 pending']).should == :pending
38
+ end
39
+
40
+ it "should return :alert" do
41
+ RspecWatchr.parse_test_status(['hrrrgrrrrrbrbrlrllrl']).should == :alert
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'rspec'
6
+ require 'tempfile'
7
+
8
+ RSpec.configure do |config|
9
+ config.mock_with :mocha
10
+ end
11
+
12
+ require File.join(File.dirname(__FILE__), "..", "lib", "providence")
@@ -0,0 +1,4 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'providence')
2
+
3
+ @eye = Providence::Eye.new(self, Providence::RspecWatchr.new, Providence::CucumberWatchr.new)
4
+ @eye.watch
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: providence
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - Chuck Collins
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-30 00:00:00 -05:00
19
+ default_executable: prov
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ name: growl
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ type: :runtime
38
+ name: rb-fsevent
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ prerelease: false
51
+ type: :runtime
52
+ name: watchr
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirement: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ prerelease: false
65
+ type: :development
66
+ name: bundler
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 23
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ version: 1.0.0
78
+ requirement: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ prerelease: false
81
+ type: :development
82
+ name: cucumber
83
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirement: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ prerelease: false
95
+ type: :development
96
+ name: jeweler
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ hash: 7
103
+ segments:
104
+ - 1
105
+ - 5
106
+ - 2
107
+ version: 1.5.2
108
+ requirement: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ prerelease: false
111
+ type: :development
112
+ name: mocha
113
+ version_requirements: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirement: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ prerelease: false
125
+ type: :development
126
+ name: rcov
127
+ version_requirements: &id008 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ requirement: *id008
137
+ - !ruby/object:Gem::Dependency
138
+ prerelease: false
139
+ type: :development
140
+ name: rspec
141
+ version_requirements: &id009 !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ requirement: *id009
151
+ description: Ready made watchr files for rails projects using rspec and cucumber. Beware the growl. Only tested on OSX.
152
+ email: chuck.collins@gmail.com
153
+ executables:
154
+ - prov
155
+ extensions: []
156
+
157
+ extra_rdoc_files:
158
+ - LICENSE.txt
159
+ - README.markdown
160
+ files:
161
+ - .document
162
+ - .rvmrc
163
+ - Gemfile
164
+ - Gemfile.lock
165
+ - LICENSE.txt
166
+ - README.markdown
167
+ - Rakefile
168
+ - VERSION
169
+ - bin/prov
170
+ - features/startup.feature
171
+ - images/glass/alert.png
172
+ - images/glass/fail.png
173
+ - images/glass/info.png
174
+ - images/glass/pass.png
175
+ - images/glass/pending.png
176
+ - lib/providence.rb
177
+ - lib/providence/base_watchr.rb
178
+ - lib/providence/cucumber_watchr.rb
179
+ - lib/providence/event_handlers/darwin.rb
180
+ - lib/providence/eye.rb
181
+ - lib/providence/rspec_watchr.rb
182
+ - providence.gemspec
183
+ - spec/lib/providence/base_watchr_spec.rb
184
+ - spec/lib/providence/cucumber_watchr_spec.rb
185
+ - spec/lib/providence/event_handlers/darwin_spec.rb
186
+ - spec/lib/providence/eye_spec.rb
187
+ - spec/lib/providence/rspec_watchr_spec.rb
188
+ - spec/spec_helper.rb
189
+ - watchrs/rails.watchr
190
+ has_rdoc: true
191
+ homepage: http://github.com/ccollins/providence
192
+ licenses:
193
+ - MIT
194
+ post_install_message:
195
+ rdoc_options: []
196
+
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ hash: 3
205
+ segments:
206
+ - 0
207
+ version: "0"
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ hash: 3
214
+ segments:
215
+ - 0
216
+ version: "0"
217
+ requirements: []
218
+
219
+ rubyforge_project:
220
+ rubygems_version: 1.3.7
221
+ signing_key:
222
+ specification_version: 3
223
+ summary: Ready made watchr files for rails projects using rspec and cucumber
224
+ test_files:
225
+ - spec/lib/providence/base_watchr_spec.rb
226
+ - spec/lib/providence/cucumber_watchr_spec.rb
227
+ - spec/lib/providence/event_handlers/darwin_spec.rb
228
+ - spec/lib/providence/eye_spec.rb
229
+ - spec/lib/providence/rspec_watchr_spec.rb
230
+ - spec/spec_helper.rb