nestor 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -1
- data/Rakefile +19 -15
- data/VERSION +1 -1
- data/doc/state-diagram.graffle +1788 -1776
- data/doc/state-diagram.png +0 -0
- data/lib/nestor/cli.rb +61 -25
- data/lib/nestor/machine.rb +57 -30
- data/lib/nestor/mappers/rails/test/rails_test_unit.rb +58 -0
- data/lib/nestor/mappers/rails/test/unit.rb +259 -0
- data/lib/nestor/mappers.rb +26 -0
- data/lib/nestor/script.rb +9 -0
- data/lib/nestor.rb +1 -0
- data/test/machine_test.rb +20 -0
- data/test/rails_mapper_test.rb +88 -0
- data/test/riot_macros/map.rb +13 -0
- data/test/script_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +20 -17
- data/lib/nestor/strategies/test/unit.rb +0 -127
- data/lib/nestor/strategies.rb +0 -18
- data/lib/nestor/watchers/rails.rb +0 -56
- data/lib/nestor/watchers/rails_script.rb +0 -89
- data/lib/nestor/watchers.rb +0 -1
- data/spec/machine_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -9
- data/spec/test_unit_strategy_spec.rb +0 -41
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
context "" do
|
4
|
+
setup do
|
5
|
+
@mapper = Object.new
|
6
|
+
class << @mapper
|
7
|
+
def log(*args); end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "A new machine" do
|
12
|
+
setup { Nestor::Machine.new(@mapper) }
|
13
|
+
should("be in the :booting state") { topic.booting? }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "A new machine with an :initial_state option" do
|
17
|
+
setup { Nestor::Machine.new(@mapper, :quick => true) }
|
18
|
+
should("start with the specified state") { topic.green? }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "nestor/mappers/rails/test/unit"
|
3
|
+
|
4
|
+
context "Nestor::Mappers::Rails::Test::Unit" do
|
5
|
+
setup { Nestor::Mappers::Rails::Test::Unit.new }
|
6
|
+
|
7
|
+
context "#map" do
|
8
|
+
should_map \
|
9
|
+
"app/models/user.rb" => ["test/unit/user_test.rb"],
|
10
|
+
"app/models/topic.rb" => ["test/unit/topic_test.rb"],
|
11
|
+
"app/models/timeline_observer.rb" => ["test/unit/timeline_observer_test.rb", "test/unit/timeline_test.rb"],
|
12
|
+
|
13
|
+
"app/controllers/users_controller.rb" => ["test/functional/users_controller_test.rb"],
|
14
|
+
"app/views/users/index.html.erb" => ["test/functional/users_controller_test.rb"],
|
15
|
+
|
16
|
+
"app/helpers/users_helper.rb" => ["test/unit/helpers/users_helper_test.rb", "test/functional/users_controller_test.rb"],
|
17
|
+
|
18
|
+
"lib/core_ext/rails/hash.rb" => ["test/unit/core_ext/rails/hash_test.rb"],
|
19
|
+
|
20
|
+
"test/unit/user_test.rb" => ["test/unit/user_test.rb"],
|
21
|
+
"test/functional/users_controller_test.rb" => ["test/functional/users_controller_test.rb"],
|
22
|
+
"test/integration/signup_test.rb" => ["test/integration/signup_test.rb"],
|
23
|
+
"test/performance/home_page_test.rb" => ["test/performance/home_page_test.rb"],
|
24
|
+
|
25
|
+
# Implies running all tests under the specified directory
|
26
|
+
"app/controllers/application_controller.rb" => ["test/functional/"],
|
27
|
+
"app/helpers/application_helper.rb" => ["test/unit/helpers/", "test/functional/"],
|
28
|
+
|
29
|
+
# Implies running all tests
|
30
|
+
"db/schema.rb" => [],
|
31
|
+
"test/test_helper.rb" => [],
|
32
|
+
"config/environment.rb" => [],
|
33
|
+
"config/environments/test.rb" => [],
|
34
|
+
|
35
|
+
# Implies no tests to run
|
36
|
+
"README.rdoc" => nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "A Test::Unit failure after being parsed by Rails::Test::Unit" do
|
41
|
+
setup do
|
42
|
+
failure = Object.new
|
43
|
+
class << failure
|
44
|
+
def location
|
45
|
+
["/test/functional/api/templates_controller_test.rb:12:in `__bind_1256961206_373905'",
|
46
|
+
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'",
|
47
|
+
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: Api::TemplatesController should flunk. '",
|
48
|
+
"/Users/francois/Projects/nestor/lib/nestor/strategies/test/unit.rb:109:in `run'"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_name
|
52
|
+
"test: Api::TemplatesController should flunk. (Api::TemplatesControllerTest)"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
test_files = ["test/functional/api/templates_controller_test.rb"]
|
57
|
+
|
58
|
+
Nestor::Mappers::Rails::Test::Unit.parse_failure(failure, test_files)
|
59
|
+
end
|
60
|
+
|
61
|
+
should("return the filename as #first") { topic.first }.equals("test/functional/api/templates_controller_test.rb")
|
62
|
+
should("return the test's name as #last") { topic.last }.equals("test: Api::TemplatesController should flunk")
|
63
|
+
end
|
64
|
+
|
65
|
+
context "A Test::Unit error after being parsed by Rails::Test::Unit" do
|
66
|
+
setup do
|
67
|
+
exception = RuntimeError.new("bad")
|
68
|
+
exception.set_backtrace(["./test/functional/api/templates_controller_test.rb:12:in `__bind_1256962198_402597'",
|
69
|
+
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'",
|
70
|
+
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: Api::TemplatesController should flunk. '",
|
71
|
+
"/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'",
|
72
|
+
"/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/testing/setup_and_teardown.rb:62:in `run'"])
|
73
|
+
|
74
|
+
failure = Object.new
|
75
|
+
class << failure
|
76
|
+
attr_accessor :exception, :test_name
|
77
|
+
end
|
78
|
+
failure.exception = exception
|
79
|
+
failure.test_name = "test: Api::TemplatesController should flunk. (Api::TemplatesControllerTest)"
|
80
|
+
|
81
|
+
test_files = ["test/functional/api/templates_controller_test.rb"]
|
82
|
+
|
83
|
+
Nestor::Mappers::Rails::Test::Unit.parse_failure(failure, test_files)
|
84
|
+
end
|
85
|
+
|
86
|
+
should("return the filename as #first") { topic.first }.equals("test/functional/api/templates_controller_test.rb")
|
87
|
+
should("return the test's name as #last") { topic.last }.equals("test: Api::TemplatesController should flunk")
|
88
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nestor
|
2
|
+
module Test
|
3
|
+
module Macros
|
4
|
+
def should_map(params)
|
5
|
+
params.each_pair do |key, values|
|
6
|
+
asserts(key.inspect) { topic.map(key) }.equals(values)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Riot::Context.instance_eval { include Nestor::Test::Macros }
|
data/test/script_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nestor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fran\xC3\xA7ois Beausoleil"
|
@@ -9,28 +9,28 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-17 00:00:00 -05:00
|
13
13
|
default_executable: nestor
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: yard
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 0.2.3.5
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: riot
|
27
27
|
type: :development
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.9.12
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: watchr
|
@@ -85,14 +85,15 @@ files:
|
|
85
85
|
- lib/nestor.rb
|
86
86
|
- lib/nestor/cli.rb
|
87
87
|
- lib/nestor/machine.rb
|
88
|
-
- lib/nestor/
|
89
|
-
- lib/nestor/
|
90
|
-
- lib/nestor/
|
91
|
-
- lib/nestor/
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
88
|
+
- lib/nestor/mappers.rb
|
89
|
+
- lib/nestor/mappers/rails/test/rails_test_unit.rb
|
90
|
+
- lib/nestor/mappers/rails/test/unit.rb
|
91
|
+
- lib/nestor/script.rb
|
92
|
+
- test/machine_test.rb
|
93
|
+
- test/rails_mapper_test.rb
|
94
|
+
- test/riot_macros/map.rb
|
95
|
+
- test/script_test.rb
|
96
|
+
- test/test_helper.rb
|
96
97
|
- vendor/watchr-0.5.7/.gitignore
|
97
98
|
- vendor/watchr-0.5.7/History.txt
|
98
99
|
- vendor/watchr-0.5.7/LICENSE
|
@@ -149,6 +150,8 @@ signing_key:
|
|
149
150
|
specification_version: 3
|
150
151
|
summary: Nestor keeps the place tidy by running your specs/tests everytime a file changes
|
151
152
|
test_files:
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
153
|
+
- test/machine_test.rb
|
154
|
+
- test/rails_mapper_test.rb
|
155
|
+
- test/riot_macros/map.rb
|
156
|
+
- test/script_test.rb
|
157
|
+
- test/test_helper.rb
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
require "pathname"
|
3
|
-
require "test/unit/ui/console/testrunner"
|
4
|
-
|
5
|
-
module Nestor
|
6
|
-
module Strategies
|
7
|
-
module Test
|
8
|
-
class Unit
|
9
|
-
def initialize(root)
|
10
|
-
@root = Pathname.new(root).realpath
|
11
|
-
end
|
12
|
-
|
13
|
-
# Logs a message to STDOUT. This implementation forks, so the #log method also
|
14
|
-
# provides the PID of the logger.
|
15
|
-
def log(message)
|
16
|
-
STDOUT.printf "[%d] %s - %s\n", Process.pid, Time.now.strftime("%H:%M:%S"), message
|
17
|
-
STDOUT.flush
|
18
|
-
end
|
19
|
-
|
20
|
-
# Runs absolutely all tests as found by walking test/.
|
21
|
-
def run_all
|
22
|
-
fork do
|
23
|
-
log "Run all tests"
|
24
|
-
test_files = Dir["test/**/*_test.rb"]
|
25
|
-
test_files.each {|f| log(f); load f}
|
26
|
-
|
27
|
-
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
28
|
-
test_runner = ::Nestor::Strategies::Test::TestRunner.new(nil)
|
29
|
-
result = ::Test::Unit::AutoRunner.run(false, nil, []) do |autorunner|
|
30
|
-
autorunner.runner = lambda { test_runner }
|
31
|
-
end
|
32
|
-
|
33
|
-
report(test_runner, test_files)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Runs only the named files, and optionally focuses on only a couple of tests
|
38
|
-
# within the loaded test cases.
|
39
|
-
def run(test_files, focuses=[])
|
40
|
-
fork do
|
41
|
-
log "Running #{focuses.length} focused tests"
|
42
|
-
test_files.each {|f| log(f); load f}
|
43
|
-
|
44
|
-
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
45
|
-
test_runner = ::Nestor::Strategies::Test::TestRunner.new(nil)
|
46
|
-
result = ::Test::Unit::AutoRunner.run(false, nil, []) do |autorunner|
|
47
|
-
autorunner.runner = lambda { test_runner }
|
48
|
-
autorunner.filters << proc{|t| focuses.include?(t.method_name)} unless focuses.empty?
|
49
|
-
end
|
50
|
-
|
51
|
-
report(test_runner, test_files)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Utility method to extract data from a Test::Unit failure.
|
56
|
-
#
|
57
|
-
# @param failure [Test::Unit::Failure, Test::Unit::Error] The Test::Unit failure or error from which to extract information.
|
58
|
-
# @param test_files [Array<String>] The list of files that might have generated this failure. This is used to detect the file that caused the failure.
|
59
|
-
#
|
60
|
-
# @return [String, String] Returns the filename and test name as a 2 element Array.
|
61
|
-
def self.parse_failure(failure, test_files)
|
62
|
-
filename = if failure.respond_to?(:location) then
|
63
|
-
failure.location.map do |loc|
|
64
|
-
filename = loc.split(":", 2).first
|
65
|
-
test_files.detect {|tf| filename.include?(tf)}
|
66
|
-
end.compact.first
|
67
|
-
elsif failure.respond_to?(:exception) then
|
68
|
-
failure.exception.backtrace.map do |loc|
|
69
|
-
filename = loc.split(":", 2).first
|
70
|
-
loc = loc[1..-1] if loc[0,1] == "/"
|
71
|
-
test_files.detect {|tf| filename.include?(tf)}
|
72
|
-
end.compact.first
|
73
|
-
else
|
74
|
-
raise "Unknown object type received as failure: #{failure.inspect} doesn't have #exception or #location methods."
|
75
|
-
end
|
76
|
-
|
77
|
-
test_name = failure.test_name.split("(", 2).first.strip.sub(/\.$/, "")
|
78
|
-
|
79
|
-
[filename, test_name]
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
# Since we forked, we can't call into the Machine from the child process. Upstream
|
85
|
-
# communications is implemented by writing new files to the filesystem and letting
|
86
|
-
# the parent process catch the changes.
|
87
|
-
def report(test_runner, test_files)
|
88
|
-
info = {"status" => test_runner.passed? ? "successful" : "failed", "failures" => {}}
|
89
|
-
failures = info["failures"]
|
90
|
-
test_runner.faults.each do |failure|
|
91
|
-
filename, test_name = self.class.parse_failure(failure, test_files)
|
92
|
-
if filename.nil? then
|
93
|
-
log("Could not map #{failure.test_name.inspect} to a specific test file: mapping to #{test_files.length} files")
|
94
|
-
failures[test_name] = test_files
|
95
|
-
else
|
96
|
-
log("Failed #{failure.test_name.inspect} in #{filename.inspect}")
|
97
|
-
failures[test_name] = filename
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
File.open("tmp/nestor-results.yml", "w") {|io| io.write(info.to_yaml) }
|
102
|
-
log "Wrote #{failures.length} failure(s) to tmp/nestor-results.yml"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# A helper class that allows me to get more information from the build.
|
107
|
-
#
|
108
|
-
# This is something that definitely will change when Nestor is tested on Ruby 1.9.
|
109
|
-
class TestRunner < ::Test::Unit::UI::Console::TestRunner #:nodoc:
|
110
|
-
attr_reader :faults
|
111
|
-
|
112
|
-
# This is a duck-typing method. Test::Unit's design requiers a #run method,
|
113
|
-
# but it is implemented as a class method. I fake it here to allow me to
|
114
|
-
# pass an instance and have the actual TestRunner instance available afterwards.
|
115
|
-
def run(suite, output_level=NORMAL)
|
116
|
-
@suite = suite.respond_to?(:suite) ? suite.suite : suite
|
117
|
-
start
|
118
|
-
end
|
119
|
-
|
120
|
-
# Returns pass/fail status.
|
121
|
-
def passed?
|
122
|
-
@faults.empty?
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
data/lib/nestor/strategies.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Nestor
|
2
|
-
# {Nestor::Cli} will require a file named +nestor/strategies/#{strategy_name}+. If you want
|
3
|
-
# to provide custom strategies, make it available to Nestor using the correct path.
|
4
|
-
#
|
5
|
-
# Strategies are simple objects that implement the following protocol:
|
6
|
-
#
|
7
|
-
# <tt>log(message)</tt>:: Logs a simple message, either to the console or a logfile.
|
8
|
-
# The {Nestor::Machine} will use the +log+ method to notify about it's
|
9
|
-
# state transitions.
|
10
|
-
#
|
11
|
-
# <tt>run_all</tt>:: Runs all the tests, no matter what. In the Rails &
|
12
|
-
# {Nestor::Strategies::Test::Unit} case, this means <tt>Dir["test/**/*_test.rb"]</tt>.
|
13
|
-
#
|
14
|
-
# <tt>run(tests_files, focused_cases=[])</tt>:: Runs only a subset of the tests, maybe
|
15
|
-
# focusing on only a couple of tests / examples.
|
16
|
-
module Strategies
|
17
|
-
end
|
18
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require "watchr"
|
2
|
-
require "pathname"
|
3
|
-
|
4
|
-
module Nestor
|
5
|
-
module Watchers
|
6
|
-
# Knows how to map file change events from Rails conventions to the corresponding test case.
|
7
|
-
module Rails
|
8
|
-
# Launches a {Watchr::Controller} to and never returns. The Controller will
|
9
|
-
# listen for file change events and trigger appropriate events on the Machine.
|
10
|
-
#
|
11
|
-
# By default, the Rails watcher will use the +{Nestor::Strategies::Test::Unit}+ strategy.
|
12
|
-
#
|
13
|
-
# @option options :strategy [Nestor::Strategies] ({Nestor::Strategies::Test::Unit}) The strategy to use. Must be an instance of a class that implements the protocol defined in {Nestor::Strategies}.
|
14
|
-
# @option options :script The path to the Watchr script.
|
15
|
-
#
|
16
|
-
# @return Never...
|
17
|
-
def self.run(options={})
|
18
|
-
strategy = options[:strategy] || Nestor::Strategies::Test::Unit.new(Dir.pwd)
|
19
|
-
script = instantiate_script(options[:script])
|
20
|
-
|
21
|
-
strategy.log "Instantiating machine"
|
22
|
-
script.nestor_strategy = strategy
|
23
|
-
script.nestor_machine = Nestor::Machine.new(strategy)
|
24
|
-
Watchr::Controller.new(script, Watchr.handler.new).run
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.path_to_script
|
28
|
-
default_script_path
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def self.default_script_path
|
34
|
-
Pathname.new(File.dirname(__FILE__) + "/rails_script.rb")
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.instantiate_script(path) #:nodoc:
|
38
|
-
# Use the default if none provided
|
39
|
-
path = default_script_path if path.nil?
|
40
|
-
|
41
|
-
script = Watchr::Script.new(path)
|
42
|
-
class << script
|
43
|
-
def nestor_machine=(m)
|
44
|
-
@machine = m
|
45
|
-
end
|
46
|
-
|
47
|
-
def nestor_strategy=(s)
|
48
|
-
@strategy = s
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
script
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
def log(message) #:nodoc:
|
2
|
-
@strategy.log(message)
|
3
|
-
end
|
4
|
-
|
5
|
-
RAILS_ENV = "test" unless defined?(RAILS_ENV)
|
6
|
-
log "Entering #{RAILS_ENV.inspect} environment"
|
7
|
-
|
8
|
-
log "Creating tmp/ if it doesn't exist"
|
9
|
-
Dir.mkdir("tmp") unless File.directory?("tmp")
|
10
|
-
|
11
|
-
log "Preloading test/test_helper.rb"
|
12
|
-
start_load_at = Time.now
|
13
|
-
$LOAD_PATH.unshift "test" unless $LOAD_PATH.include?("test")
|
14
|
-
require "test_helper"
|
15
|
-
|
16
|
-
end_load_at = Time.now
|
17
|
-
log "Waiting for changes (saving #{end_load_at - start_load_at} seconds per run)..."
|
18
|
-
|
19
|
-
def sendoff(timeout=0.8, path="tmp/nestor-sendoff") #:nodoc:
|
20
|
-
Thread.start(timeout, path) do |timeout, path|
|
21
|
-
log "Sendoff pending #{timeout}..."
|
22
|
-
sleep timeout
|
23
|
-
File.open(path, "w") {|io| io.write(rand.to_s)}
|
24
|
-
log "Sendoff fired on #{path}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def changed!(filename) #:nodoc:
|
29
|
-
return if File.directory?(filename)
|
30
|
-
@machine.changed! filename
|
31
|
-
sendoff
|
32
|
-
end
|
33
|
-
|
34
|
-
watch 'app/models/(.+)\.rb' do |md|
|
35
|
-
test_file = "test/unit/#{md[1]}_test.rb"
|
36
|
-
log "#{md[0].inspect} => #{test_file.inspect}"
|
37
|
-
changed! test_file if File.file?(test_file)
|
38
|
-
end
|
39
|
-
|
40
|
-
watch 'app/controllers/(.+)\.rb' do |md|
|
41
|
-
test_file = "test/functional/#{md[1]}_test.rb"
|
42
|
-
log "#{md[0].inspect} => #{test_file.inspect}"
|
43
|
-
changed! test_file if File.file?(test_file)
|
44
|
-
end
|
45
|
-
|
46
|
-
# It might be possible to run focused tests with the view name
|
47
|
-
watch 'app/views/(.+)' do |md|
|
48
|
-
segments = md[1].split("/")
|
49
|
-
path = segments[0..-2]
|
50
|
-
test_file = "test/functional/#{path.join("/")}_controller_test.rb"
|
51
|
-
log "#{md[0].inspect} => #{test_file.inspect}"
|
52
|
-
changed! test_file if File.file?(test_file)
|
53
|
-
end
|
54
|
-
|
55
|
-
watch 'config/' do |md|
|
56
|
-
@machine.reset!
|
57
|
-
end
|
58
|
-
|
59
|
-
watch 'test/test_helper\.rb' do |md|
|
60
|
-
@machine.reset!
|
61
|
-
end
|
62
|
-
|
63
|
-
watch 'db/schema.rb' do |_|
|
64
|
-
log "Detected changed schema: preparing test DB"
|
65
|
-
system("rake db:test:prepare")
|
66
|
-
end
|
67
|
-
|
68
|
-
watch 'test/(?:unit|functional|integration|performance)/.*' do |md|
|
69
|
-
log "#{md[0].inspect} => #{md[0].inspect}"
|
70
|
-
changed! md[0]
|
71
|
-
end
|
72
|
-
|
73
|
-
watch 'tmp/nestor-results.yml' do |md|
|
74
|
-
# Since we received the results, we must receive our child process' status, or
|
75
|
-
# else we'll have zombie processes lying around
|
76
|
-
Thread.start { Process.wait }
|
77
|
-
|
78
|
-
info = YAML.load_file(md[0])
|
79
|
-
log "New results in: #{info.inspect}"
|
80
|
-
failures = info["failures"]
|
81
|
-
@machine.send("run_#{info["status"]}!", failures.values.flatten.uniq, failures.keys)
|
82
|
-
end
|
83
|
-
|
84
|
-
watch 'tmp/nestor-sendoff' do |_|
|
85
|
-
log "Sendoff"
|
86
|
-
@machine.run!
|
87
|
-
end
|
88
|
-
|
89
|
-
@machine.ready!
|
data/lib/nestor/watchers.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "nestor/watchers/rails"
|
data/spec/machine_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Nestor::Machine do
|
4
|
-
it "should accept a strategy on instantiation" do
|
5
|
-
strategy = mock.as_null_object
|
6
|
-
machine = Nestor::Machine.new(strategy)
|
7
|
-
machine.strategy.should be_equal(strategy)
|
8
|
-
end
|
9
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
require "nestor/strategies/test/unit"
|
3
|
-
|
4
|
-
describe Nestor::Strategies::Test::Unit, "#parse_failure" do
|
5
|
-
it "should return the file and test name as reported by a failure" do
|
6
|
-
failure = mock
|
7
|
-
failure.stub(:location).and_return(
|
8
|
-
["/test/functional/api/templates_controller_test.rb:12:in `__bind_1256961206_373905'",
|
9
|
-
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'",
|
10
|
-
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: Api::TemplatesController should flunk. '",
|
11
|
-
"/Users/francois/Projects/nestor/lib/nestor/strategies/test/unit.rb:109:in `run'"])
|
12
|
-
failure.stub(:test_name).and_return("test: Api::TemplatesController should flunk. (Api::TemplatesControllerTest)")
|
13
|
-
|
14
|
-
test_files = ["test/functional/api/templates_controller_test.rb"]
|
15
|
-
|
16
|
-
filename, test_name = Nestor::Strategies::Test::Unit.parse_failure(failure, test_files)
|
17
|
-
|
18
|
-
filename.should == "test/functional/api/templates_controller_test.rb"
|
19
|
-
test_name.should == "test: Api::TemplatesController should flunk"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should return the file and test name as reported by an error" do
|
23
|
-
exception = RuntimeError.new("bad")
|
24
|
-
exception.set_backtrace(["./test/functional/api/templates_controller_test.rb:12:in `__bind_1256962198_402597'",
|
25
|
-
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'",
|
26
|
-
"/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: Api::TemplatesController should flunk. '",
|
27
|
-
"/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'",
|
28
|
-
"/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/testing/setup_and_teardown.rb:62:in `run'"])
|
29
|
-
|
30
|
-
failure = mock
|
31
|
-
failure.stub(:exception).and_return(exception)
|
32
|
-
failure.stub(:test_name).and_return("test: Api::TemplatesController should flunk. (Api::TemplatesControllerTest)")
|
33
|
-
|
34
|
-
test_files = ["test/functional/api/templates_controller_test.rb"]
|
35
|
-
|
36
|
-
filename, test_name = Nestor::Strategies::Test::Unit.parse_failure(failure, test_files)
|
37
|
-
|
38
|
-
filename.should == "test/functional/api/templates_controller_test.rb"
|
39
|
-
test_name.should == "test: Api::TemplatesController should flunk"
|
40
|
-
end
|
41
|
-
end
|