codersdojo 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/argument_parser.rb +36 -0
- data/app/codersdojo.rb +4 -618
- data/app/console_view.rb +108 -0
- data/app/controller.rb +50 -0
- data/app/filename_formatter.rb +34 -0
- data/app/progress.rb +19 -0
- data/app/runner.rb +39 -0
- data/app/scheduler.rb +15 -0
- data/app/session_id_generator.rb +17 -0
- data/app/shell_wrapper.rb +96 -0
- data/app/state_reader.rb +57 -0
- data/app/uploader.rb +49 -0
- data/app/xml_element_extractor.rb +11 -0
- data/bin/codersdojo +4 -0
- data/spec/argument_parser_spec.rb +54 -0
- data/spec/progress_spec.rb +23 -0
- data/spec/runner_spec.rb +59 -0
- data/spec/session_id_generator_spec.rb +21 -0
- data/spec/state_reader_spec.rb +27 -0
- data/spec/uploader_spec.rb +78 -0
- data/spec/xml_element_extractor_spec.rb +12 -0
- data/templates/any/README +10 -0
- data/templates/any/run-endless.sh +2 -0
- data/templates/any/run-once.sh +1 -0
- data/templates/clojure.is-test/README +12 -0
- data/templates/clojure.is-test/lib/clojure-contrib.jar +0 -0
- data/templates/clojure.is-test/run-endless.sh +1 -0
- data/templates/clojure.is-test/run-once.sh +2 -0
- data/templates/java.junit/README +20 -0
- data/templates/java.junit/run-endless.sh +1 -0
- data/templates/java.junit/run-once.sh +3 -0
- data/templates/javascript.jspec/README +8 -0
- data/templates/python.unittest/README +8 -0
- data/templates/ruby.test-unit/README +5 -0
- metadata +42 -5
- data/spec/codersdojo_spec.rb +0 -265
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'state_reader'
|
2
|
+
require 'filename_formatter'
|
3
|
+
|
4
|
+
describe StateReader do
|
5
|
+
|
6
|
+
before (:each) do
|
7
|
+
@a_time = Time.new
|
8
|
+
@shell_mock = mock
|
9
|
+
@state_reader = StateReader.new @shell_mock
|
10
|
+
@state_reader.session_id = "id0815"
|
11
|
+
@state_dir_prefix = FilenameFormatter.state_dir_prefix
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should read a stored kata state" do
|
15
|
+
@shell_mock.should_receive(:ctime).with("#{@state_dir_prefix}0").and_return @a_time
|
16
|
+
Dir.should_receive(:entries).with("#{@state_dir_prefix}0").and_return(['.','..','file.rb', 'result.txt'])
|
17
|
+
@shell_mock.should_receive(:read_file).with("#{@state_dir_prefix}0/file.rb").and_return "source code"
|
18
|
+
@shell_mock.should_receive(:read_file).with("#{@state_dir_prefix}0/result.txt").and_return "result"
|
19
|
+
state = @state_reader.read_next_state
|
20
|
+
state.time.should == @a_time
|
21
|
+
state.code.should == "source code"
|
22
|
+
state.result.should == "result"
|
23
|
+
@state_reader.next_step.should == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'uploader'
|
2
|
+
|
3
|
+
describe Uploader do
|
4
|
+
|
5
|
+
before (:each) do
|
6
|
+
@state_reader_mock = mock StateReader
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should convert session-dir to session-id" do
|
10
|
+
@state_reader_mock.should_receive(:session_id=).with("session_id")
|
11
|
+
Uploader.new "http://dummy_host", "dummy.framework", ".codersdojo/session_id", @state_reader_mock
|
12
|
+
end
|
13
|
+
|
14
|
+
context'upload' do
|
15
|
+
|
16
|
+
before (:each) do
|
17
|
+
@state_reader_mock = mock StateReader
|
18
|
+
@state_reader_mock.should_receive(:session_id=).with("path_to_kata")
|
19
|
+
@uploader = Uploader.new "http://dummy_host", "dummy.framework", "path_to_kata", @state_reader_mock
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should upload a kata through a rest-interface" do
|
23
|
+
RestClient.should_receive(:post).with('http://dummy_host/katas', {:framework => "dummy.framework"}).and_return '<id>222</id>'
|
24
|
+
@uploader.upload_kata
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should upload kata and states" do
|
28
|
+
@uploader.stub(:upload_kata).and_return 'kata_xml'
|
29
|
+
XMLElementExtractor.should_receive(:extract).with('kata/id', 'kata_xml').and_return 'kata_id'
|
30
|
+
@uploader.stub(:upload_states).with 'kata_id'
|
31
|
+
XMLElementExtractor.should_receive(:extract).with('kata/short-url', 'kata_xml').and_return 'short_url'
|
32
|
+
@uploader.upload_kata_and_states
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should upload if enugh states are there' do
|
36
|
+
@state_reader_mock.should_receive(:enough_states?).and_return 'true'
|
37
|
+
@uploader.stub!(:upload_kata_and_states).and_return 'kata_link'
|
38
|
+
@uploader.upload
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return a helptext if not enught states are there' do
|
42
|
+
@state_reader_mock.should_receive(:enough_states?).and_return nil
|
43
|
+
help_text = @uploader.upload
|
44
|
+
help_text.should == 'You need at least two states'
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'states' do
|
48
|
+
it "should read all states and starts/ends progress" do
|
49
|
+
@state_reader_mock.should_receive(:state_count).and_return(1)
|
50
|
+
Progress.should_receive(:write_empty_progress).with(1)
|
51
|
+
|
52
|
+
@state_reader_mock.should_receive(:has_next_state).and_return 'true'
|
53
|
+
@uploader.should_receive(:upload_state)
|
54
|
+
@state_reader_mock.should_receive(:has_next_state).and_return nil
|
55
|
+
|
56
|
+
Progress.should_receive(:end)
|
57
|
+
|
58
|
+
@uploader.upload_states "kata_id"
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
it "through a rest interface and log process" do
|
63
|
+
state = mock State
|
64
|
+
@state_reader_mock.should_receive(:read_next_state).and_return state
|
65
|
+
state.should_receive(:code).and_return 'code'
|
66
|
+
state.should_receive(:time).and_return 'time'
|
67
|
+
state.should_receive(:result).and_return 'result'
|
68
|
+
RestClient.should_receive(:post).with('http://dummy_host/katas/kata_id/states', {:code=> 'code', :result => 'result', :created_at => 'time'})
|
69
|
+
Progress.should_receive(:next)
|
70
|
+
@uploader.upload_state "kata_id"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "xml_element_extractor"
|
2
|
+
|
3
|
+
describe XMLElementExtractor do
|
4
|
+
|
5
|
+
it "should extract first element from a xml string" do
|
6
|
+
xmlString = "<?xml version='1.0' encoding='UTF-8'?>\n<kata>\n <created-at type='datetime'>2010-07-16T16:02:00+02:00</created-at>\n <end-date type='datetime' nil='true'/>\n <id type='integer'>60</id>\n <short-url nil='true'/>\n <updated-at type='datetime'>2010-07-16T16:02:00+02:00</updated-at>\n <uuid>2a5a83dc71b8ad6565bd99f15d01e41ec1a8f3f2</uuid>\n</kata>\n"
|
7
|
+
element = XMLElementExtractor.extract 'kata/id', xmlString
|
8
|
+
element.should == "60"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
You have to create two shell scripts manually:
|
2
|
+
Create a shell script run-once.%sh% that runs the tests of your kata once.
|
3
|
+
|
4
|
+
Create a second shell script run-endless.sh with this content:
|
5
|
+
#{$0} start run-once.%sh% #{kata_file}.<extension>
|
6
|
+
|
7
|
+
Run run-endless.%sh% and start your kata.
|
8
|
+
|
9
|
+
Assumptions:
|
10
|
+
- The whole kata source code is in the one #{kata_file}.<extension>.
|
@@ -0,0 +1 @@
|
|
1
|
+
echo "Modify shell script run-once.sh so that it runs your tests once."
|
@@ -0,0 +1,12 @@
|
|
1
|
+
You have to create two shell scripts manually:
|
2
|
+
Create a shell script run-once.%sh% with this content:
|
3
|
+
java -cp clojure-contrib.jar%:%clojure.jar clojure.main #{kata_file}.clj
|
4
|
+
|
5
|
+
Create a second shell script run-endless.sh with this content:
|
6
|
+
#{$0} start run-once.%sh% #{kata_file}.clj
|
7
|
+
|
8
|
+
Run run-endless.%sh% and start your kata.
|
9
|
+
|
10
|
+
Assumptions:
|
11
|
+
- Java is installed on your system and 'java' is in the path.
|
12
|
+
- clojure.jar and clojure-contrib.jar are placed in your work directory.
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
codersdojo start run-once.sh prime.clj
|
@@ -0,0 +1,20 @@
|
|
1
|
+
You have to create two shell scripts manually:
|
2
|
+
Create a shell script run-once.%sh% with this content:
|
3
|
+
%rm% bin/#{kata_file}.class
|
4
|
+
javac -cp lib/junit.jar -d bin #{kata_file}.java
|
5
|
+
java -cp lib/junit.jar%:%bin #{kata_file}
|
6
|
+
|
7
|
+
Create a second shell script run-endless.sh with this content:
|
8
|
+
#{$0} start run-once.%sh% src/#{kata_file}.java
|
9
|
+
|
10
|
+
Run run-endless.%sh% and start your kata.
|
11
|
+
|
12
|
+
Assumptions:
|
13
|
+
- A Java JDK is installed on your system and 'java' and 'javac' are in the path.
|
14
|
+
- junit.jar is placed in a directory named 'lib'.
|
15
|
+
- The kata source file is placed in the 'src' directory.
|
16
|
+
- The kata class file is generated into the 'class' directory.
|
17
|
+
- In the source file the classes are placed in the default package.
|
18
|
+
- The kata source file has a main method that starts the tests.
|
19
|
+
- If your IDE (like Eclipse) compiles the source file, you should remove the first two lines
|
20
|
+
in the run-once.%sh% file.
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby ../../app/personal_codersdojo.rb start run-once.sh src/PrimeTest.java
|
@@ -0,0 +1,8 @@
|
|
1
|
+
You have to create two shell scripts manually:
|
2
|
+
Create a shell script run-once.%sh% with this content:
|
3
|
+
jspec --rhino run
|
4
|
+
|
5
|
+
Create a second shell script run-endless.sh with this content:
|
6
|
+
#{$0} start run-once.%sh% #{kata_file}.js
|
7
|
+
|
8
|
+
Run run-endless.%sh% and start your kata.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
You have to create two shell scripts manually:
|
2
|
+
Create a shell script run-once.%sh% with this content:
|
3
|
+
python #{kata_file}.py
|
4
|
+
|
5
|
+
Create a second shell script run-endless.sh with this content:
|
6
|
+
#{$0} start run-once.%sh% #{kata_file}.py
|
7
|
+
|
8
|
+
Run run-endless.%sh% and start your kata.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codersdojo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 8
|
10
|
+
version: 0.9.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- CodersDojo-Team
|
@@ -41,8 +41,39 @@ extensions: []
|
|
41
41
|
extra_rdoc_files: []
|
42
42
|
|
43
43
|
files:
|
44
|
+
- app/argument_parser.rb
|
44
45
|
- app/codersdojo.rb
|
45
|
-
-
|
46
|
+
- app/console_view.rb
|
47
|
+
- app/controller.rb
|
48
|
+
- app/filename_formatter.rb
|
49
|
+
- app/progress.rb
|
50
|
+
- app/runner.rb
|
51
|
+
- app/scheduler.rb
|
52
|
+
- app/session_id_generator.rb
|
53
|
+
- app/shell_wrapper.rb
|
54
|
+
- app/state_reader.rb
|
55
|
+
- app/uploader.rb
|
56
|
+
- app/xml_element_extractor.rb
|
57
|
+
- templates/any/README
|
58
|
+
- templates/any/run-endless.sh
|
59
|
+
- templates/any/run-once.sh
|
60
|
+
- templates/clojure.is-test/lib/clojure-contrib.jar
|
61
|
+
- templates/clojure.is-test/README
|
62
|
+
- templates/clojure.is-test/run-endless.sh
|
63
|
+
- templates/clojure.is-test/run-once.sh
|
64
|
+
- templates/java.junit/README
|
65
|
+
- templates/java.junit/run-endless.sh
|
66
|
+
- templates/java.junit/run-once.sh
|
67
|
+
- templates/javascript.jspec/README
|
68
|
+
- templates/python.unittest/README
|
69
|
+
- templates/ruby.test-unit/README
|
70
|
+
- spec/argument_parser_spec.rb
|
71
|
+
- spec/progress_spec.rb
|
72
|
+
- spec/runner_spec.rb
|
73
|
+
- spec/session_id_generator_spec.rb
|
74
|
+
- spec/state_reader_spec.rb
|
75
|
+
- spec/uploader_spec.rb
|
76
|
+
- spec/xml_element_extractor_spec.rb
|
46
77
|
- bin/codersdojo
|
47
78
|
has_rdoc: true
|
48
79
|
homepage: http://www.codersdojo.org/
|
@@ -79,4 +110,10 @@ signing_key:
|
|
79
110
|
specification_version: 3
|
80
111
|
summary: Client for CodersDojo.org
|
81
112
|
test_files:
|
82
|
-
- spec/
|
113
|
+
- spec/argument_parser_spec.rb
|
114
|
+
- spec/progress_spec.rb
|
115
|
+
- spec/runner_spec.rb
|
116
|
+
- spec/session_id_generator_spec.rb
|
117
|
+
- spec/state_reader_spec.rb
|
118
|
+
- spec/uploader_spec.rb
|
119
|
+
- spec/xml_element_extractor_spec.rb
|
data/spec/codersdojo_spec.rb
DELETED
@@ -1,265 +0,0 @@
|
|
1
|
-
ARGV[0] = "spec" # to be first line to suppress help text output of shell command
|
2
|
-
require "app/codersdojo"
|
3
|
-
require "restclient"
|
4
|
-
require "spec"
|
5
|
-
|
6
|
-
|
7
|
-
describe Runner, "in run mode" do
|
8
|
-
|
9
|
-
WORKSPACE_DIR = ".codersdojo"
|
10
|
-
SESSION_ID = "id0815"
|
11
|
-
SESSION_DIR = "#{WORKSPACE_DIR}/#{SESSION_ID}"
|
12
|
-
STATE_DIR_PREFIX = "#{SESSION_DIR}/state_"
|
13
|
-
|
14
|
-
before (:each) do
|
15
|
-
@shell_mock = mock.as_null_object
|
16
|
-
@session_id_provider_mock = mock.as_null_object
|
17
|
-
@session_id_provider_mock.should_receive(:generate_id).and_return SESSION_ID
|
18
|
-
@runner = Runner.new @shell_mock, @session_id_provider_mock
|
19
|
-
@runner.file = "my_file.rb"
|
20
|
-
@runner.run_command = "ruby"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should create codersdojo directory if it doesn't exist with session sub-directory" do
|
24
|
-
@shell_mock.should_receive(:mkdir_p).with SESSION_DIR
|
25
|
-
@runner.start
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should run ruby command on kata file given as argument" do
|
29
|
-
@shell_mock.should_receive(:execute).with "ruby my_file.rb"
|
30
|
-
@runner.start
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should create a state directory for every state" do
|
34
|
-
@shell_mock.should_receive(:ctime).with("my_file.rb").and_return 1
|
35
|
-
@shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}0"
|
36
|
-
@shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}0"
|
37
|
-
@runner.start
|
38
|
-
@shell_mock.should_receive(:ctime).with("my_file.rb").and_return 2
|
39
|
-
@shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}1"
|
40
|
-
@shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}1"
|
41
|
-
@runner.execute
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should not run if the kata file wasn't modified" do
|
45
|
-
a_time = Time.new
|
46
|
-
@shell_mock.should_receive(:ctime).with("my_file.rb").and_return a_time
|
47
|
-
@shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}0"
|
48
|
-
@shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}0"
|
49
|
-
@runner.start
|
50
|
-
@shell_mock.should_receive(:ctime).with("my_file.rb").and_return a_time
|
51
|
-
@shell_mock.should_not_receive(:mkdir).with "#{STATE_DIR_PREFIX}1"
|
52
|
-
@shell_mock.should_not_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}1"
|
53
|
-
@runner.execute
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should capture run result into state directory" do
|
57
|
-
@shell_mock.should_receive(:execute).and_return "spec result"
|
58
|
-
@shell_mock.should_receive(:write_file).with "#{STATE_DIR_PREFIX}0/result.txt", "spec result"
|
59
|
-
@runner.start
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
describe SessionIdGenerator do
|
66
|
-
|
67
|
-
before (:each) do
|
68
|
-
@time_mock = mock
|
69
|
-
@generator = SessionIdGenerator.new
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should format id as yyyy-mm-dd_hh-mm-ss" do
|
73
|
-
@time_mock.should_receive(:year).and_return 2010
|
74
|
-
@time_mock.should_receive(:month).and_return 8
|
75
|
-
@time_mock.should_receive(:day).and_return 7
|
76
|
-
@time_mock.should_receive(:hour).and_return 6
|
77
|
-
@time_mock.should_receive(:min).and_return 5
|
78
|
-
@time_mock.should_receive(:sec).and_return 0
|
79
|
-
@generator.generate_id(@time_mock).should == "2010-08-07_06-05-00"
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
describe StateReader do
|
85
|
-
|
86
|
-
before (:each) do
|
87
|
-
@a_time = Time.new
|
88
|
-
@shell_mock = mock
|
89
|
-
@state_reader = StateReader.new @shell_mock
|
90
|
-
@state_reader.session_id = "id0815"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should read a stored kata state" do
|
94
|
-
@shell_mock.should_receive(:ctime).with("#{STATE_DIR_PREFIX}0").and_return @a_time
|
95
|
-
Dir.should_receive(:entries).with("#{STATE_DIR_PREFIX}0").and_return(['.','..','file.rb', 'result.txt'])
|
96
|
-
@shell_mock.should_receive(:read_file).with("#{STATE_DIR_PREFIX}0/file.rb").and_return "source code"
|
97
|
-
@shell_mock.should_receive(:read_file).with("#{STATE_DIR_PREFIX}0/result.txt").and_return "result"
|
98
|
-
state = @state_reader.read_next_state
|
99
|
-
state.time.should == @a_time
|
100
|
-
state.code.should == "source code"
|
101
|
-
state.result.should == "result"
|
102
|
-
@state_reader.next_step.should == 1
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
describe Uploader do
|
108
|
-
|
109
|
-
before (:each) do
|
110
|
-
@state_reader_mock = mock StateReader
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should convert session-dir to session-id" do
|
114
|
-
@state_reader_mock.should_receive(:session_id=).with("session_id")
|
115
|
-
Uploader.new "http://dummy_host", "dummy.framework", ".codersdojo/session_id", @state_reader_mock
|
116
|
-
end
|
117
|
-
|
118
|
-
context'upload' do
|
119
|
-
|
120
|
-
before (:each) do
|
121
|
-
@state_reader_mock = mock StateReader
|
122
|
-
@state_reader_mock.should_receive(:session_id=).with("path_to_kata")
|
123
|
-
@uploader = Uploader.new "http://dummy_host", "dummy.framework", "path_to_kata", @state_reader_mock
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should upload a kata through a rest-interface" do
|
127
|
-
RestClient.should_receive(:post).with('http://dummy_host/katas', {:framework => "dummy.framework"}).and_return '<id>222</id>'
|
128
|
-
@uploader.upload_kata
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should upload kata and states" do
|
132
|
-
@uploader.stub(:upload_kata).and_return 'kata_xml'
|
133
|
-
XMLElementExtractor.should_receive(:extract).with('kata/id', 'kata_xml').and_return 'kata_id'
|
134
|
-
@uploader.stub(:upload_states).with 'kata_id'
|
135
|
-
XMLElementExtractor.should_receive(:extract).with('kata/short-url', 'kata_xml').and_return 'short_url'
|
136
|
-
@uploader.upload_kata_and_states
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should upload if enugh states are there' do
|
140
|
-
@state_reader_mock.should_receive(:enough_states?).and_return 'true'
|
141
|
-
@uploader.stub!(:upload_kata_and_states).and_return 'kata_link'
|
142
|
-
@uploader.upload
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'should return a helptext if not enught states are there' do
|
146
|
-
@state_reader_mock.should_receive(:enough_states?).and_return nil
|
147
|
-
help_text = @uploader.upload
|
148
|
-
help_text.should == 'You need at least two states'
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'states' do
|
152
|
-
it "should read all states and starts/ends progress" do
|
153
|
-
@state_reader_mock.should_receive(:state_count).and_return(1)
|
154
|
-
Progress.should_receive(:write_empty_progress).with(1)
|
155
|
-
|
156
|
-
@state_reader_mock.should_receive(:has_next_state).and_return 'true'
|
157
|
-
@uploader.should_receive(:upload_state)
|
158
|
-
@state_reader_mock.should_receive(:has_next_state).and_return nil
|
159
|
-
|
160
|
-
Progress.should_receive(:end)
|
161
|
-
|
162
|
-
@uploader.upload_states "kata_id"
|
163
|
-
end
|
164
|
-
|
165
|
-
|
166
|
-
it "through a rest interface and log process" do
|
167
|
-
state = mock State
|
168
|
-
@state_reader_mock.should_receive(:read_next_state).and_return state
|
169
|
-
state.should_receive(:code).and_return 'code'
|
170
|
-
state.should_receive(:time).and_return 'time'
|
171
|
-
state.should_receive(:result).and_return 'result'
|
172
|
-
RestClient.should_receive(:post).with('http://dummy_host/katas/kata_id/states', {:code=> 'code', :result => 'result', :created_at => 'time'})
|
173
|
-
Progress.should_receive(:next)
|
174
|
-
@uploader.upload_state "kata_id"
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
182
|
-
|
183
|
-
describe XMLElementExtractor do
|
184
|
-
|
185
|
-
it "should extract first element from a xml string" do
|
186
|
-
xmlString = "<?xml version='1.0' encoding='UTF-8'?>\n<kata>\n <created-at type='datetime'>2010-07-16T16:02:00+02:00</created-at>\n <end-date type='datetime' nil='true'/>\n <id type='integer'>60</id>\n <short-url nil='true'/>\n <updated-at type='datetime'>2010-07-16T16:02:00+02:00</updated-at>\n <uuid>2a5a83dc71b8ad6565bd99f15d01e41ec1a8f3f2</uuid>\n</kata>\n"
|
187
|
-
element = XMLElementExtractor.extract 'kata/id', xmlString
|
188
|
-
element.should == "60"
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
describe ArgumentParser do
|
194
|
-
|
195
|
-
before (:each) do
|
196
|
-
@controller_mock = mock.as_null_object
|
197
|
-
@parser = ArgumentParser.new @controller_mock
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should reject empty command" do
|
201
|
-
lambda{@parser.parse []}.should raise_error
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should reject unknown command" do
|
205
|
-
lambda{@parser.parse "unknown command"}.should raise_error
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should accept help command" do
|
209
|
-
@controller_mock.should_receive(:help).with(nil)
|
210
|
-
@parser.parse ["help"]
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should accept start command" do
|
214
|
-
@controller_mock.should_receive(:start).with "aCommand", "aFile"
|
215
|
-
@parser.parse ["start", "aCommand","aFile"]
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should prepend *.sh start scripts with 'bash'" do
|
219
|
-
@controller_mock.should_receive(:start).with "bash aCommand.sh", "aFile"
|
220
|
-
@parser.parse ["start", "aCommand.sh","aFile"]
|
221
|
-
end
|
222
|
-
|
223
|
-
it "should prepend *.bat start scripts with 'start'" do
|
224
|
-
@controller_mock.should_receive(:start).with "start aCommand.bat", "aFile"
|
225
|
-
@parser.parse ["start", "aCommand.bat","aFile"]
|
226
|
-
end
|
227
|
-
|
228
|
-
it "should prepend *.cmd start scripts with 'start'" do
|
229
|
-
@controller_mock.should_receive(:start).with "start aCommand.cmd", "aFile"
|
230
|
-
@parser.parse ["start", "aCommand.cmd","aFile"]
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should accept upload command" do
|
234
|
-
@controller_mock.should_receive(:upload).with "framework", "dir"
|
235
|
-
@parser.parse ["upload", "framework", "dir"]
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should accept uppercase commands" do
|
239
|
-
@controller_mock.should_receive(:help).with(nil)
|
240
|
-
@parser.parse ["HELP"]
|
241
|
-
end
|
242
|
-
|
243
|
-
end
|
244
|
-
|
245
|
-
describe Progress do
|
246
|
-
|
247
|
-
it 'should print infos and empty progress in initialization' do
|
248
|
-
STDOUT.should_receive(:print).with("2 states to upload")
|
249
|
-
STDOUT.should_receive(:print).with("[ ]")
|
250
|
-
STDOUT.should_receive(:print).with("\b\b\b")
|
251
|
-
Progress.write_empty_progress 2
|
252
|
-
end
|
253
|
-
|
254
|
-
it 'should print dots and flush in next' do
|
255
|
-
STDOUT.should_receive(:print).with(".")
|
256
|
-
STDOUT.should_receive(:flush)
|
257
|
-
Progress.next
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'should print empty line in end' do
|
261
|
-
STDOUT.should_receive(:puts)
|
262
|
-
Progress.end
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|