Description:
updated rspec
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@428 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r199:e0161642a10a - - 7 files changed: 181 inserted, 23 deleted
@@ -0,0 +1,144 | |||
|
1 | + gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 | |
|
2 | + rspec_gem_dir = nil | |
|
3 | + Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| | |
|
4 | + rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") | |
|
5 | + end | |
|
6 | + rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec') | |
|
7 | + | |
|
8 | + if rspec_gem_dir && (test ?d, rspec_plugin_dir) | |
|
9 | + raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n" | |
|
10 | + end | |
|
11 | + | |
|
12 | + if rspec_gem_dir | |
|
13 | + $LOAD_PATH.unshift("#{rspec_gem_dir}/lib") | |
|
14 | + elsif File.exist?(rspec_plugin_dir) | |
|
15 | + $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib") | |
|
16 | + end | |
|
17 | + | |
|
18 | + # Don't load rspec if running "rake gems:*" | |
|
19 | + unless ARGV.any? {|a| a =~ /^gems/} | |
|
20 | + | |
|
21 | + begin | |
|
22 | + require 'spec/rake/spectask' | |
|
23 | + rescue MissingSourceFile | |
|
24 | + module Spec | |
|
25 | + module Rake | |
|
26 | + class SpecTask | |
|
27 | + def initialize(name) | |
|
28 | + task name do | |
|
29 | + # if rspec-rails is a configured gem, this will output helpful material and exit ... | |
|
30 | + require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment")) | |
|
31 | + | |
|
32 | + # ... otherwise, do this: | |
|
33 | + raise <<-MSG | |
|
34 | + | |
|
35 | + #{"*" * 80} | |
|
36 | + * You are trying to run an rspec rake task defined in | |
|
37 | + * #{__FILE__}, | |
|
38 | + * but rspec can not be found in vendor/gems, vendor/plugins or system gems. | |
|
39 | + #{"*" * 80} | |
|
40 | + MSG | |
|
41 | + end | |
|
42 | + end | |
|
43 | + end | |
|
44 | + end | |
|
45 | + end | |
|
46 | + end | |
|
47 | + | |
|
48 | + Rake.application.instance_variable_get('@tasks').delete('default') | |
|
49 | + | |
|
50 | + spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop | |
|
51 | + task :noop do | |
|
52 | + end | |
|
53 | + | |
|
54 | + task :default => :spec | |
|
55 | + task :stats => "spec:statsetup" | |
|
56 | + | |
|
57 | + desc "Run all specs in spec directory (excluding plugin specs)" | |
|
58 | + Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| | |
|
59 | + t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
|
60 | + t.spec_files = FileList['spec/**/*_spec.rb'] | |
|
61 | + end | |
|
62 | + | |
|
63 | + namespace :spec do | |
|
64 | + desc "Run all specs in spec directory with RCov (excluding plugin specs)" | |
|
65 | + Spec::Rake::SpecTask.new(:rcov) do |t| | |
|
66 | + t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
|
67 | + t.spec_files = FileList['spec/**/*_spec.rb'] | |
|
68 | + t.rcov = true | |
|
69 | + t.rcov_opts = lambda do | |
|
70 | + IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten | |
|
71 | + end | |
|
72 | + end | |
|
73 | + | |
|
74 | + desc "Print Specdoc for all specs (excluding plugin specs)" | |
|
75 | + Spec::Rake::SpecTask.new(:doc) do |t| | |
|
76 | + t.spec_opts = ["--format", "specdoc", "--dry-run"] | |
|
77 | + t.spec_files = FileList['spec/**/*_spec.rb'] | |
|
78 | + end | |
|
79 | + | |
|
80 | + desc "Print Specdoc for all plugin examples" | |
|
81 | + Spec::Rake::SpecTask.new(:plugin_doc) do |t| | |
|
82 | + t.spec_opts = ["--format", "specdoc", "--dry-run"] | |
|
83 | + t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*') | |
|
84 | + end | |
|
85 | + | |
|
86 | + [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| | |
|
87 | + desc "Run the code examples in spec/#{sub}" | |
|
88 | + Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| | |
|
89 | + t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
|
90 | + t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] | |
|
91 | + end | |
|
92 | + end | |
|
93 | + | |
|
94 | + desc "Run the code examples in vendor/plugins (except RSpec's own)" | |
|
95 | + Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| | |
|
96 | + t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
|
97 | + t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*") | |
|
98 | + end | |
|
99 | + | |
|
100 | + namespace :plugins do | |
|
101 | + desc "Runs the examples for rspec_on_rails" | |
|
102 | + Spec::Rake::SpecTask.new(:rspec_on_rails) do |t| | |
|
103 | + t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] | |
|
104 | + t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb'] | |
|
105 | + end | |
|
106 | + end | |
|
107 | + | |
|
108 | + # Setup specs for stats | |
|
109 | + task :statsetup do | |
|
110 | + require 'code_statistics' | |
|
111 | + ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') | |
|
112 | + ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') | |
|
113 | + ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') | |
|
114 | + ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') | |
|
115 | + ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') | |
|
116 | + ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing') | |
|
117 | + ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration') | |
|
118 | + ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') | |
|
119 | + ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') | |
|
120 | + ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers') | |
|
121 | + ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers') | |
|
122 | + ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib') | |
|
123 | + ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing') | |
|
124 | + ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration') | |
|
125 | + end | |
|
126 | + | |
|
127 | + namespace :db do | |
|
128 | + namespace :fixtures do | |
|
129 | + desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." | |
|
130 | + task :load => :environment do | |
|
131 | + ActiveRecord::Base.establish_connection(Rails.env) | |
|
132 | + base_dir = File.join(Rails.root, 'spec', 'fixtures') | |
|
133 | + fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir | |
|
134 | + | |
|
135 | + require 'active_record/fixtures' | |
|
136 | + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| | |
|
137 | + Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) | |
|
138 | + end | |
|
139 | + end | |
|
140 | + end | |
|
141 | + end | |
|
142 | + end | |
|
143 | + | |
|
144 | + end |
@@ -0,0 +1,6 | |||
|
1 | + #!/usr/bin/env ruby | |
|
2 | + gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 | |
|
3 | + ENV['RSPEC'] = 'true' # allows autotest to discover rspec | |
|
4 | + ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux | |
|
5 | + system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) || | |
|
6 | + $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH") |
@@ -1,48 +1,50 | |||
|
1 | + THIS IS OUT-DATED. To be updated later. | |
|
2 | + | |
|
1 | 3 | Steps |
|
2 | 4 | ===== |
|
3 | 5 | |
|
4 | 6 | 1. Set up mongrel_cluster |
|
5 | 7 | |
|
6 | 8 | follow: http://mongrel.rubyforge.org/docs/mongrel_cluster.html |
|
7 | 9 | |
|
8 | 10 | run it with user ioi:ioi |
|
9 | 11 | |
|
10 | 12 | |
|
11 | 13 | 2. Set up Apache |
|
12 | 14 | |
|
13 | 15 | in general follow: |
|
14 | 16 | http://mongrel.rubyforge.org/docs/apache.html |
|
15 | 17 | |
|
16 | 18 | 2.1 enable mods |
|
17 | 19 | |
|
18 | 20 | run: |
|
19 | 21 | sudo a2enmod rewrite |
|
20 | 22 | sudo a2enmod proxy |
|
21 | 23 | sudo a2enmod proxy_balancer |
|
22 | 24 | sudo a2enmod proxy_http |
|
23 | 25 | sudo a2enmod deflate |
|
24 | 26 | sudo a2enmod headers |
|
25 | 27 | |
|
26 | 28 | 2.2 edit virtual host at /etc/apache2/site-(available|enabled) |
|
27 | 29 | |
|
28 | 30 | added: |
|
29 | 31 | =========================================== |
|
30 | 32 | <directory "/home/ioi/web_grader/public/"> |
|
31 | 33 | Options FollowSymLinks |
|
32 | 34 | AllowOverride None |
|
33 | 35 | Order allow,deny |
|
34 | 36 | Allow from all |
|
35 | 37 | </directory> |
|
36 | 38 | |
|
37 | 39 | <proxy balancer://mongrel_cluster> |
|
38 | 40 | BalancerMember http://127.0.0.1:8000 |
|
39 | 41 | BalancerMember http://127.0.0.1:8001 |
|
40 | 42 | BalancerMember http://127.0.0.1:8002 |
|
41 | 43 | BalancerMember http://127.0.0.1:8003 |
|
42 | 44 | BalancerMember http://127.0.0.1:8004 |
|
43 | 45 | Allow from all |
|
44 | 46 | </proxy> |
|
45 | 47 | |
|
46 | 48 | # can't use proxypass because we want access to balancer-manager |
|
47 | 49 | #ProxyPass / balancer://mongrel_cluster/ |
|
48 | 50 | #ProxyPassReverse / balancer://mongrel_cluster/ |
@@ -1,105 +1,93 | |||
|
1 | 1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
2 | 2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
3 | 3 | # then regenerate this schema definition. |
|
4 | 4 | # |
|
5 | 5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
6 | 6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | 9 | # |
|
10 | 10 | # It's strongly recommended to check this file into your version control system. |
|
11 | 11 | |
|
12 | 12 | ActiveRecord::Schema.define(:version => 20090815171610) do |
|
13 | 13 | |
|
14 | 14 | create_table "announcements", :force => true do |t| |
|
15 | 15 | t.string "author" |
|
16 | 16 | t.text "body" |
|
17 | 17 | t.boolean "published" |
|
18 | 18 | t.datetime "created_at" |
|
19 | 19 | t.datetime "updated_at" |
|
20 | 20 | t.boolean "frontpage", :default => false |
|
21 | 21 | t.boolean "contest_only", :default => false |
|
22 | 22 | t.string "title" |
|
23 | 23 | end |
|
24 | 24 | |
|
25 | 25 | create_table "configurations", :force => true do |t| |
|
26 | 26 | t.string "key" |
|
27 | 27 | t.string "value_type" |
|
28 | 28 | t.string "value" |
|
29 | 29 | t.datetime "created_at" |
|
30 | 30 | t.datetime "updated_at" |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | create_table "countries", :force => true do |t| |
|
34 | 34 | t.string "name" |
|
35 | 35 | t.datetime "created_at" |
|
36 | 36 | t.datetime "updated_at" |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | create_table "descriptions", :force => true do |t| |
|
40 | 40 | t.text "body" |
|
41 | 41 | t.boolean "markdowned" |
|
42 | 42 | t.datetime "created_at" |
|
43 | 43 | t.datetime "updated_at" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | - create_table "grader_messages", :force => true do |t| | |
|
47 | - t.integer "grader_process_id" | |
|
48 | - t.integer "command" | |
|
49 | - t.string "options" | |
|
50 | - t.integer "target_id" | |
|
51 | - t.boolean "accepted" | |
|
52 | - t.boolean "completed" | |
|
53 | - t.integer "accepting_grader_process_id" | |
|
54 | - t.datetime "created_at" | |
|
55 | - t.datetime "updated_at" | |
|
56 | - end | |
|
57 | - | |
|
58 | 46 | create_table "grader_processes", :force => true do |t| |
|
59 | 47 | t.string "host", :limit => 20 |
|
60 | 48 | t.integer "pid" |
|
61 | 49 | t.string "mode" |
|
62 | 50 | t.boolean "active" |
|
63 | 51 | t.datetime "created_at" |
|
64 | 52 | t.datetime "updated_at" |
|
65 | 53 | t.integer "task_id" |
|
66 | 54 | t.string "task_type" |
|
67 | 55 | t.boolean "terminated" |
|
68 | 56 | end |
|
69 | 57 | |
|
70 | 58 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
71 | 59 | |
|
72 | 60 | create_table "languages", :force => true do |t| |
|
73 | 61 | t.string "name", :limit => 10 |
|
74 | 62 | t.string "pretty_name" |
|
75 | 63 | t.string "ext", :limit => 10 |
|
76 | 64 | t.string "common_ext" |
|
77 | 65 | end |
|
78 | 66 | |
|
79 | 67 | create_table "messages", :force => true do |t| |
|
80 | 68 | t.integer "sender_id" |
|
81 | 69 | t.integer "receiver_id" |
|
82 | 70 | t.integer "replying_message_id" |
|
83 | 71 | t.text "body" |
|
84 | 72 | t.boolean "replied" |
|
85 | 73 | t.datetime "created_at" |
|
86 | 74 | t.datetime "updated_at" |
|
87 | 75 | end |
|
88 | 76 | |
|
89 | 77 | create_table "problems", :force => true do |t| |
|
90 | 78 | t.string "name", :limit => 30 |
|
91 | 79 | t.string "full_name" |
|
92 | 80 | t.integer "full_score" |
|
93 | 81 | t.date "date_added" |
|
94 | 82 | t.boolean "available" |
|
95 | 83 | t.string "url" |
|
96 | 84 | t.integer "description_id" |
|
97 | 85 | t.boolean "test_allowed" |
|
98 | 86 | t.boolean "output_only" |
|
99 | 87 | end |
|
100 | 88 | |
|
101 | 89 | create_table "rights", :force => true do |t| |
|
102 | 90 | t.string "name" |
|
103 | 91 | t.string "controller" |
|
104 | 92 | t.string "action" |
|
105 | 93 | end |
@@ -1,5 +1,10 | |||
|
1 | 1 | #!/usr/bin/env ruby |
|
2 | - $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib")) | |
|
3 | - require 'rubygems' | |
|
4 | - require 'spec' | |
|
5 | - exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT)) | |
|
2 | + if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)} | |
|
3 | + require 'rubygems' unless ENV['NO_RUBYGEMS'] | |
|
4 | + else | |
|
5 | + gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 | |
|
6 | + ENV["RAILS_ENV"] ||= 'test' | |
|
7 | + require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT) | |
|
8 | + end | |
|
9 | + require 'spec/autorun' | |
|
10 | + exit ::Spec::Runner::CommandLine.run |
@@ -1,6 +1,4 | |||
|
1 | 1 | --colour |
|
2 | - --format | |
|
3 | - progress | |
|
4 | - --loadby | |
|
5 | - mtime | |
|
2 | + --format progress | |
|
3 | + --loadby mtime | |
|
6 | 4 | --reverse |
@@ -1,39 +1,54 | |||
|
1 | 1 | # This file is copied to ~/spec when you run 'ruby script/generate rspec' |
|
2 | 2 | # from the project root directory. |
|
3 |
- ENV["RAILS_ENV"] = |
|
|
4 |
- require File.expand_path(File.dirname(__FILE__) |
|
|
5 | - require 'spec' | |
|
3 | + ENV["RAILS_ENV"] ||= 'test' | |
|
4 | + require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) | |
|
5 | + require 'spec/autorun' | |
|
6 | 6 | require 'spec/rails' |
|
7 | 7 | |
|
8 | + # Uncomment the next line to use webrat's matchers | |
|
9 | + #require 'webrat/integrations/rspec-rails' | |
|
10 | + | |
|
11 | + # Requires supporting files with custom matchers and macros, etc, | |
|
12 | + # in ./support/ and its subdirectories. | |
|
13 | + Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} | |
|
14 | + | |
|
8 | 15 | Spec::Runner.configure do |config| |
|
9 | 16 | # If you're not using ActiveRecord you should remove these |
|
10 | 17 | # lines, delete config/database.yml and disable :active_record |
|
11 | 18 | # in your config/boot.rb |
|
12 | 19 | config.use_transactional_fixtures = true |
|
13 | 20 | config.use_instantiated_fixtures = false |
|
14 | 21 | config.fixture_path = RAILS_ROOT + '/spec/fixtures/' |
|
15 | 22 | |
|
16 | 23 | # == Fixtures |
|
17 | 24 | # |
|
18 | 25 | # You can declare fixtures for each example_group like this: |
|
19 | 26 | # describe "...." do |
|
20 | 27 | # fixtures :table_a, :table_b |
|
21 | 28 | # |
|
22 | 29 | # Alternatively, if you prefer to declare them only once, you can |
|
23 | 30 | # do so right here. Just uncomment the next line and replace the fixture |
|
24 | 31 | # names with your fixtures. |
|
25 | 32 | # |
|
26 | 33 | # config.global_fixtures = :table_a, :table_b |
|
27 | 34 | # |
|
28 | 35 | # If you declare global fixtures, be aware that they will be declared |
|
29 | 36 | # for all of your examples, even those that don't use them. |
|
30 | 37 | # |
|
38 | + # You can also declare which fixtures to use (for example fixtures for test/fixtures): | |
|
39 | + # | |
|
40 | + # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' | |
|
41 | + # | |
|
31 | 42 | # == Mock Framework |
|
32 | 43 | # |
|
33 | 44 | # RSpec uses it's own mocking framework by default. If you prefer to |
|
34 | 45 | # use mocha, flexmock or RR, uncomment the appropriate line: |
|
35 | 46 | # |
|
36 | 47 | # config.mock_with :mocha |
|
37 | 48 | # config.mock_with :flexmock |
|
38 | 49 | # config.mock_with :rr |
|
50 | + # | |
|
51 | + # == Notes | |
|
52 | + # | |
|
53 | + # For more information take a look at Spec::Runner::Configuration and Spec::Runner | |
|
39 | 54 | end |
You need to be logged in to leave comments.
Login now