autocuke 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +2 -0
- data/LICENSE +27 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/autocuke.gemspec +30 -0
- data/bin/autocuke +39 -0
- data/lib/autocuke.rb +23 -0
- data/lib/autocuke/handler.rb +63 -0
- data/lib/autocuke/runtime.rb +65 -0
- data/lib/autocuke/version.rb +3 -0
- data/test/dummy_hooks/after_migrate.rb.sample +1 -0
- data/test/dummy_hooks/before_migrate.rb +9 -0
- data/test/support/em.rb +29 -0
- data/test/support/kernel.rb +18 -0
- data/test/test_helper.rb +9 -0
- data/test/unit/autocuke_test.rb +40 -0
- data/test/unit/handler_test.rb +72 -0
- data/test/unit/runtime_test.rb +80 -0
- metadata +158 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2011 Spencer Steffen and Citrus Media Group.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
* Neither the name of Citrus Media Group nor the names of its
|
|
15
|
+
contributors may be used to endorse or promote products derived from this
|
|
16
|
+
software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Autocuke
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
Autocuke uses EventMachine to watch your .feature files, then automatically runs cucumber as they change. Use with spork for total awesomeness.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Installation
|
|
9
|
+
------------
|
|
10
|
+
|
|
11
|
+
If you're using bundler, just add this to your Gemfile:
|
|
12
|
+
|
|
13
|
+
group :test do
|
|
14
|
+
gem "autocuke", "0.1.0"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then create a bundle-of-joy with:
|
|
18
|
+
|
|
19
|
+
bundle
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Otherwise, just install from rubygems like so:
|
|
23
|
+
|
|
24
|
+
(sudo) gem install autocuke
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
That's it!
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Usage
|
|
31
|
+
-----
|
|
32
|
+
|
|
33
|
+
First, add an autocuke profile to your `config/cucumber.yml`.
|
|
34
|
+
|
|
35
|
+
autocuke: -r features --format pretty --strict
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Then boot up the "autocuke-file-watcher-5000":
|
|
39
|
+
|
|
40
|
+
autocuke
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Then 'cuke away... and next time you save your .feature, autocuke will run it for you.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Have fun!
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Contributors
|
|
50
|
+
------------
|
|
51
|
+
|
|
52
|
+
So far it's just me; Spencer Steffen.
|
|
53
|
+
|
|
54
|
+
If you'd like to help out feel free to fork and send me pull requests!
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
License
|
|
59
|
+
-------
|
|
60
|
+
|
|
61
|
+
Copyright (c) 2011 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.
|
data/Rakefile
ADDED
data/autocuke.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "autocuke/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "autocuke"
|
|
7
|
+
s.version = Autocuke::VERSION
|
|
8
|
+
s.authors = ["Spencer Steffen"]
|
|
9
|
+
s.email = ["spencer@citrusme.com"]
|
|
10
|
+
s.homepage = "https://github.com/citrus/autocuke"
|
|
11
|
+
s.summary = %q{Autocuke uses EventMachine to watch your .feature files, then automatically runs cucumber as they change. Use with Spork for total awesomeness.}
|
|
12
|
+
s.description = %q{Autocuke uses EventMachine to watch your .feature files, then automatically runs cucumber as they change. Use with Spork for total awesomeness. Please see README.md for more details.}
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
# Runtime
|
|
20
|
+
s.add_dependency('eventmachine', '>= 0.12.10')
|
|
21
|
+
|
|
22
|
+
# Development
|
|
23
|
+
s.add_development_dependency('dummier', '>= 0.2.0')
|
|
24
|
+
s.add_development_dependency('shoulda', '>= 2.11.3')
|
|
25
|
+
s.add_development_dependency('rails', '>= 3.0.0')
|
|
26
|
+
s.add_development_dependency('cucumber-rails', '>= 1.0.2')
|
|
27
|
+
s.add_development_dependency('database_cleaner', '>= 0.6.7')
|
|
28
|
+
s.add_development_dependency('sqlite3', '>= 1.3.3')
|
|
29
|
+
|
|
30
|
+
end
|
data/bin/autocuke
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
3
|
+
|
|
4
|
+
require "autocuke"
|
|
5
|
+
require "optparse"
|
|
6
|
+
|
|
7
|
+
options = OpenStruct.new
|
|
8
|
+
options.root = File.join(Dir.getwd)
|
|
9
|
+
options.features = File.join(options.root, "features")
|
|
10
|
+
options.verbose = false
|
|
11
|
+
|
|
12
|
+
OptionParser.new do |opts|
|
|
13
|
+
opts.banner = "Usage: autocuke [options]"
|
|
14
|
+
|
|
15
|
+
opts.on("-r", "--root DIRECTORY", "Set the root directory to DIRECTORY") do |dir|
|
|
16
|
+
options.root = dir
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
opts.on("-d", "--dir DIRECTORY", "Watch for .feature files in DIRECTORY") do |dir|
|
|
20
|
+
options.dir = dir
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
|
24
|
+
options.verbose = v
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
28
|
+
puts opts
|
|
29
|
+
exit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
opts.on_tail("--version", "Show version") do
|
|
33
|
+
puts [ "autocuke v", Autocuke::VERSION ].join
|
|
34
|
+
exit
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end.parse!
|
|
38
|
+
|
|
39
|
+
Autocuke.start(options)
|
data/lib/autocuke.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "ostruct"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
require "autocuke/runtime"
|
|
4
|
+
require "autocuke/version"
|
|
5
|
+
|
|
6
|
+
module Autocuke
|
|
7
|
+
|
|
8
|
+
class NoFileError < Exception; end
|
|
9
|
+
|
|
10
|
+
def self.start(options)
|
|
11
|
+
@active_runtime = Runtime.new(options)
|
|
12
|
+
@active_runtime.run!
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.set_active_runtime(runtime)
|
|
16
|
+
@active_runtime = runtime
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.active_runtime
|
|
20
|
+
@active_runtime
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Autocuke
|
|
2
|
+
module Handler
|
|
3
|
+
|
|
4
|
+
# Triggered after a file has been modified
|
|
5
|
+
def file_modified
|
|
6
|
+
return if runtime.current_file
|
|
7
|
+
runtime.current_file = path
|
|
8
|
+
local = path.sub(/.*#{runtime.options.root}\/?/, '')
|
|
9
|
+
cmd = "cd #{runtime.root}; bundle exec cucumber -p autocuke #{local}"
|
|
10
|
+
puts "#{local} modified - re-cuking it."
|
|
11
|
+
run_with_defer cmd
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Triggered after a file has been moved
|
|
15
|
+
def file_moved
|
|
16
|
+
stop! unless File.exists?(path)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Triggered after a file has been deleted.
|
|
20
|
+
# In text editors, the file is deleted and recreated rather than modified.
|
|
21
|
+
# If so, we'll start watching the new file and trigger `file_modified`
|
|
22
|
+
def file_deleted
|
|
23
|
+
if File.exists?(path)
|
|
24
|
+
file_modified
|
|
25
|
+
runtime.watch(path)
|
|
26
|
+
else
|
|
27
|
+
stop!
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Stop EM if the file doesn't exist
|
|
32
|
+
def unbind
|
|
33
|
+
stop! unless File.exists?(path)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# Runs the cucumber command and triggers a callback when it's complete
|
|
39
|
+
def run_with_defer(cmd)
|
|
40
|
+
puts cmd if runtime.options.verbose
|
|
41
|
+
operation = proc {
|
|
42
|
+
system(cmd)
|
|
43
|
+
}
|
|
44
|
+
callback = proc {|result|
|
|
45
|
+
runtime.current_file = nil
|
|
46
|
+
}
|
|
47
|
+
EM.defer operation, callback
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Just an alias to the active runtime
|
|
51
|
+
def runtime
|
|
52
|
+
Autocuke.active_runtime
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Warns the user and stops the active runtime
|
|
56
|
+
def stop!
|
|
57
|
+
puts "*" * 88
|
|
58
|
+
puts "#{File.basename(path)} is no longer available! Autocuke stopping..."
|
|
59
|
+
runtime.stop!
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require "eventmachine"
|
|
2
|
+
require "autocuke/handler"
|
|
3
|
+
|
|
4
|
+
module Autocuke
|
|
5
|
+
class Runtime
|
|
6
|
+
|
|
7
|
+
attr_reader :root, :options
|
|
8
|
+
attr_accessor :files, :current_file
|
|
9
|
+
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@options = options
|
|
12
|
+
@root = options.root
|
|
13
|
+
@files ||= Dir[File.join(options.root, "**/*.feature")]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Starts the EM reactor and watches each of the runtime's files
|
|
17
|
+
# Raises an Autocuke::NoFileError if the list of files is empty
|
|
18
|
+
def run!
|
|
19
|
+
raise Autocuke::NoFileError.new("No files given to watch!") if files.empty?
|
|
20
|
+
|
|
21
|
+
log if options.verbose
|
|
22
|
+
|
|
23
|
+
# file watching requires kqueue on OSX
|
|
24
|
+
EM.kqueue = true if EM.kqueue?
|
|
25
|
+
|
|
26
|
+
EM.run {
|
|
27
|
+
watch_feature_files
|
|
28
|
+
puts "autocuke is up and running!"
|
|
29
|
+
trap "SIGINT", proc{
|
|
30
|
+
puts "\nbye-bye!"
|
|
31
|
+
exit
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Logs the root and file list
|
|
37
|
+
def log
|
|
38
|
+
puts "Root Set To:"
|
|
39
|
+
puts root
|
|
40
|
+
puts
|
|
41
|
+
puts "Watching files:"
|
|
42
|
+
puts "-" * 88
|
|
43
|
+
puts files
|
|
44
|
+
puts
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Adds each of the runtime's files to EM's file watch list
|
|
48
|
+
def watch_feature_files
|
|
49
|
+
files.each do |file|
|
|
50
|
+
watch(file)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Adds a file to EM's file watch list
|
|
55
|
+
def watch(file)
|
|
56
|
+
EM.watch_file(File.expand_path(file), handler)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Overwrite for custom handlers
|
|
60
|
+
def handler
|
|
61
|
+
Autocuke::Handler
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end # Runtime
|
|
65
|
+
end # Autocuke
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rake "db:migrate", :env => "development"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
run "rails generate cucumber:install"
|
|
2
|
+
|
|
3
|
+
run "rails generate cucumber:feature post title:string body:text published:boolean"
|
|
4
|
+
run "rails generate scaffold post title:string body:text published:boolean"
|
|
5
|
+
|
|
6
|
+
run "rails generate cucumber:feature comment post:references name:string body:text"
|
|
7
|
+
run "rails generate scaffold comment post:references name:string body:text"
|
|
8
|
+
|
|
9
|
+
append_file "config/cucumber.yml", "\nautocuke: -r features --format pretty --strict"
|
data/test/support/em.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class Test::Unit::TestCase
|
|
2
|
+
|
|
3
|
+
def default_runtime_options
|
|
4
|
+
options = OpenStruct.new
|
|
5
|
+
options.root = File.expand_path("../../dummy", __FILE__)
|
|
6
|
+
options.features = File.join(options.root, "features")
|
|
7
|
+
options.verbose = false
|
|
8
|
+
options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def current_runtime_options
|
|
12
|
+
@current_runtime_options ||= default_runtime_options
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def within_loop(opts={}, &block)
|
|
16
|
+
output = capture_stdout do
|
|
17
|
+
EM.run {
|
|
18
|
+
options = default_runtime_options
|
|
19
|
+
opts.map{ |k,v| options.send("#{k}=", v) }
|
|
20
|
+
@current_runtime_options = options
|
|
21
|
+
Autocuke.start(options)
|
|
22
|
+
yield
|
|
23
|
+
EM.stop
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
outputs = output.string.split("\n").select{|i| i && 0 < i.length }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Captures output from `puts`
|
|
2
|
+
# thanks @ Rob Olson
|
|
3
|
+
# http://thinkingdigitally.com/archive/capturing-output-from-puts-in-ruby/
|
|
4
|
+
|
|
5
|
+
require 'stringio'
|
|
6
|
+
|
|
7
|
+
module Kernel
|
|
8
|
+
|
|
9
|
+
def capture_stdout
|
|
10
|
+
out = StringIO.new
|
|
11
|
+
$stdout = out
|
|
12
|
+
yield
|
|
13
|
+
return out
|
|
14
|
+
ensure
|
|
15
|
+
$stdout = STDOUT
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
class AutocukeTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@bin = File.expand_path("../../../bin/autocuke", __FILE__)
|
|
7
|
+
@output = ""
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(options)
|
|
11
|
+
`#{@bin} #{options}`
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "have classes defined" do
|
|
15
|
+
assert defined?(Autocuke)
|
|
16
|
+
assert defined?(Autocuke::Runtime)
|
|
17
|
+
assert defined?(Autocuke::Handler)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should "have executable" do
|
|
21
|
+
assert File.exists?(@bin)
|
|
22
|
+
assert File.executable?(@bin)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "Autocuke options" do
|
|
26
|
+
|
|
27
|
+
should "display help" do
|
|
28
|
+
@output = call("-h")
|
|
29
|
+
assert @output.include?("Usage: autocuke [options]")
|
|
30
|
+
%w(-r --root -d --dir -v --[no-]verbose -h --help --version).map{|i| assert @output.include?(i) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
should "display version and exit" do
|
|
34
|
+
@output = call("--version")
|
|
35
|
+
assert_equal "autocuke v#{Autocuke::VERSION}\n", @output
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Extends the original handler
|
|
5
|
+
module MockHandler
|
|
6
|
+
|
|
7
|
+
include Autocuke::Handler
|
|
8
|
+
|
|
9
|
+
def file_modified
|
|
10
|
+
$modified = true
|
|
11
|
+
super
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# don't run, just output the command
|
|
17
|
+
def run_with_defer(cmd)
|
|
18
|
+
operation = proc {
|
|
19
|
+
puts(cmd)
|
|
20
|
+
# simulate delay
|
|
21
|
+
#sleep 0.25
|
|
22
|
+
}
|
|
23
|
+
callback = proc {|result|
|
|
24
|
+
runtime.current_file = nil
|
|
25
|
+
}
|
|
26
|
+
EM.defer operation, callback
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# use the MockHandler
|
|
33
|
+
module Autocuke
|
|
34
|
+
class Runtime
|
|
35
|
+
def handler
|
|
36
|
+
::MockHandler
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class HandlerTest < Test::Unit::TestCase
|
|
43
|
+
|
|
44
|
+
def setup
|
|
45
|
+
$modified = false
|
|
46
|
+
@features = Dir[File.expand_path("../../dummy/features/**/*.feature", __FILE__)]
|
|
47
|
+
@options = OpenStruct.new
|
|
48
|
+
@options.root = File.expand_path("../../dummy", __FILE__)
|
|
49
|
+
@options.features = File.join(@options.root, "features")
|
|
50
|
+
@options.verbose = false
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
should "watch a file" do
|
|
54
|
+
|
|
55
|
+
outputs = within_loop do
|
|
56
|
+
File.open(@features.first, 'w+'){ |f| f.write "\n" }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# disregard the start-up message
|
|
60
|
+
outputs.shift
|
|
61
|
+
|
|
62
|
+
assert $modified
|
|
63
|
+
|
|
64
|
+
name = File.basename(@features.first)
|
|
65
|
+
assert_equal "features/#{name} modified - re-cuking it.", outputs.shift
|
|
66
|
+
|
|
67
|
+
commands = outputs.shift.split("; ")
|
|
68
|
+
assert_equal "cd #{@options.root}", commands.first
|
|
69
|
+
assert_equal "bundle exec cucumber -p autocuke features/#{name}", commands.last
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
class RuntimeTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@features = Dir[File.expand_path("../../dummy/features/**/*.feature", __FILE__)]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "A new, invalid runtime" do
|
|
10
|
+
|
|
11
|
+
setup do
|
|
12
|
+
options = OpenStruct.new
|
|
13
|
+
options.root = File.expand_path("../../dummy/that/doesnt/exist", __FILE__)
|
|
14
|
+
options.features = File.join(options.root, "features")
|
|
15
|
+
options.verbose = false
|
|
16
|
+
@rt = Autocuke::Runtime.new(options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should "raise error" do
|
|
20
|
+
assert_raises Autocuke::NoFileError do
|
|
21
|
+
@rt.run!
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
context "A new, valid runtime" do
|
|
29
|
+
|
|
30
|
+
setup do
|
|
31
|
+
options = OpenStruct.new
|
|
32
|
+
options.root = File.expand_path("../../dummy", __FILE__)
|
|
33
|
+
options.features = File.join(options.root, "features")
|
|
34
|
+
options.verbose = false
|
|
35
|
+
@rt = Autocuke::Runtime.new(options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "find features" do
|
|
39
|
+
assert_equal @features, @rt.files
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "start EM reactor" do
|
|
43
|
+
output = capture_stdout do
|
|
44
|
+
EM.run {
|
|
45
|
+
@rt.run!
|
|
46
|
+
EM.stop
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
assert_equal "autocuke is up and running!", output.string.strip
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
context "The default test runtime" do
|
|
56
|
+
|
|
57
|
+
should "also start the EM reactor" do
|
|
58
|
+
outputs = within_loop do
|
|
59
|
+
# nothing
|
|
60
|
+
end
|
|
61
|
+
assert_equal "autocuke is up and running!", outputs.first
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
should "start the EM reactor in verbose mode" do
|
|
65
|
+
outputs = within_loop :verbose => true, do
|
|
66
|
+
# nothing
|
|
67
|
+
end
|
|
68
|
+
assert_equal "Root Set To:", outputs.shift
|
|
69
|
+
assert_equal current_runtime_options.root, outputs.shift
|
|
70
|
+
assert_equal "Watching files:", outputs.shift
|
|
71
|
+
# ignore the line
|
|
72
|
+
outputs.shift
|
|
73
|
+
@features.each do |feature|
|
|
74
|
+
assert_equal feature, outputs.shift
|
|
75
|
+
end
|
|
76
|
+
assert_equal "autocuke is up and running!", outputs.shift
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: autocuke
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Spencer Steffen
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2011-07-14 00:00:00 -07:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: eventmachine
|
|
18
|
+
prerelease: false
|
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
|
+
none: false
|
|
21
|
+
requirements:
|
|
22
|
+
- - ">="
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: 0.12.10
|
|
25
|
+
type: :runtime
|
|
26
|
+
version_requirements: *id001
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dummier
|
|
29
|
+
prerelease: false
|
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
31
|
+
none: false
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 0.2.0
|
|
36
|
+
type: :development
|
|
37
|
+
version_requirements: *id002
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: shoulda
|
|
40
|
+
prerelease: false
|
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 2.11.3
|
|
47
|
+
type: :development
|
|
48
|
+
version_requirements: *id003
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: rails
|
|
51
|
+
prerelease: false
|
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: 3.0.0
|
|
58
|
+
type: :development
|
|
59
|
+
version_requirements: *id004
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: cucumber-rails
|
|
62
|
+
prerelease: false
|
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
64
|
+
none: false
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 1.0.2
|
|
69
|
+
type: :development
|
|
70
|
+
version_requirements: *id005
|
|
71
|
+
- !ruby/object:Gem::Dependency
|
|
72
|
+
name: database_cleaner
|
|
73
|
+
prerelease: false
|
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
75
|
+
none: false
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: 0.6.7
|
|
80
|
+
type: :development
|
|
81
|
+
version_requirements: *id006
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: sqlite3
|
|
84
|
+
prerelease: false
|
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
86
|
+
none: false
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: 1.3.3
|
|
91
|
+
type: :development
|
|
92
|
+
version_requirements: *id007
|
|
93
|
+
description: Autocuke uses EventMachine to watch your .feature files, then automatically runs cucumber as they change. Use with Spork for total awesomeness. Please see README.md for more details.
|
|
94
|
+
email:
|
|
95
|
+
- spencer@citrusme.com
|
|
96
|
+
executables:
|
|
97
|
+
- autocuke
|
|
98
|
+
extensions: []
|
|
99
|
+
|
|
100
|
+
extra_rdoc_files: []
|
|
101
|
+
|
|
102
|
+
files:
|
|
103
|
+
- .gitignore
|
|
104
|
+
- Gemfile
|
|
105
|
+
- LICENSE
|
|
106
|
+
- README.md
|
|
107
|
+
- Rakefile
|
|
108
|
+
- autocuke.gemspec
|
|
109
|
+
- bin/autocuke
|
|
110
|
+
- lib/autocuke.rb
|
|
111
|
+
- lib/autocuke/handler.rb
|
|
112
|
+
- lib/autocuke/runtime.rb
|
|
113
|
+
- lib/autocuke/version.rb
|
|
114
|
+
- test/dummy_hooks/after_migrate.rb.sample
|
|
115
|
+
- test/dummy_hooks/before_migrate.rb
|
|
116
|
+
- test/support/em.rb
|
|
117
|
+
- test/support/kernel.rb
|
|
118
|
+
- test/test_helper.rb
|
|
119
|
+
- test/unit/autocuke_test.rb
|
|
120
|
+
- test/unit/handler_test.rb
|
|
121
|
+
- test/unit/runtime_test.rb
|
|
122
|
+
has_rdoc: true
|
|
123
|
+
homepage: https://github.com/citrus/autocuke
|
|
124
|
+
licenses: []
|
|
125
|
+
|
|
126
|
+
post_install_message:
|
|
127
|
+
rdoc_options: []
|
|
128
|
+
|
|
129
|
+
require_paths:
|
|
130
|
+
- lib
|
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
|
+
none: false
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: "0"
|
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
|
+
none: false
|
|
139
|
+
requirements:
|
|
140
|
+
- - ">="
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: "0"
|
|
143
|
+
requirements: []
|
|
144
|
+
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 1.6.2
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 3
|
|
149
|
+
summary: Autocuke uses EventMachine to watch your .feature files, then automatically runs cucumber as they change. Use with Spork for total awesomeness.
|
|
150
|
+
test_files:
|
|
151
|
+
- test/dummy_hooks/after_migrate.rb.sample
|
|
152
|
+
- test/dummy_hooks/before_migrate.rb
|
|
153
|
+
- test/support/em.rb
|
|
154
|
+
- test/support/kernel.rb
|
|
155
|
+
- test/test_helper.rb
|
|
156
|
+
- test/unit/autocuke_test.rb
|
|
157
|
+
- test/unit/handler_test.rb
|
|
158
|
+
- test/unit/runtime_test.rb
|