Skip to content
This repository
  • 1 commit
  • 5 files changed
  • 0 comments
  • 1 contributor
Mar 30, 2012
squarism Spork, Guard and rbenv 82f3f40
1  .rbenv-version
... ... @@ -0,0 +1 @@
  1 +1.9.3-p125
7 Gemfile
@@ -47,6 +47,13 @@ group :test, :develop do
47 47 gem 'cover_me'
48 48 gem 'minitest'
49 49 gem 'mocha', :require => false
  50 + gem 'spork', "~> 0.9.0"
  51 + gem 'rb-inotify' if RUBY_PLATFORM.downcase.include?("linux")
  52 + gem 'rb-fsevent', "~> 0.9.0" if RUBY_PLATFORM.downcase.include?("darwin")
  53 + gem 'guard', "~> 1.0.1"
  54 + gem 'guard-spork', "~> 0.5.2"
  55 + gem 'guard-minitest', "~> 0.5.0"
  56 + gem 'spork-testunit', "~> 0.0.8"
50 57 end
51 58
52 59 group :production do
19 Gemfile.lock
@@ -84,11 +84,20 @@ GEM
84 84 multi_json (~> 1.0)
85 85 factory_girl (2.6.3)
86 86 activesupport (>= 2.3.9)
  87 + ffi (1.0.11)
87 88 foreman (0.40.0)
88 89 term-ansicolor (~> 1.0.7)
89 90 thor (>= 0.13.6)
90 91 formtastic (2.1.1)
91 92 actionpack (~> 3.0)
  93 + guard (1.0.1)
  94 + ffi (>= 0.5.0)
  95 + thor (~> 0.14.6)
  96 + guard-minitest (0.5.0)
  97 + guard (>= 0.4)
  98 + guard-spork (0.5.2)
  99 + guard (>= 0.10.0)
  100 + spork (>= 0.8.4)
92 101 hashie (1.2.0)
93 102 hike (1.2.1)
94 103 i18n (0.6.0)
@@ -156,6 +165,7 @@ GEM
156 165 thor (~> 0.14.6)
157 166 raindrops (0.8.0)
158 167 rake (0.9.2.2)
  168 + rb-fsevent (0.9.0)
159 169 rdoc (3.12)
160 170 json (~> 1.4)
161 171 redis (2.2.2)
@@ -185,6 +195,9 @@ GEM
185 195 rack-protection (~> 1.1)
186 196 tilt (~> 1.3)
187 197 slop (2.4.4)
  198 + spork (0.9.0)
  199 + spork-testunit (0.0.8)
  200 + spork (>= 0.6.0)
188 201 sprockets (2.0.3)
189 202 hike (~> 1.2)
190 203 rack (~> 1.0)
@@ -230,6 +243,9 @@ DEPENDENCIES
230 243 factory_girl
231 244 foreman
232 245 formtastic
  246 + guard (~> 1.0.1)
  247 + guard-minitest (~> 0.5.0)
  248 + guard-spork (~> 0.5.2)
233 249 health-data-standards!
234 250 jquery-rails
235 251 json
@@ -243,8 +259,11 @@ DEPENDENCIES
243 259 quality-measure-engine!
244 260 rack (= 1.3.3)
245 261 rails (= 3.1.0)
  262 + rb-fsevent (~> 0.9.0)
246 263 rubyzip
247 264 sass-rails (~> 3.1.0)
  265 + spork (~> 0.9.0)
  266 + spork-testunit (~> 0.0.8)
248 267 therubyracer
249 268 turn
250 269 uglifier
32 Guardfile
... ... @@ -0,0 +1,32 @@
  1 +guard 'spork' do
  2 + watch('config/application.rb')
  3 + watch('config/environment.rb')
  4 + watch(%r{^config/environments/.+\\.rb$})
  5 + watch(%r{^config/initializers/.+\\.rb$})
  6 + watch('Gemfile')
  7 + watch('Gemfile.lock')
  8 + watch('test/test_helper.rb') { :minitest }
  9 + watch(%r{features/support/}) { :cucumber }
  10 +end
  11 +
  12 +guard 'minitest' do
  13 + # with Minitest::Unit
  14 + watch(%r|^test/(.*)\/(.*)_test\.rb|)
  15 + watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  16 + watch(%r|^test/test_helper\.rb|) { "test" }
  17 +
  18 + # with Minitest::Spec
  19 + # watch(%r|^spec/(.*)_spec\.rb|)
  20 + # watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  21 + # watch(%r|^spec/spec_helper\.rb|) { "spec" }
  22 +
  23 + # Rails 3.2
  24 + watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  25 + watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
  26 + watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
  27 +
  28 + # Rails
  29 + # watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  30 + # watch(%r|^app/helpers/(.*)\.rb|) { |m| "test/helpers/#{m[1]}_test.rb" }
  31 + # watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
  32 +end
163 test/test_helper.rb
... ... @@ -1,70 +1,113 @@
1   -require 'cover_me'
2   -ENV["RAILS_ENV"] = "test"
3   -require File.expand_path('../../config/environment', __FILE__)
4   -require 'rails/test_help'
5   -
6   -require 'factory_girl'
7   -require 'mocha'
8   -
9   -FactoryGirl.find_definitions
10   -
11   -class ActiveSupport::TestCase
12   -
13   -
14   - def dump_database
15   - User.delete_all
16   - Provider.delete_all
17   - Record.delete_all
18   - Team.delete_all
19   - db = Mongoid::Config.master
20   - db['measures'].remove({})
21   - db['selected_measures'].remove({})
22   - db['records'].remove({})
23   - db['patient_cache'].remove({})
24   - db['query_cache'].remove({})
25   - end
  1 +require 'rubygems'
  2 +require 'spork'
  3 +#uncomment the following line to use spork with the debugger
  4 +#require 'spork/ext/ruby-debug'
26 5
27   - def raw_post(action, body, parameters = nil, session = nil, flash = nil)
28   - @request.env['RAW_POST_DATA'] = body
29   - post(action, parameters, session, flash)
30   - end
  6 +Spork.prefork do
  7 + # Loading more in this block will cause your tests to run faster. However,
  8 + # if you change any configuration or code from libraries loaded here, you'll
  9 + # need to restart spork for it take effect.
  10 + require 'cover_me'
  11 + ENV["RAILS_ENV"] = "test"
  12 + require File.expand_path('../../config/environment', __FILE__)
  13 + require 'rails/test_help'
  14 +
  15 + require 'factory_girl'
  16 + require 'mocha'
31 17
32   - def basic_signin(user)
33   - @request.env['HTTP_AUTHORIZATION'] = "Basic #{ActiveSupport::Base64.encode64("#{user.username}:#{user.password}")}"
34   - end
  18 + FactoryGirl.find_definitions
  19 +
  20 + class ActiveSupport::TestCase
  21 +
  22 + def dump_database
  23 + User.delete_all
  24 + Provider.delete_all
  25 + Record.delete_all
  26 + Team.delete_all
  27 + db = Mongoid::Config.master
  28 + db['measures'].remove({})
  29 + db['selected_measures'].remove({})
  30 + db['records'].remove({})
  31 + db['patient_cache'].remove({})
  32 + db['query_cache'].remove({})
  33 + end
  34 +
  35 + def raw_post(action, body, parameters = nil, session = nil, flash = nil)
  36 + @request.env['RAW_POST_DATA'] = body
  37 + post(action, parameters, session, flash)
  38 + end
35 39
36   - def collection_fixtures(*collection_names)
37   - collection_names.each do |collection|
38   - MONGO_DB[collection].drop
39   - Dir.glob(File.join(Rails.root, 'test', 'fixtures', collection, '*.json')).each do |json_fixture_file|
40   - fixture_json = JSON.parse(File.read(json_fixture_file))
41   - MONGO_DB[collection].save(fixture_json)
  40 + def basic_signin(user)
  41 + @request.env['HTTP_AUTHORIZATION'] = "Basic #{ActiveSupport::Base64.encode64("#{user.username}:#{user.password}")}"
  42 + end
  43 +
  44 + def collection_fixtures(*collection_names)
  45 + collection_names.each do |collection|
  46 + MONGO_DB[collection].drop
  47 + Dir.glob(File.join(Rails.root, 'test', 'fixtures', collection, '*.json')).each do |json_fixture_file|
  48 + fixture_json = JSON.parse(File.read(json_fixture_file))
  49 + MONGO_DB[collection].save(fixture_json)
  50 + end
42 51 end
43 52 end
44   - end
45   -
46   - def hash_includes?(expected, actual)
47   - if (actual.is_a? Hash)
48   - (expected.keys & actual.keys).all? {|k| expected[k] == actual[k]}
49   - elsif (actual.is_a? Array )
50   - actual.any? {|value| hash_includes? expected, value}
51   - else
52   - false
  53 +
  54 + def hash_includes?(expected, actual)
  55 + if (actual.is_a? Hash)
  56 + (expected.keys & actual.keys).all? {|k| expected[k] == actual[k]}
  57 + elsif (actual.is_a? Array )
  58 + actual.any? {|value| hash_includes? expected, value}
  59 + else
  60 + false
  61 + end
53 62 end
54   - end
55   -
56   - def assert_false(value)
57   - assert !value
58   - end
59   -
60   - def assert_query_results_equal(factory_result, result)
61   -
62   - factory_result.each do |key, value|
63   - assert_equal value, result[key] unless key == '_id'
  63 +
  64 + def assert_false(value)
  65 + assert !value
  66 + end
  67 +
  68 + def assert_query_results_equal(factory_result, result)
  69 + factory_result.each do |key, value|
  70 + assert_equal value, result[key] unless key == '_id'
  71 + end
64 72 end
65   -
66 73 end
67   -
68   -
69 74 end
70 75
  76 +Spork.each_run do
  77 + # This code will be run each time you run your specs.
  78 +end
  79 +
  80 +# --- Instructions ---
  81 +# Sort the contents of this file into a Spork.prefork and a Spork.each_run
  82 +# block.
  83 +#
  84 +# The Spork.prefork block is run only once when the spork server is started.
  85 +# You typically want to place most of your (slow) initializer code in here, in
  86 +# particular, require'ing any 3rd-party gems that you don't normally modify
  87 +# during development.
  88 +#
  89 +# The Spork.each_run block is run each time you run your specs. In case you
  90 +# need to load files that tend to change during development, require them here.
  91 +# With Rails, your application modules are loaded automatically, so sometimes
  92 +# this block can remain empty.
  93 +#
  94 +# Note: You can modify files loaded *from* the Spork.each_run block without
  95 +# restarting the spork server. However, this file itself will not be reloaded,
  96 +# so if you change any of the code inside the each_run block, you still need to
  97 +# restart the server. In general, if you have non-trivial code in this file,
  98 +# it's advisable to move it into a separate file so you can easily edit it
  99 +# without restarting spork. (For example, with RSpec, you could move
  100 +# non-trivial code into a file spec/support/my_helper.rb, making sure that the
  101 +# spec/support/* files are require'd from inside the each_run block.)
  102 +#
  103 +# Any code that is left outside the two blocks will be run during preforking
  104 +# *and* during each_run -- that's probably not what you want.
  105 +#
  106 +# These instructions should self-destruct in 10 seconds. If they don't, feel
  107 +# free to delete them.
  108 +
  109 +
  110 +
  111 +
  112 +
  113 +

No commit comments for this range

Something went wrong with that request. Please try again.