shenandoah 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.braids +8 -0
  2. data/.document +5 -0
  3. data/.gitignore +6 -0
  4. data/ChangeLog.markdown +6 -0
  5. data/LICENSE +20 -0
  6. data/LICENSE-Blue-Ridge +20 -0
  7. data/LICENSE-Screw.Unit +22 -0
  8. data/LICENSE-Smoke +22 -0
  9. data/README.markdown +260 -0
  10. data/Rakefile +70 -0
  11. data/VERSION.yml +4 -0
  12. data/lib/shenandoah/buildr.rb +9 -0
  13. data/lib/shenandoah/buildr/locator.rb +17 -0
  14. data/lib/shenandoah/buildr/shenandoah_tasks.rb +18 -0
  15. data/lib/shenandoah/buildr/test_framework.rb +28 -0
  16. data/lib/shenandoah/css/screw.css +90 -0
  17. data/lib/shenandoah/javascript/browser/runner.js +34 -0
  18. data/lib/shenandoah/javascript/common/jquery-1.3.2.js +4376 -0
  19. data/lib/shenandoah/javascript/common/jquery.fn.js +29 -0
  20. data/lib/shenandoah/javascript/common/jquery.print.js +109 -0
  21. data/lib/shenandoah/javascript/common/screw.behaviors.js +129 -0
  22. data/lib/shenandoah/javascript/common/screw.builder.js +104 -0
  23. data/lib/shenandoah/javascript/common/screw.events.js +45 -0
  24. data/lib/shenandoah/javascript/common/screw.matchers.js +254 -0
  25. data/lib/shenandoah/javascript/common/screw.mocking.js +22 -0
  26. data/lib/shenandoah/javascript/common/smoke.core.js +6 -0
  27. data/lib/shenandoah/javascript/common/smoke.mock.js +130 -0
  28. data/lib/shenandoah/javascript/common/smoke.stub.js +29 -0
  29. data/lib/shenandoah/javascript/console/consoleReportForRake.js +32 -0
  30. data/lib/shenandoah/javascript/console/env.rhino.js +8841 -0
  31. data/lib/shenandoah/javascript/console/js.jar +0 -0
  32. data/lib/shenandoah/javascript/console/runner.js +43 -0
  33. data/lib/shenandoah/javascript/console/shell.js.erb +23 -0
  34. data/lib/shenandoah/locator.rb +17 -0
  35. data/lib/shenandoah/runner.rb +69 -0
  36. data/lib/shenandoah/server.rb +88 -0
  37. data/lib/shenandoah/server/views/index.haml +12 -0
  38. data/lib/shenandoah/tasks.rb +58 -0
  39. data/shenandoah.gemspec +133 -0
  40. data/spec/shenandoah/buildr/locator_spec.rb +33 -0
  41. data/spec/shenandoah/buildr/shenandoah_tasks_spec.rb +27 -0
  42. data/spec/shenandoah/buildr/spec_helper.rb +2 -0
  43. data/spec/shenandoah/buildr/test_framework_spec.rb +77 -0
  44. data/spec/shenandoah/locator_spec.rb +74 -0
  45. data/spec/shenandoah/runner_spec.rb +110 -0
  46. data/spec/shenandoah/server_spec.rb +216 -0
  47. data/spec/shenandoah/tasks_spec.rb +76 -0
  48. data/spec/spec_helper.rb +36 -0
  49. metadata +232 -0
@@ -0,0 +1,43 @@
1
+ if(arguments.length == 0) {
2
+ print("Usage: test_runner.js /path/to/shenandoah /path/to/mainfiles /path/to/specfiles file_spec.js");
3
+ quit(1);
4
+ }
5
+
6
+ var SHENANDOAH = arguments[0]
7
+ var MAIN_PATH = arguments[1]
8
+ var SPEC_PATH = arguments[2]
9
+ var SPEC_FILE = arguments[3]
10
+
11
+ function require_main(file) {
12
+ require_absolute(MAIN_PATH + '/' + file)
13
+ }
14
+
15
+ function require_spec(file) {
16
+ require_absolute(SPEC_PATH + '/' + file)
17
+ }
18
+
19
+ function require_absolute(file) {
20
+ load(file)
21
+ }
22
+
23
+ var fixture = SPEC_FILE.replace(/^(.*?)_spec\.js$/, "$1.html");
24
+ print("Running " + SPEC_FILE + " with fixture '" + fixture + "'");
25
+
26
+ load(SHENANDOAH + "/lib/shenandoah/javascript/console/env.rhino.js");
27
+ window.location = fixture;
28
+
29
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/jquery-1.3.2.js");
30
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/jquery.fn.js");
31
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/jquery.print.js");
32
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/screw.builder.js");
33
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/screw.matchers.js");
34
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/screw.events.js");
35
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/screw.behaviors.js");
36
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/smoke.core.js");
37
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/smoke.mock.js");
38
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/smoke.stub.js");
39
+ load(SHENANDOAH + "/lib/shenandoah/javascript/common/screw.mocking.js");
40
+ load(SHENANDOAH + "/lib/shenandoah/javascript/console/consoleReportForRake.js");
41
+
42
+ load(SPEC_PATH + '/' + SPEC_FILE);
43
+ jQuery(window).trigger("load");
@@ -0,0 +1,23 @@
1
+ (function(){
2
+ var _old_quit = this.quit;
3
+ this.__defineGetter__("exit", function(){ _old_quit() });
4
+ this.__defineGetter__("quit", function(){ _old_quit() });
5
+
6
+ print("=================================================");
7
+ print(" Rhino JavaScript Shell");
8
+ print(" To exit type 'exit', 'quit', or 'quit()'.");
9
+ print("=================================================");
10
+
11
+ load("<%= shenandoah_root %>/lib/shenandoah/javascript/console/env.rhino.js");
12
+ print(" - loaded env.js");
13
+
14
+ window.location = "<%= shell_html_path %>";
15
+ print(" - sample DOM loaded");
16
+
17
+ load("<%= shenandoah_root %>/lib/shenandoah/javascript/common/jquery-1.3.2.js");
18
+ print (" jQuery-1.3.2 loaded");
19
+ // load(PLUGIN_PREFIX + "lib/jquery-1.2.6.js");
20
+ // print(" - jQuery-1.2.6 loaded");
21
+
22
+ print("=================================================");
23
+ })();
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+
3
+ module Shenandoah
4
+ class DefaultLocator
5
+ attr_accessor :main_path, :spec_path, :tmp_path
6
+
7
+ def initialize(options = {})
8
+ @main_path = options[:main_path] || "lib"
9
+ @spec_path = options[:spec_path] || "spec"
10
+ @tmp_path = options[:tmp_path] || ENV['TMPDIR'] || "tmp"
11
+ end
12
+
13
+ def spec_files
14
+ FileList["#{spec_path}/**/*_spec.js"]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,69 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+
4
+ module Shenandoah
5
+ class Runner
6
+ def initialize(locator, options = {})
7
+ @locator = locator
8
+ @quiet = options[:quiet]
9
+ end
10
+
11
+ # Runs the specified specs. Returns an array of the specs that passed.
12
+ def run_console(specs)
13
+ FileUtils.cd @locator.spec_path do
14
+ runner_cmd = rhino_command(shen_path_to('lib/shenandoah/javascript/console/runner.js'))
15
+ args = [
16
+ shen_path_to,
17
+ @locator.main_path,
18
+ @locator.spec_path
19
+ ]
20
+
21
+ return specs.select { |spec|
22
+ system("#{runner_cmd} '#{args.join("' '")}' '#{spec.sub(%r{^#{@locator.spec_path}/}, '')}' #{@quiet ? '> /dev/null' : ''}")
23
+ }
24
+ end
25
+ end
26
+
27
+ def run_shell
28
+ create_shell_html
29
+ create_shell_js
30
+
31
+ rlwrap = `which rlwrap`.chomp
32
+ cmd = "#{rlwrap} #{rhino_command('-f', shell_js_path, '-f', '-')}"
33
+ $stderr.puts "Starting shell with #{cmd}"
34
+ system(cmd)
35
+ end
36
+
37
+ private
38
+
39
+ def shen_path_to(file=nil)
40
+ File.expand_path(File.dirname(__FILE__) + "/../../#{file}")
41
+ end
42
+ alias :shenandoah_root :shen_path_to
43
+
44
+ def rhino_command(*args)
45
+ "java -jar '#{shen_path_to 'lib/shenandoah/javascript/console/js.jar'}' -w -debug '#{args.join("' '")}'"
46
+ end
47
+
48
+ def shell_html_path
49
+ "#{@locator.tmp_path}/shell.html"
50
+ end
51
+
52
+ def shell_js_path
53
+ "#{@locator.tmp_path}/shell.js"
54
+ end
55
+
56
+ def create_shell_html
57
+ FileUtils.mkdir_p File.dirname(shell_html_path)
58
+ File.open(shell_html_path, 'w') do |f|
59
+ f.write "<html><body></body></html>"
60
+ end
61
+ end
62
+
63
+ def create_shell_js
64
+ js = ERB.new(File.read(shen_path_to('lib/shenandoah/javascript/console/shell.js.erb'))).result(binding)
65
+ FileUtils.mkdir_p File.dirname(shell_js_path)
66
+ File.open(shell_js_path, 'w') { |f| f.write js }
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,88 @@
1
+ require 'sinatra'
2
+ require 'haml'
3
+
4
+ module Shenandoah
5
+ # The server which enables in-browser execution of Screw.Unit specs in
6
+ # Shenandoah.
7
+ #
8
+ # It exposes a list of all the specs at the root of the server,
9
+ # organized by subdirectory, with links to individual test fixtures.
10
+ # The contents of the +main_path+ and +spec_path+ in the configured locator
11
+ # are exposed under <tt>/main</tt> and <tt>/spec</tt> respectively.
12
+ class Server < Sinatra::Base
13
+ set :root, File.dirname(__FILE__) + "/server"
14
+ set :port, 4410
15
+ enable :logging
16
+
17
+ get '/' do
18
+ section_map = options.locator.spec_files.
19
+ collect { |t| t.sub(%r{^#{options.locator.spec_path}/?}, '') }.
20
+ collect { |t| [File.dirname(t), File.basename(t).sub(/_spec.js$/, '.html')] }.
21
+ inject({}) { |h, (dir, file)| h[dir] ||= []; h[dir] << file; h }
22
+ @sections = section_map.collect { |dir, files| [dir, files.sort] }.sort
23
+
24
+ haml :index
25
+ end
26
+
27
+ get '/main/*' do
28
+ map_file(options.locator.main_path, params[:splat].first, "Main")
29
+ end
30
+
31
+ get '/spec/*' do
32
+ map_file(options.locator.spec_path, params[:splat].first, "Spec")
33
+ end
34
+
35
+ get '/screw.css' do
36
+ screw_css = File.join(options.locator.spec_path, 'screw.css')
37
+ unless File.exist?(screw_css)
38
+ screw_css = File.join(File.dirname(__FILE__), 'css/screw.css')
39
+ end
40
+ send_file screw_css
41
+ end
42
+
43
+ get '/shenandoah/browser-runner.js' do
44
+ content_type 'text/javascript'
45
+
46
+ last_modified runner_files.collect { |filename|
47
+ File.stat("#{File.dirname(__FILE__)}/#{filename}").mtime
48
+ }.max
49
+
50
+ runner_files.collect { |filename|
51
+ [
52
+ "\n//////\n////// #{filename}\n//////\n",
53
+ File.read("#{File.dirname(__FILE__)}/#{filename}")
54
+ ]
55
+ }.flatten
56
+ end
57
+
58
+ protected
59
+
60
+ def map_file(path, name, desc) # :nodoc:
61
+ file = File.join(path, name)
62
+ if File.exist?(file)
63
+ headers['Cache-Control'] = 'no-cache'
64
+ send_file file
65
+ else
66
+ halt 404, "#{desc} file not found: #{file}"
67
+ end
68
+ end
69
+
70
+ def runner_files # :nodoc:
71
+ # Can't just use Dir[] because order is important
72
+ [
73
+ "javascript/common/jquery-1.3.2.js",
74
+ "javascript/common/jquery.fn.js",
75
+ "javascript/common/jquery.print.js",
76
+ "javascript/common/screw.builder.js",
77
+ "javascript/common/screw.matchers.js",
78
+ "javascript/common/screw.events.js",
79
+ "javascript/common/screw.behaviors.js",
80
+ "javascript/common/smoke.core.js",
81
+ "javascript/common/smoke.mock.js",
82
+ "javascript/common/smoke.stub.js",
83
+ "javascript/common/screw.mocking.js",
84
+ "javascript/browser/runner.js"
85
+ ]
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,12 @@
1
+ %html
2
+ %head
3
+ %link{ :rel => "stylesheet", :href => "/screw.css", :type => "text/css", :charset => "utf-8" }
4
+ %body
5
+ - if options.respond_to?(:project_name) && options.project_name
6
+ %h1= "Specs for #{options.project_name}"
7
+ - @sections.each do |section, tests|
8
+ %h2= section == '.' ? '[root]' : section
9
+ %ul
10
+ - tests.each do |test|
11
+ %li
12
+ %a{ :href => ["spec", section, test].reject { |s| s == '.' }.join('/') }= test.sub(/.html$/, '')
@@ -0,0 +1,58 @@
1
+ require 'rake'
2
+ require 'shenandoah/runner'
3
+ require 'shenandoah/server'
4
+
5
+ module Shenandoah
6
+ class Tasks
7
+ attr_accessor :locator, :options, :runner
8
+
9
+ def initialize(options = {})
10
+ @options = options
11
+ @locator =
12
+ if options[:locator]
13
+ options[:locator]
14
+ else
15
+ DefaultLocator.new(options)
16
+ end
17
+ @runner = Shenandoah::Runner.new(@locator)
18
+ create_serve_task
19
+ create_shell_task
20
+ create_run_task
21
+ end
22
+
23
+ def run_specs
24
+ files = @locator.spec_files
25
+ if ENV['SHEN_SPEC']
26
+ files = files.select { |f| f =~ /#{ENV['SHEN_SPEC']}/ }
27
+ end
28
+ successes = @runner.run_console(files)
29
+ if (successes.size != files.size)
30
+ raise "Shenandoah specs failed!"
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ def create_serve_task
37
+ task('shen:serve') do |t|
38
+ Shenandoah::Server.set :locator, @locator
39
+ if @options[:project_name]
40
+ Shenandoah::Server.set :project_name, @options[:project_name]
41
+ end
42
+ Shenandoah::Server.run!
43
+ end
44
+ end
45
+
46
+ def create_shell_task
47
+ task('shen:shell') do |t|
48
+ @runner.run_shell
49
+ end
50
+ end
51
+
52
+ def create_run_task
53
+ task('shen:spec') do |t|
54
+ run_specs
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,133 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{shenandoah}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Rhett Sutphin"]
9
+ s.date = %q{2009-06-14}
10
+ s.email = %q{rhett@detailedbalance.net}
11
+ s.extra_rdoc_files = [
12
+ "ChangeLog.markdown",
13
+ "LICENSE",
14
+ "LICENSE-Blue-Ridge",
15
+ "LICENSE-Screw.Unit",
16
+ "LICENSE-Smoke",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".braids",
21
+ ".document",
22
+ ".gitignore",
23
+ "ChangeLog.markdown",
24
+ "LICENSE",
25
+ "LICENSE-Blue-Ridge",
26
+ "LICENSE-Screw.Unit",
27
+ "LICENSE-Smoke",
28
+ "README.markdown",
29
+ "Rakefile",
30
+ "VERSION.yml",
31
+ "lib/shenandoah/buildr.rb",
32
+ "lib/shenandoah/buildr/locator.rb",
33
+ "lib/shenandoah/buildr/shenandoah_tasks.rb",
34
+ "lib/shenandoah/buildr/test_framework.rb",
35
+ "lib/shenandoah/css/screw.css",
36
+ "lib/shenandoah/javascript/browser/runner.js",
37
+ "lib/shenandoah/javascript/common/jquery-1.3.2.js",
38
+ "lib/shenandoah/javascript/common/jquery.fn.js",
39
+ "lib/shenandoah/javascript/common/jquery.print.js",
40
+ "lib/shenandoah/javascript/common/screw.behaviors.js",
41
+ "lib/shenandoah/javascript/common/screw.builder.js",
42
+ "lib/shenandoah/javascript/common/screw.events.js",
43
+ "lib/shenandoah/javascript/common/screw.matchers.js",
44
+ "lib/shenandoah/javascript/common/screw.mocking.js",
45
+ "lib/shenandoah/javascript/common/smoke.core.js",
46
+ "lib/shenandoah/javascript/common/smoke.mock.js",
47
+ "lib/shenandoah/javascript/common/smoke.stub.js",
48
+ "lib/shenandoah/javascript/console/consoleReportForRake.js",
49
+ "lib/shenandoah/javascript/console/env.rhino.js",
50
+ "lib/shenandoah/javascript/console/js.jar",
51
+ "lib/shenandoah/javascript/console/runner.js",
52
+ "lib/shenandoah/javascript/console/shell.js.erb",
53
+ "lib/shenandoah/locator.rb",
54
+ "lib/shenandoah/runner.rb",
55
+ "lib/shenandoah/server.rb",
56
+ "lib/shenandoah/server/views/index.haml",
57
+ "lib/shenandoah/tasks.rb",
58
+ "shenandoah.gemspec",
59
+ "spec/shenandoah/buildr/locator_spec.rb",
60
+ "spec/shenandoah/buildr/shenandoah_tasks_spec.rb",
61
+ "spec/shenandoah/buildr/spec_helper.rb",
62
+ "spec/shenandoah/buildr/test_framework_spec.rb",
63
+ "spec/shenandoah/locator_spec.rb",
64
+ "spec/shenandoah/runner_spec.rb",
65
+ "spec/shenandoah/server_spec.rb",
66
+ "spec/shenandoah/tasks_spec.rb",
67
+ "spec/spec_helper.rb"
68
+ ]
69
+ s.has_rdoc = true
70
+ s.homepage = %q{http://github.com/rsutphin/shenandoah}
71
+ s.rdoc_options = ["--charset=UTF-8"]
72
+ s.require_paths = ["lib"]
73
+ s.rubyforge_project = %q{detailedbalance}
74
+ s.rubygems_version = %q{1.3.1}
75
+ s.summary = %q{A javascript test framework for buildr, rails, and other ruby-built projects}
76
+ s.test_files = [
77
+ "spec/shenandoah/buildr/locator_spec.rb",
78
+ "spec/shenandoah/buildr/shenandoah_tasks_spec.rb",
79
+ "spec/shenandoah/buildr/spec_helper.rb",
80
+ "spec/shenandoah/buildr/test_framework_spec.rb",
81
+ "spec/shenandoah/locator_spec.rb",
82
+ "spec/shenandoah/runner_spec.rb",
83
+ "spec/shenandoah/server_spec.rb",
84
+ "spec/shenandoah/tasks_spec.rb",
85
+ "spec/spec_helper.rb"
86
+ ]
87
+
88
+ if s.respond_to? :specification_version then
89
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
90
+ s.specification_version = 2
91
+
92
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
93
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
94
+ s.add_runtime_dependency(%q<haml>, [">= 2.0.9"])
95
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
96
+ s.add_development_dependency(%q<rspec>, ["= 1.2.4"])
97
+ s.add_development_dependency(%q<rack-test>, [">= 0.3.0"])
98
+ s.add_development_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
99
+ s.add_development_dependency(%q<braid>, [">= 0.5.0"])
100
+ s.add_development_dependency(%q<rake>, ["= 0.8.4"])
101
+ s.add_development_dependency(%q<net-ssh>, ["= 2.0.11"])
102
+ s.add_development_dependency(%q<net-sftp>, ["= 2.0.2"])
103
+ s.add_development_dependency(%q<highline>, ["= 1.5.0"])
104
+ s.add_development_dependency(%q<hoe>, ["= 1.12.2"])
105
+ else
106
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
107
+ s.add_dependency(%q<haml>, [">= 2.0.9"])
108
+ s.add_dependency(%q<rake>, [">= 0"])
109
+ s.add_dependency(%q<rspec>, ["= 1.2.4"])
110
+ s.add_dependency(%q<rack-test>, [">= 0.3.0"])
111
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
112
+ s.add_dependency(%q<braid>, [">= 0.5.0"])
113
+ s.add_dependency(%q<rake>, ["= 0.8.4"])
114
+ s.add_dependency(%q<net-ssh>, ["= 2.0.11"])
115
+ s.add_dependency(%q<net-sftp>, ["= 2.0.2"])
116
+ s.add_dependency(%q<highline>, ["= 1.5.0"])
117
+ s.add_dependency(%q<hoe>, ["= 1.12.2"])
118
+ end
119
+ else
120
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
121
+ s.add_dependency(%q<haml>, [">= 2.0.9"])
122
+ s.add_dependency(%q<rake>, [">= 0"])
123
+ s.add_dependency(%q<rspec>, ["= 1.2.4"])
124
+ s.add_dependency(%q<rack-test>, [">= 0.3.0"])
125
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
126
+ s.add_dependency(%q<braid>, [">= 0.5.0"])
127
+ s.add_dependency(%q<rake>, ["= 0.8.4"])
128
+ s.add_dependency(%q<net-ssh>, ["= 2.0.11"])
129
+ s.add_dependency(%q<net-sftp>, ["= 2.0.2"])
130
+ s.add_dependency(%q<highline>, ["= 1.5.0"])
131
+ s.add_dependency(%q<hoe>, ["= 1.12.2"])
132
+ end
133
+ end