judge 0.2.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/.document +5 -0
- data/.travis.yml +18 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +112 -0
- data/LICENSE.txt +20 -0
- data/README.md +20 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/judge.gemspec +155 -0
- data/lib/generators/judge/judge_generator.rb +21 -0
- data/lib/generators/judge/templates/json2.js +483 -0
- data/lib/generators/judge/templates/judge.js +295 -0
- data/lib/generators/judge/templates/underscore.js +840 -0
- data/lib/judge.rb +4 -0
- data/lib/judge/helpers.rb +31 -0
- data/lib/tasks/js_tests.rake +27 -0
- data/spec/javascripts/JudgeSpec.js +670 -0
- data/spec/javascripts/fixtures/form.html +50 -0
- data/spec/javascripts/helpers/customMatchers.js +20 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +204 -0
- data/spec/javascripts/helpers/jquery-1.5.1.min.js +18 -0
- data/spec/javascripts/helpers/json2.js +482 -0
- data/spec/javascripts/helpers/underscore.js +824 -0
- data/spec/javascripts/support/jasmine.yml +79 -0
- data/spec/javascripts/support/jasmine_config.rb +6 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/javascripts/support/phantomRunner.js +28 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/foos_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/foo.rb +11 -0
- data/test/dummy/app/views/foos/new.html.erb +42 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110624115516_create_foos.rb +26 -0
- data/test/dummy/db/schema.rb +34 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +59 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +175 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/judge_test.rb +73 -0
- data/test/test_helper.rb +23 -0
- metadata +275 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- spec/javascripts/helpers/jquery-1.5.1.min.js
|
15
|
+
- spec/javascripts/helpers/json2.js
|
16
|
+
- spec/javascripts/helpers/underscore.js
|
17
|
+
- lib/generators/judge/templates/judge.js
|
18
|
+
|
19
|
+
# stylesheets
|
20
|
+
#
|
21
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
22
|
+
# Default: []
|
23
|
+
#
|
24
|
+
# EXAMPLE:
|
25
|
+
#
|
26
|
+
# stylesheets:
|
27
|
+
# - css/style.css
|
28
|
+
# - stylesheets/*.css
|
29
|
+
#
|
30
|
+
stylesheets:
|
31
|
+
|
32
|
+
# helpers
|
33
|
+
#
|
34
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
35
|
+
# Default: ["helpers/**/*.js"]
|
36
|
+
#
|
37
|
+
# EXAMPLE:
|
38
|
+
#
|
39
|
+
# helpers:
|
40
|
+
# - helpers/**/*.js
|
41
|
+
#
|
42
|
+
helpers:
|
43
|
+
- helpers/jasmine-jquery.js
|
44
|
+
- helpers/customMatchers.js
|
45
|
+
|
46
|
+
# spec_files
|
47
|
+
#
|
48
|
+
# Return an array of filepaths relative to spec_dir to include.
|
49
|
+
# Default: ["**/*[sS]pec.js"]
|
50
|
+
#
|
51
|
+
# EXAMPLE:
|
52
|
+
#
|
53
|
+
# spec_files:
|
54
|
+
# - **/*[sS]pec.js
|
55
|
+
#
|
56
|
+
spec_files:
|
57
|
+
- JudgeSpec.js
|
58
|
+
|
59
|
+
# src_dir
|
60
|
+
#
|
61
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
62
|
+
# Default: project root
|
63
|
+
#
|
64
|
+
# EXAMPLE:
|
65
|
+
#
|
66
|
+
# src_dir: public
|
67
|
+
#
|
68
|
+
src_dir:
|
69
|
+
|
70
|
+
# spec_dir
|
71
|
+
#
|
72
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
73
|
+
# Default: spec/javascripts
|
74
|
+
#
|
75
|
+
# EXAMPLE:
|
76
|
+
#
|
77
|
+
# spec_dir: spec/javascripts
|
78
|
+
#
|
79
|
+
spec_dir:
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'jasmine'
|
5
|
+
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
|
6
|
+
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
|
7
|
+
if Jasmine::rspec2?
|
8
|
+
require 'rspec'
|
9
|
+
else
|
10
|
+
require 'spec'
|
11
|
+
end
|
12
|
+
|
13
|
+
jasmine_config = Jasmine::Config.new
|
14
|
+
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
15
|
+
|
16
|
+
should_stop = false
|
17
|
+
|
18
|
+
if Jasmine::rspec2?
|
19
|
+
RSpec.configuration.after(:suite) do
|
20
|
+
spec_builder.stop if should_stop
|
21
|
+
end
|
22
|
+
else
|
23
|
+
Spec::Runner.configure do |config|
|
24
|
+
config.after(:suite) do
|
25
|
+
spec_builder.stop if should_stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
spec_builder.start
|
31
|
+
should_stop = true
|
32
|
+
spec_builder.declare_suites
|
@@ -0,0 +1,28 @@
|
|
1
|
+
var page = new WebPage();
|
2
|
+
page.open(phantom.args[0], function(status) {
|
3
|
+
if (status !== 'success') {
|
4
|
+
console.log('Cannot open Jasmine server page');
|
5
|
+
phantom.exit();
|
6
|
+
} else {
|
7
|
+
window.setTimeout(function () {
|
8
|
+
var result = page.evaluate(function() {
|
9
|
+
var desc = document.querySelector('.runner .description').innerHTML;
|
10
|
+
if (document.querySelector('.runner.failed')) {
|
11
|
+
var failed = document.querySelectorAll('.spec.failed'),
|
12
|
+
failMsgs = [],
|
13
|
+
output = '';
|
14
|
+
for (var i = 0, l = failed.length; i < l; i += 1) {
|
15
|
+
var msg = ' - ' + failed[i].querySelector('.description').title + ' (' + failed[i].querySelector('.messages .resultMessage').innerHTML + ')';
|
16
|
+
failMsgs.push(msg);
|
17
|
+
};
|
18
|
+
output = '\n' + failMsgs.length + ' specs failed:\n\n' + failMsgs.join('\n') + '\n\n' + desc;
|
19
|
+
return { msg:output, code:1 };
|
20
|
+
} else {
|
21
|
+
return { msg:desc, code:0 };
|
22
|
+
};
|
23
|
+
});
|
24
|
+
console.log(result.msg);
|
25
|
+
phantom.exit(result.code);
|
26
|
+
}, 400);
|
27
|
+
};
|
28
|
+
});
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Foo < ActiveRecord::Base
|
2
|
+
|
3
|
+
validates :one, :presence => true
|
4
|
+
validates :two, :length => { :in => 5..10, :allow_blank => true }
|
5
|
+
validates :three, :exclusion => { :in => %w{foo bar} }
|
6
|
+
validates :four, :numericality => { :only_integer => true, :odd => true, :less_than_or_equal_to => 7 },
|
7
|
+
:exclusion => { :in => [3,12] }
|
8
|
+
validates :five, :format => { :without => /[A-Za-z]+/ }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<h1>New foo</h1>
|
2
|
+
|
3
|
+
<%= validated_form_for(@foo) do |f| %>
|
4
|
+
<% if @foo.errors.any? %>
|
5
|
+
<div id="error_explanation">
|
6
|
+
<h2><%= pluralize(@foo.errors.count, "error") %> prohibited this foo from being saved:</h2>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<% @foo.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<div class="field">
|
17
|
+
<%= f.label :one %><br />
|
18
|
+
<%= f.validated_text_field :one %>
|
19
|
+
</div>
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :two %><br />
|
22
|
+
<%= f.validated_text_field :two %>
|
23
|
+
</div>
|
24
|
+
<div class="field">
|
25
|
+
<%= f.label :three %><br />
|
26
|
+
<%= f.validated_text_field :three %>
|
27
|
+
</div>
|
28
|
+
<div class="field">
|
29
|
+
<%= f.label :four %><br />
|
30
|
+
<%= f.validated_text_area :four %>
|
31
|
+
</div>
|
32
|
+
<div class="field">
|
33
|
+
<%= f.label :five %><br />
|
34
|
+
<%= f.validated_text_area :five %>
|
35
|
+
</div>
|
36
|
+
<div class="actions">
|
37
|
+
<%= f.submit %>
|
38
|
+
</div>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
|
42
|
+
<%= link_to 'Back', foos_path %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
#require "dummy"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|