Description:
[web] added submission spec
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@136 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
r62:ad0cd1a4447d - - 1 file changed: 37 inserted, 0 deleted
@@ -0,0 +1,37 | |||||
|
|
1 | + | ||
|
|
2 | + require File.dirname(__FILE__) + '/../spec_helper' | ||
|
|
3 | + | ||
|
|
4 | + describe Submission do | ||
|
|
5 | + | ||
|
|
6 | + before(:each) do | ||
|
|
7 | + @submission = Submission.new | ||
|
|
8 | + @submission.source = <<SOURCE | ||
|
|
9 | + /* | ||
|
|
10 | + LANG: C++ | ||
|
|
11 | + TASK: testproblem | ||
|
|
12 | + */ | ||
|
|
13 | + SOURCE | ||
|
|
14 | + end | ||
|
|
15 | + | ||
|
|
16 | + it "should find language in source" do | ||
|
|
17 | + langcpp = stub(Language, :name => 'cpp', :ext => 'cpp') | ||
|
|
18 | + Language.should_receive(:find_by_name).with('C++').and_return(langcpp) | ||
|
|
19 | + Submission.find_language_in_source(@submission.source).should == langcpp | ||
|
|
20 | + end | ||
|
|
21 | + | ||
|
|
22 | + it "should find problem in source, when there is any" do | ||
|
|
23 | + problem = stub(Problem, :name => 'testproblem') | ||
|
|
24 | + Problem.should_receive(:find_by_name).with('testproblem').and_return(problem) | ||
|
|
25 | + Submission.find_problem_in_source(@submission.source).should == problem | ||
|
|
26 | + end | ||
|
|
27 | + | ||
|
|
28 | + it "should return nil when it cannot find problem in source" do | ||
|
|
29 | + Submission.find_problem_in_source(<<SOURCE | ||
|
|
30 | + /* | ||
|
|
31 | + LANG: C | ||
|
|
32 | + */ | ||
|
|
33 | + SOURCE | ||
|
|
34 | + ).should == nil | ||
|
|
35 | + end | ||
|
|
36 | + | ||
|
|
37 | + end |
You need to be logged in to leave comments.
Login now