diff --git a/rails/gerbil/.watchr b/rails/gerbil/.watchr new file mode 100644 index 0000000..6c03f8a --- /dev/null +++ b/rails/gerbil/.watchr @@ -0,0 +1,24 @@ +def run_spec(file) + unless File.exist?(file) + puts "#{file} does not exist" + return + end + + puts "Running #{file}" + system "bundle exec rspec #{file}" + puts +end + + +watch("spec/[^/]*/[^/]*_spec\\.rb") do |match| + run_spec(match[0]) +end + + +watch("app/(.*)\\.rb") do |match| + run_spec(%{spec/#{match[1]}_spec.rb}) +end + + + +# vim:filetype=ruby diff --git a/rails/gerbil/Gemfile b/rails/gerbil/Gemfile index b57f049..dda09ad 100644 --- a/rails/gerbil/Gemfile +++ b/rails/gerbil/Gemfile @@ -34,4 +34,7 @@ gem 'jquery-rails' group :development, :test do gem 'rspec-rails' + gem 'watchr' + gem 'rev' + gem 'spork' end diff --git a/rails/gerbil/Gemfile.lock b/rails/gerbil/Gemfile.lock index 536ded3..e8426d4 100644 --- a/rails/gerbil/Gemfile.lock +++ b/rails/gerbil/Gemfile.lock @@ -44,6 +44,7 @@ GEM multi_json (~> 1.0) hike (1.2.1) i18n (0.6.0) + iobuffer (1.0.0) jquery-rails (1.0.17) railties (~> 3.0) thor (~> 0.14) @@ -82,6 +83,8 @@ GEM rake (0.9.2.2) rdoc (3.11) json (~> 1.4) + rev (0.3.2) + iobuffer (>= 0.1.3) rspec (2.7.0) rspec-core (~> 2.7.0) rspec-expectations (~> 2.7.0) @@ -116,6 +119,7 @@ GEM uglifier (1.0.4) execjs (>= 0.3.0) multi_json (>= 1.0.2) + watchr (0.7) PLATFORMS ruby @@ -125,7 +129,9 @@ DEPENDENCIES jquery-rails json rails (= 3.1.1) + rev rspec-rails sass-rails (~> 3.1.4) sqlite3 uglifier (>= 1.0.3) + watchr diff --git a/rails/gerbil/app/models/person.rb b/rails/gerbil/app/models/person.rb index 2f2e286..c2e188d 100644 --- a/rails/gerbil/app/models/person.rb +++ b/rails/gerbil/app/models/person.rb @@ -1,2 +1,3 @@ class Person < ActiveRecord::Base + end diff --git a/rails/gerbil/spec/models/person_spec.rb b/rails/gerbil/spec/models/person_spec.rb index 6f582eb..d8f56ff 100644 --- a/rails/gerbil/spec/models/person_spec.rb +++ b/rails/gerbil/spec/models/person_spec.rb @@ -1,5 +1,12 @@ require 'spec_helper' describe Person do - pending "add some examples to (or delete) #{__FILE__}" + it "can be instantiated" do + Person.new.should be_an_instance_of(Person) + end + + it "can be saved successfully" do + Person.create.should be_persisted + + end end