├── spec ├── screw_unit │ ├── resources │ │ ├── file_system_fixtures │ │ │ ├── foo.css │ │ │ ├── foo.gif │ │ │ ├── foo.jpeg │ │ │ ├── foo.jpg │ │ │ ├── foo.png │ │ │ ├── foo.js │ │ │ ├── specs │ │ │ │ ├── foo_spec.js │ │ │ │ └── subsuite │ │ │ │ │ └── bar_spec.js │ │ │ └── code_under_test │ │ │ │ └── code_under_test.js │ │ ├── root_spec.rb │ │ ├── spec_runner_spec.rb │ │ ├── spec_suite_spec.rb │ │ ├── spec_dir_spec.rb │ │ ├── suite_completion_spec.rb │ │ ├── dir_spec.rb │ │ └── file_spec.rb │ ├── file_system_fixtures_for_asset_manager_specs │ │ ├── dir │ │ │ └── 6.js │ │ ├── dir_1 │ │ │ ├── 7.js │ │ │ ├── subdir_1 │ │ │ │ └── 4.js │ │ │ └── 1.js │ │ ├── dir_2 │ │ │ └── 2.js │ │ ├── dir_4 │ │ │ └── 1.css │ │ └── dir_3 │ │ │ ├── subdir_3 │ │ │ └── 5.js │ │ │ └── 3.js │ ├── server_spec.rb │ ├── array_extension_spec.rb │ ├── js_file_spec.rb │ ├── asset_location_spec.rb │ ├── configuration_spec.rb │ ├── dispatcher_spec.rb │ └── asset_manager_spec.rb ├── screw_unit_spec_suite.rb └── screw_unit_spec_helper.rb ├── .gitignore ├── example ├── lib │ ├── example.js │ └── models │ │ ├── cat.js │ │ └── man.js ├── .screwrc └── spec │ ├── spec_helper.js │ ├── matchers │ └── have.js │ ├── suite.html │ └── models │ ├── cat_spec.js │ └── man_spec.js ├── client ├── vendor │ ├── screw.monarch_view.js │ ├── jquery.print.js │ └── jquery.cookie.js ├── lib │ ├── screw │ │ ├── context.js │ │ ├── runnable_methods.js │ │ ├── interface.js │ │ ├── interface │ │ │ ├── example.js │ │ │ ├── progress_bar.js │ │ │ ├── description.js │ │ │ ├── streaming_runner.js │ │ │ └── runner.js │ │ ├── require.js │ │ ├── screw.js │ │ ├── example.js │ │ ├── keywords.js │ │ ├── description.js │ │ └── matchers.js │ └── screw.js ├── stylesheets │ └── screw.css └── spec │ ├── interface │ ├── progress_bar_spec.js │ ├── example_spec.js │ ├── description_spec.js │ └── runner_spec.js │ ├── print_spec.js │ ├── example_spec.js │ ├── mock_spec.js │ ├── integration_spec.js │ ├── description_spec.js │ └── matchers_spec.js ├── .screwrc ├── lib ├── screw_unit │ ├── string_extension.rb │ ├── array_extension.rb │ ├── resources.rb │ ├── resources │ │ ├── file_not_found.rb │ │ ├── root.rb │ │ ├── suite_completion.rb │ │ ├── dir.rb │ │ ├── streaming_spec_runner.rb │ │ ├── file.rb │ │ ├── spec_dir.rb │ │ └── spec_runner.rb │ ├── dispatcher.rb │ ├── server.rb │ ├── js_file.rb │ ├── asset_manager.rb │ ├── asset_location.rb │ └── configuration.rb └── screw_unit.rb ├── todo ├── Rakefile ├── bin └── screw ├── README.txt └── README.markdown /spec/screw_unit/resources/file_system_fixtures/foo.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/foo.gif: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/foo.jpeg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/foo.jpg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/foo.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/foo.js: -------------------------------------------------------------------------------- 1 | var foo = {}; -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/specs/foo_spec.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir/6.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_1/7.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_2/2.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_4/1.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/specs/subsuite/bar_spec.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.ipr 3 | *.iws 4 | .DS_Store 5 | pkg 6 | .rakeTasks 7 | .idea -------------------------------------------------------------------------------- /example/lib/example.js: -------------------------------------------------------------------------------- 1 | //= require "models/cat" 2 | //= require "models/man" 3 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_3/subdir_3/5.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/screw_unit/resources/file_system_fixtures/code_under_test/code_under_test.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_1/subdir_1/4.js: -------------------------------------------------------------------------------- 1 | //= require "../7" 2 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_3/3.js: -------------------------------------------------------------------------------- 1 | //= require "subdir_3/5" 2 | -------------------------------------------------------------------------------- /client/vendor/screw.monarch_view.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathansobo/screw-unit/HEAD/client/vendor/screw.monarch_view.js -------------------------------------------------------------------------------- /spec/screw_unit_spec_suite.rb: -------------------------------------------------------------------------------- 1 | dir = File.dirname(__FILE__) 2 | Dir.glob("#{dir}/**/*_spec.rb").each do |spec_file| 3 | require spec_file 4 | end -------------------------------------------------------------------------------- /.screwrc: -------------------------------------------------------------------------------- 1 | ScrewUnit.configure do 2 | port 8181 3 | add_js_location "/under_test", "client/lib" 4 | add_js_location "/specs", "client/spec" 5 | end 6 | -------------------------------------------------------------------------------- /spec/screw_unit/file_system_fixtures_for_asset_manager_specs/dir_1/1.js: -------------------------------------------------------------------------------- 1 | //= require "subdir_1/4" 2 | //= require "7" 3 | //= require <3> 4 | var x = 1; 5 | -------------------------------------------------------------------------------- /example/.screwrc: -------------------------------------------------------------------------------- 1 | ScrewUnit.configure do 2 | port 8082 3 | add_js_location "/under_test", "lib" 4 | add_js_location "/specs", "spec" 5 | end 6 | -------------------------------------------------------------------------------- /example/lib/models/cat.js: -------------------------------------------------------------------------------- 1 | function Cat(options) { 2 | this.cross_path = function(man) { 3 | if (options.color == 'black') man.decrement_luck(5); 4 | }; 5 | } -------------------------------------------------------------------------------- /client/lib/screw/context.js: -------------------------------------------------------------------------------- 1 | (function(Screw, Monarch, jQuery) { 2 | 3 | Monarch.constructor("Screw.Context", Screw.Matchers, Screw.Keywords); 4 | 5 | })(Screw, Monarch); 6 | -------------------------------------------------------------------------------- /lib/screw_unit/string_extension.rb: -------------------------------------------------------------------------------- 1 | class String 2 | def starts_with?(prefix) 3 | index(prefix) == 0 4 | end 5 | 6 | def path_starts_with?(prefix) 7 | split('/').starts_with?(prefix.split('/')) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /todo: -------------------------------------------------------------------------------- 1 | [ ] - change mock_function to take an optional function_name as its first argument (it should be able to take both a name and a function to call) 2 | [ ] - add specs for jquery_mapper 3 | [ ] - add specs for match_html 4 | [ ] - screw specs no longer run... wtf -------------------------------------------------------------------------------- /example/spec/spec_helper.js: -------------------------------------------------------------------------------- 1 | //= require ; 2 | 3 | Screw.Unit(function(c) { with(c) { 4 | before(function() { 5 | Screw.$('dom_test').empty(); // Screw comes with its own version of jQuery, located Screw.$ to keep out of your version's way if you have one 6 | }); 7 | }}); 8 | -------------------------------------------------------------------------------- /spec/screw_unit_spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "rubygems" 2 | require "spec" 3 | 4 | dir = File.dirname(__FILE__) 5 | require File.expand_path("#{dir}/../lib/screw_unit") 6 | 7 | Spec::Runner.configure do |config| 8 | config.mock_with :rr 9 | end 10 | 11 | at_exit do 12 | Spec::Runner.run 13 | end 14 | -------------------------------------------------------------------------------- /lib/screw_unit/array_extension.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | def starts_with?(prefix) 3 | return true if prefix.empty? 4 | return false if prefix.size > size 5 | prefix.each_with_index do |element, index| 6 | return false unless self[index] == element 7 | end 8 | true 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /example/spec/matchers/have.js: -------------------------------------------------------------------------------- 1 | Screw.Matchers["have"] = { 2 | match: function(expected, actual) { 3 | return actual.find(expected).length > 0; 4 | }, 5 | failure_message: function(expected, actual, not) { 6 | return 'expected ' + $.print(actual) + (not ? ' to not have ' : ' to have ') + $.print(expected); 7 | } 8 | } -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # -*- ruby -*- 2 | 3 | require 'rubygems' 4 | require 'hoe' 5 | require './lib/screw_unit.rb' 6 | 7 | Hoe.new('screw_unit', ScrewUnit::VERSION) do |p| 8 | # p.rubyforge_name = 'screw_unitx' # if different than lowercase project name 9 | p.developer('Nathan Sobo', 'nathansobo@gmail.com') 10 | end 11 | 12 | # vim: syntax=Ruby 13 | -------------------------------------------------------------------------------- /lib/screw_unit/resources.rb: -------------------------------------------------------------------------------- 1 | dir = File.dirname(__FILE__) 2 | require "#{dir}/resources/file" 3 | require "#{dir}/resources/dir" 4 | require "#{dir}/resources/root" 5 | require "#{dir}/resources/spec_dir" 6 | require "#{dir}/resources/spec_runner" 7 | require "#{dir}/resources/streaming_spec_runner" 8 | require "#{dir}/resources/file_not_found" 9 | require "#{dir}/resources/suite_completion" 10 | -------------------------------------------------------------------------------- /bin/screw: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | dir = File.dirname(__FILE__) 4 | $LOAD_PATH.push("#{dir}/../lib/") 5 | require "screw_unit" 6 | 7 | configuration = ScrewUnit::Configuration.instance 8 | configuration.load_screwrc(Dir.pwd) 9 | configuration.selenium_mode if ARGV.include?("--selenium") 10 | 11 | $exit_status = 0 12 | 13 | ScrewUnit::Server.start(configuration) 14 | 15 | exit $exit_status 16 | -------------------------------------------------------------------------------- /client/lib/screw/runnable_methods.js: -------------------------------------------------------------------------------- 1 | (function(Screw, Monarch) { 2 | 3 | Monarch.module("Screw.RunnableMethods", { 4 | path: function() { 5 | if (!this.parentDescription) { 6 | return []; 7 | } 8 | return this.parentDescription.path().concat([this.index]); 9 | }, 10 | 11 | onExampleCompleted: function(callback) { 12 | return this.exampleCompletedSubscriptionNode.subscribe(callback); 13 | } 14 | }); 15 | 16 | })(Screw, Monarch); 17 | 18 | -------------------------------------------------------------------------------- /example/lib/models/man.js: -------------------------------------------------------------------------------- 1 | function Man(options) { 2 | var luck = options.luck; 3 | 4 | this.decrement_luck = function(delta) { 5 | luck = Math.max(0, luck - delta); 6 | }; 7 | this.luck = function() { 8 | return luck; 9 | }; 10 | this.render = function() { 11 | return Screw.$('