Skip to content

Commit

Permalink
Basic functionality
Browse files Browse the repository at this point in the history
run all and run selected paths work
  • Loading branch information
Michal Taszycki committed Aug 2, 2011
1 parent c0e8040 commit 0535202
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 9 deletions.
5 changes: 2 additions & 3 deletions guard-jessie.gemspec
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "guard-jessie/version"
require "guard/jessie"

Gem::Specification.new do |s|
s.name = "guard-jessie"
Expand All @@ -10,15 +10,14 @@ Gem::Specification.new do |s|
s.email = ["mtaszycki@gmail.com"]
s.homepage = "https://github.com/mehowte/guard-jessie"
s.summary = %q{Guard gem for jessie}
s.description = %q{Guard::Jessie automatically runs you jasmine specs through jessie driver}
s.description = %q{Guard::Jessie automatically runs your jasmine specs through jessie driver}

s.rubyforge_project = "guard-jessie"

s.add_dependency 'guard', '>= 0.4.0'

s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency 'rspec', '~> 2.6'
s.add_development_dependency 'guard-ego'
s.add_development_dependency 'guard-bundler'
s.add_development_dependency 'guard-rspec'

Expand Down
5 changes: 0 additions & 5 deletions lib/guard-jessie.rb
@@ -1,5 +0,0 @@
module Guard
module Jessie
# Your code goes here...
end
end
21 changes: 21 additions & 0 deletions lib/guard/jessie.rb
@@ -0,0 +1,21 @@
require 'guard'
require 'guard/guard'

module Guard
class Jessie < Guard
autoload :VERSION, 'guard/jessie/version'
autoload :Runner, 'guard/jessie/runner'

def run_all
puts "Running all specs"
Runner.run %w[spec]
end

def run_on_change paths
paths_string = paths.map {|path| "#{path}" }.join(' ')
puts "Running #{paths_string}"
Runner.run paths
end
end
end

20 changes: 20 additions & 0 deletions lib/guard/jessie/runner.rb
@@ -0,0 +1,20 @@
module Guard
class Jessie
module Runner
def self.run paths
return false if paths.empty?
system(jessie_command(paths))
end

private
def self.jessie_command(paths)
cmd_parts = []
cmd_parts << "jessie"
cmd_parts << "-f progress"
cmd_parts << paths.join(" ")

cmd_parts.join(" ")
end
end
end
end
19 changes: 19 additions & 0 deletions lib/guard/jessie/templates/Guardfile
@@ -0,0 +1,19 @@
guard 'jessie' do

# Standard node project
watch(%r{^spec/.+(_spec|Spec)\.(js|coffee)$})
watch(%r{^lib/(.+)\.(js|coffee)$}) { |m| "spec/lib/#{m[1]}_spec.js" }
watch('spec/spec_helper.js') { "spec" }

# Typical Rails (version < 3.1) app
watch(%r{^spec/javascripts/.+(_spec|Spec)\.(js|coffee)$})
watch(%r{^public/javascripts/(.+)\.(js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.js" }
watch('spec/spec_helper.js') { "spec" }

# Typical Rails (version >= 3.1) app
watch(%r{^spec/javascripts/.+(_spec|Spec)\.(js|coffee)$})
# you'll want to make adjustments to the rule below if you don't use coffeescript in your tests ;)
watch(%r{^app/assets/javascripts/(.+)\.(js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.coffee" }
watch('spec/spec_helper.js') { "spec" }
end

@@ -1,5 +1,5 @@
module Guard
module Jessie
class Jessie
VERSION = "0.0.1"
end
end
24 changes: 24 additions & 0 deletions spec/lib/guard/jessie/runner_spec.rb
@@ -0,0 +1,24 @@
require 'spec_helper'
module Guard
class Jessie
describe Runner do
let(:multiple_paths) { %w[/spec ./spec/something.js ../spec/something_else.js other_thing.js]}
context "when passed an empty paths list" do
it "returns false" do
subject.run([]).should be_false
end
end

context "when passed multiple paths" do
it "runs jessie with those paths" do
subject.should_receive(:system).with(
"jessie -f progress /spec ./spec/something.js ../spec/something_else.js other_thing.js"
)
subject.run(multiple_paths)
end

end

end
end
end
19 changes: 19 additions & 0 deletions spec/lib/guard/jessie_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'
module Guard
describe Jessie do
let(:paths) { %w[array of changed paths]}

describe "#run_all" do
it "runs all specs" do
Jessie::Runner.should_receive(:run).with(["spec"])
subject.run_all
end
end
describe "#run_on_change" do
it "runs changed files" do
Jessie::Runner.should_receive(:run).with(paths)
subject.run_on_change paths
end
end
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,4 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'guard/jessie'

0 comments on commit 0535202

Please sign in to comment.