codersdojo 1.1.03 → 1.1.04

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.
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: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 3
10
- version: 1.1.03
9
+ - 4
10
+ version: 1.1.04
11
11
  platform: ruby
12
12
  authors:
13
13
  - CodersDojo-Team
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 13
30
30
  segments:
31
- - 0
32
- version: "0"
31
+ - 1
32
+ - 6
33
+ - 1
34
+ version: 1.6.1
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  description: Client executes tests in an endless loop and logs source code and test result.
@@ -90,18 +92,6 @@ files:
90
92
  - templates/ruby.test-unit/run-endless.%sh%
91
93
  - templates/ruby.test-unit/run-once.%sh%
92
94
  - lib/place_libs_here
93
- - spec/argument_parser_spec.rb
94
- - spec/filename_formatter_spec.rb
95
- - spec/progress_spec.rb
96
- - spec/runner_spec.rb
97
- - spec/scaffolder_spec.rb
98
- - spec/scheduler_spec.rb
99
- - spec/session_id_generator_spec.rb
100
- - spec/state_reader_spec.rb
101
- - spec/text_converter_spec.rb
102
- - spec/text_template_machine_spec.rb
103
- - spec/uploader_spec.rb
104
- - spec/xml_element_extractor_spec.rb
105
95
  - bin/codersdojo
106
96
  has_rdoc: true
107
97
  homepage: http://www.codersdojo.org/
@@ -139,16 +129,5 @@ rubygems_version: 1.3.7
139
129
  signing_key:
140
130
  specification_version: 3
141
131
  summary: Client for CodersDojo.org
142
- test_files:
143
- - spec/argument_parser_spec.rb
144
- - spec/filename_formatter_spec.rb
145
- - spec/progress_spec.rb
146
- - spec/runner_spec.rb
147
- - spec/scaffolder_spec.rb
148
- - spec/scheduler_spec.rb
149
- - spec/session_id_generator_spec.rb
150
- - spec/state_reader_spec.rb
151
- - spec/text_converter_spec.rb
152
- - spec/text_template_machine_spec.rb
153
- - spec/uploader_spec.rb
154
- - spec/xml_element_extractor_spec.rb
132
+ test_files: []
133
+
@@ -1,54 +0,0 @@
1
- require 'argument_parser'
2
-
3
- describe ArgumentParser do
4
-
5
- before (:each) do
6
- @controller_mock = mock.as_null_object
7
- @parser = ArgumentParser.new @controller_mock
8
- end
9
-
10
- it "should reject empty command" do
11
- lambda{@parser.parse []}.should raise_error
12
- end
13
-
14
- it "should reject unknown command" do
15
- lambda{@parser.parse "unknown command"}.should raise_error
16
- end
17
-
18
- it "should accept help command" do
19
- @controller_mock.should_receive(:help).with(nil)
20
- @parser.parse ["help"]
21
- end
22
-
23
- it "should accept start command" do
24
- @controller_mock.should_receive(:start).with "aCommand", "aFile"
25
- @parser.parse ["start", "aCommand","aFile"]
26
- end
27
-
28
- it "should prepend *.sh start scripts with 'bash'" do
29
- @controller_mock.should_receive(:start).with "bash aCommand.sh", "aFile"
30
- @parser.parse ["start", "aCommand.sh","aFile"]
31
- end
32
-
33
- it "should not prepend *.bat start scripts with anything" do
34
- @controller_mock.should_receive(:start).with "aCommand.bat", "aFile"
35
- @parser.parse ["start", "aCommand.bat","aFile"]
36
- end
37
-
38
- it "should not prepend *.cmd start scripts with anything" do
39
- @controller_mock.should_receive(:start).with "aCommand.cmd", "aFile"
40
- @parser.parse ["start", "aCommand.cmd","aFile"]
41
- end
42
-
43
- it "should accept upload command" do
44
- @controller_mock.should_receive(:upload).with "framework", "dir"
45
- @parser.parse ["upload", "framework", "dir"]
46
- end
47
-
48
- it "should accept uppercase commands" do
49
- @controller_mock.should_receive(:help).with(nil)
50
- @parser.parse ["HELP"]
51
- end
52
-
53
- end
54
-
@@ -1,17 +0,0 @@
1
- require 'filename_formatter'
2
-
3
- describe FilenameFormatter do
4
-
5
- before (:each) do
6
- @formatter = FilenameFormatter.new
7
- end
8
-
9
- it 'extract the last element of a dir path' do
10
- @formatter.extract_last_path_item("").should == ""
11
- @formatter.extract_last_path_item("/").should == ""
12
- @formatter.extract_last_path_item("a").should == "a"
13
- @formatter.extract_last_path_item("a/b/").should == "b"
14
- @formatter.extract_last_path_item("/a/b/c").should == "c"
15
- end
16
-
17
- end
@@ -1,23 +0,0 @@
1
- require 'progress'
2
-
3
- describe Progress do
4
-
5
- it 'should print infos and empty progress in initialization' do
6
- STDOUT.should_receive(:print).with("2 states to upload")
7
- STDOUT.should_receive(:print).with("[ ]")
8
- STDOUT.should_receive(:print).with("\b\b\b")
9
- Progress.write_empty_progress 2
10
- end
11
-
12
- it 'should print dots and flush in next' do
13
- STDOUT.should_receive(:print).with(".")
14
- STDOUT.should_receive(:flush)
15
- Progress.next
16
- end
17
-
18
- it 'should print empty line in end' do
19
- STDOUT.should_receive(:puts)
20
- Progress.end
21
- end
22
-
23
- end
data/spec/runner_spec.rb DELETED
@@ -1,65 +0,0 @@
1
- require 'runner'
2
-
3
- describe Runner, "in run mode" do
4
-
5
- WORKSPACE_DIR = ".codersdojo"
6
- SESSION_ID = "id0815"
7
- SESSION_DIR = "#{WORKSPACE_DIR}/#{SESSION_ID}"
8
- STATE_DIR_PREFIX = "#{SESSION_DIR}/state_"
9
-
10
- before (:each) do
11
- @shell_mock = mock.as_null_object
12
- @session_id_provider_mock = mock.as_null_object
13
- @session_id_provider_mock.should_receive(:generate_id).and_return SESSION_ID
14
- @runner = Runner.new @shell_mock, @session_id_provider_mock
15
- @runner.file = "my_file.rb"
16
- @runner.run_command = "run-once.sh"
17
- end
18
-
19
- it "should create codersdojo directory if it doesn't exist with session sub-directory" do
20
- @shell_mock.should_receive(:mkdir_p).with SESSION_DIR
21
- @runner.start
22
- end
23
-
24
- it "should run ruby command on kata file given as argument" do
25
- @shell_mock.should_receive(:execute).with "run-once.sh"
26
- @runner.start
27
- end
28
-
29
- it "should create a state directory for every state" do
30
- @shell_mock.should_receive(:modification_time).with("my_file.rb").and_return 1
31
- @shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}0"
32
- @shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}0"
33
- @runner.start
34
- @shell_mock.should_receive(:modification_time).with("my_file.rb").and_return 2
35
- @shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}1"
36
- @shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}1"
37
- @runner.execute
38
- end
39
-
40
- it "should not run if the kata file wasn't modified" do
41
- a_time = Time.new
42
- @shell_mock.should_receive(:modification_time).with("my_file.rb").and_return a_time
43
- @shell_mock.should_receive(:mkdir).with "#{STATE_DIR_PREFIX}0"
44
- @shell_mock.should_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}0"
45
- @runner.start
46
- @shell_mock.should_receive(:modification_time).with("my_file.rb").and_return a_time
47
- @shell_mock.should_not_receive(:mkdir).with "#{STATE_DIR_PREFIX}1"
48
- @shell_mock.should_not_receive(:cp).with "my_file.rb", "#{STATE_DIR_PREFIX}1"
49
- @runner.execute
50
- end
51
-
52
- it "should capture run result into state directory" do
53
- @shell_mock.should_receive(:execute).and_return "spec result"
54
- @shell_mock.should_receive(:write_file).with "#{STATE_DIR_PREFIX}0/result.txt", "spec result"
55
- @runner.start
56
- end
57
-
58
- it "should remove escape sequences" do
59
- @shell_mock.should_receive(:execute).and_return "#{TextConverter.ESCAPE_SEQUENCE_START}b#{TextConverter.ESCAPE_SEQUENCE_END}c"
60
- @shell_mock.should_receive(:write_file).with "#{STATE_DIR_PREFIX}0/result.txt", "c"
61
- @runner.start
62
- end
63
-
64
- end
65
-
@@ -1,53 +0,0 @@
1
- require "scaffolder"
2
-
3
- describe Scaffolder do
4
-
5
- before (:each) do
6
- @shell_mock = mock
7
- @shell_mock.should_receive(:shell_extension).any_number_of_times.and_return "cmd"
8
- @shell_mock.should_receive(:remove_command_name).any_number_of_times.and_return "del"
9
- @shell_mock.should_receive(:path_separator).any_number_of_times.and_return ";"
10
- @shell_mock.should_receive(:current_file).any_number_of_times.and_return("aDir/app/aFile.rb")
11
- @scaffolder = Scaffolder.new @shell_mock
12
- end
13
-
14
- it "should compute template path from location of ruby source file" do
15
- @scaffolder.template_path.should == "aDir/templates"
16
- end
17
-
18
- it "should retrieve templates from directories within the template directory" do
19
- @shell_mock.should_receive(:real_dir_entries).with("aDir/templates").and_return ['any', 't1', 't2', 't3']
20
- @scaffolder.list_templates.should == 't1, t2, t3'
21
- end
22
-
23
- it "should scaffold the files and directories for a given template" do
24
- @shell_mock.should_receive(:real_dir_entries).with("aDir/templates/a.template").and_return ["a", "b"]
25
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/a", "."
26
- @shell_mock.should_receive(:file?).with("a").and_return false
27
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/b", "."
28
- @shell_mock.should_receive(:file?).with("b").and_return false
29
- @scaffolder.scaffold "a.template", 'myKata'
30
- end
31
-
32
- it "should replace placeholder in template file README and shell scripts" do
33
- @shell_mock.should_receive(:real_dir_entries).with("aDir/templates/a.template").
34
- and_return ["a", "README", "run-once.sh", "run-endless.sh"]
35
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/a", "."
36
- @shell_mock.should_receive(:file?).with("a").and_return false
37
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/README", "."
38
- @shell_mock.should_receive(:file?).with("README").and_return true
39
- @shell_mock.should_receive(:read_file).with("README").and_return '%rm% %kata_file%\nb.%sh%\nc%:%d'
40
- @shell_mock.should_receive(:write_file).with "README", 'del myKata\nb.cmd\nc;d'
41
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/run-once.sh", "."
42
- @shell_mock.should_receive(:file?).with("run-once.sh").and_return true
43
- @shell_mock.should_receive(:read_file).with("run-once.sh").and_return "%rm% a\nb.%sh%\nc%:%d"
44
- @shell_mock.should_receive(:write_file).with "run-once.sh", "del a\nb.cmd\nc;d"
45
- @shell_mock.should_receive(:cp_r).with "aDir/templates/a.template/run-endless.sh", "."
46
- @shell_mock.should_receive(:file?).with("run-endless.sh").and_return true
47
- @shell_mock.should_receive(:read_file).with("run-endless.sh").and_return "%rm% a\nb.%sh%\nc%:%d"
48
- @shell_mock.should_receive(:write_file).with "run-endless.sh", "del a\nb.cmd\nc;d"
49
- @scaffolder.scaffold "a.template", 'myKata'
50
- end
51
-
52
- end
53
-
@@ -1,14 +0,0 @@
1
- require 'scheduler'
2
-
3
- describe Scheduler do
4
-
5
- it "should exit on Ctrl-C" do
6
- scheduler = Scheduler.new mock.as_null_object
7
- scheduler.should_receive(:exit)
8
-
9
- Thread.new { scheduler.start }
10
- Process.kill "INT", 0
11
- end
12
-
13
- end
14
-
@@ -1,21 +0,0 @@
1
- require 'session_id_generator'
2
-
3
- describe SessionIdGenerator do
4
-
5
- before (:each) do
6
- @time_mock = mock
7
- @generator = SessionIdGenerator.new
8
- end
9
-
10
- it "should format id as yyyy-mm-dd_hh-mm-ss" do
11
- @time_mock.should_receive(:year).and_return 2010
12
- @time_mock.should_receive(:month).and_return 8
13
- @time_mock.should_receive(:day).and_return 7
14
- @time_mock.should_receive(:hour).and_return 6
15
- @time_mock.should_receive(:min).and_return 5
16
- @time_mock.should_receive(:sec).and_return 0
17
- @generator.generate_id(@time_mock).should == "2010-08-07_06-05-00"
18
- end
19
-
20
- end
21
-
@@ -1,27 +0,0 @@
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(:creation_time).with(".codersdojo/id0815/#{@state_dir_prefix}0").and_return @a_time
16
- Dir.should_receive(:entries).with(".codersdojo/id0815/#{@state_dir_prefix}0").and_return(['.','..','file.rb', 'result.txt'])
17
- @shell_mock.should_receive(:read_file).with(".codersdojo/id0815/#{@state_dir_prefix}0/result.txt").and_return "result"
18
- @shell_mock.should_receive(:read_file).with(".codersdojo/id0815/#{@state_dir_prefix}0/file.rb").and_return "source code"
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
-
@@ -1,30 +0,0 @@
1
- require 'text_converter'
2
-
3
- describe TextConverter do
4
-
5
- before (:each) do
6
- @escape_sequence_start = 0x1b.chr
7
- @escape_sequence_end = 0x6d.chr
8
- @text_converter = TextConverter.new
9
- end
10
-
11
- it "should leave nil as nil" do
12
- @text_converter.remove_escape_sequences(nil).should be_nil
13
-
14
- end
15
-
16
- it "should leave text without escape sequences untouched" do
17
- @text_converter.remove_escape_sequences("text without escape sequence").should == "text without escape sequence"
18
- end
19
-
20
- it "should remove escape sequences from text" do
21
- @text_converter.remove_escape_sequences("#{@escape_sequence_start}ab#{@escape_sequence_end}").should == ""
22
- @text_converter.remove_escape_sequences("a#{@escape_sequence_start}b#{@escape_sequence_end}c").should == "ac"
23
- @text_converter.remove_escape_sequences("ab#{@escape_sequence_start}#{@escape_sequence_end}cd").should == "abcd"
24
- end
25
-
26
- it "should remove escape sequences non greedy" do
27
- @text_converter.remove_escape_sequences("#{@escape_sequence_start}a#{@escape_sequence_end}b#{@escape_sequence_start}c#{@escape_sequence_end}").should == "b"
28
- end
29
-
30
- end
@@ -1,40 +0,0 @@
1
- require 'text_template_machine'
2
-
3
- describe TextTemplateMachine do
4
-
5
- before (:each) do
6
- shell_mock = mock
7
- @machine = TextTemplateMachine.new shell_mock
8
- @placeholder_values = {'a' => 'A', 'wo' => 'world', 'm' => 'my'}
9
- @machine.placeholder_values = @placeholder_values
10
- end
11
-
12
- it "should not modifiy text without placeholders" do
13
- @machine.render('Some text without placeholders.').should == 'Some text without placeholders.'
14
- end
15
-
16
- it "should not modifiy unknown placeholders" do
17
- @machine.render('Hello %unknown%').should == 'Hello %unknown%'
18
- end
19
-
20
- it "should resolve placeholders" do
21
- @machine.render('Hello %wo%, %m% %wo%').should == 'Hello world, my world'
22
- end
23
-
24
- it "should not modify case of first letter" do
25
- @machine.render('Hello %wo%').should == 'Hello world'
26
- @machine.render('Hello %Wo%').should == 'Hello World'
27
- end
28
-
29
- it "should use added placeholder" do
30
- @machine.placeholder_values['xxx'] = 'xxx-value'
31
- @machine.render('%xxx%').should == 'xxx-value'
32
- end
33
-
34
- it "should use newest placeholder value" do
35
- @machine.placeholder_values['a'] = 'b'
36
- @machine.render('%a%').should == 'b'
37
- end
38
-
39
- end
40
-
@@ -1,79 +0,0 @@
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_dir=).with(".codersdojo/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_dir=).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/uuid', 'kata_xml').and_return 'describe_url'
32
- XMLElementExtractor.should_receive(:extract).with('kata/short-url', 'kata_xml').and_return 'short_url'
33
- @uploader.upload_kata_and_states
34
- end
35
-
36
- it 'should upload if enugh states are there' do
37
- @state_reader_mock.should_receive(:enough_states?).and_return 'true'
38
- @uploader.stub!(:upload_kata_and_states).and_return 'kata_link'
39
- @uploader.upload
40
- end
41
-
42
- it 'should return a helptext if not enught states are there' do
43
- @state_reader_mock.should_receive(:enough_states?).and_return nil
44
- help_text = @uploader.upload
45
- help_text.should == 'You need at least two states'
46
- end
47
-
48
- context 'states' do
49
- it "should read all states and starts/ends progress" do
50
- @state_reader_mock.should_receive(:state_count).and_return(1)
51
- Progress.should_receive(:write_empty_progress).with(1)
52
-
53
- @state_reader_mock.should_receive(:has_next_state).and_return 'true'
54
- @uploader.should_receive(:upload_state)
55
- @state_reader_mock.should_receive(:has_next_state).and_return nil
56
-
57
- Progress.should_receive(:end)
58
-
59
- @uploader.upload_states "kata_id"
60
- end
61
-
62
-
63
- it "through a rest interface and log process" do
64
- state = mock State
65
- @state_reader_mock.should_receive(:read_next_state).and_return state
66
- state.should_receive(:code).and_return 'code'
67
- state.should_receive(:time).and_return 'time'
68
- state.should_receive(:result).and_return 'result'
69
- RestClient.should_receive(:post).with('http://dummy_host/katas/kata_id/states', {:code=> 'code', :result => 'result', :created_at => 'time'})
70
- Progress.should_receive(:next)
71
- @uploader.upload_state "kata_id"
72
- end
73
-
74
- end
75
-
76
- end
77
-
78
- end
79
-
@@ -1,12 +0,0 @@
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
-