hw_checker 1.3.48 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/hw_checker +3 -3
- data/config/config.yml +12 -0
- data/lib/hw_checker/archive_result.rb +12 -0
- data/lib/hw_checker/base.rb +7 -7
- data/lib/hw_checker/directory_format_error.rb +3 -0
- data/lib/hw_checker/file_scan.rb +9 -8
- data/lib/hw_checker/{python_stat.rb → python_code_quality.rb} +14 -3
- data/lib/hw_checker/python_test_run.rb +1 -1
- data/lib/hw_checker/{ruby_stat.rb → ruby_code_quality.rb} +3 -2
- data/lib/hw_checker/ruby_test_run.rb +1 -1
- data/lib/hw_checker/string.rb +7 -0
- data/lib/hw_checker/zip.rb +1 -1
- data/lib/hw_checker.rb +18 -8
- data/spec/spec_helper.rb +2 -0
- metadata +9 -11
- data/lib/hw_checker/test_run_stat.rb +0 -25
- data/spec/base_spec.rb +0 -32
- data/spec/file_scan_spec.rb +0 -48
- data/spec/ruby_stat_spec.rb +0 -30
- data/spec/ruby_test_run_spec.rb +0 -27
- data/spec/test_run_stat_spec.rb +0 -14
- data/spec/zip_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzhkMzI5YTgzNjBhNDc1ZWRhMTljMjQ2NTJlMDRlMjUxZTI3NWY1ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjdhOTc1MjE5ZjBiZjkzMTRkZTUzODA4MGQ2NjQzNDljYmFkY2E1Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGIxODQ0OWE4YjYyM2IxYzU1MjIxNzE3MTViNTQ5NTllN2E4MTIyYTIzOTQ5
|
10
|
+
MjMxZmI0NTFlMDU0ZjdmNGFiOWFiNjQ5ZGE3MmMzNjAxOTJkZmU0NTM0N2My
|
11
|
+
MzA0MjZiOWQ2YjJhOWNmM2RkZDNlZjFhODExMTA0ZmZkOTZiYjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWRlN2UwNmJjM2YxMmIxZjRkMmFhYjFjYjE3N2RlOWViYTc1MjY5Nzg3N2Q4
|
14
|
+
M2RhODFjOGFkYjJmMDEwZDNhYjc1OTgxM2EzYmMwMTVjMWY2OGJiOGIwNmJl
|
15
|
+
YTg2ZWNkMjE4ZTEyZGM2NmRjYjNmYjM0NGU1NmJmYzEyODAyOWE=
|
data/bin/hw_checker
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'hw_checker'
|
4
4
|
|
5
5
|
begin
|
6
|
-
HomeWorkChecker::FileScan.new(ARGV[0],
|
7
|
-
HomeWorkChecker::Base.start(ARGV[0],
|
6
|
+
HomeWorkChecker::FileScan.new(ARGV[0], ARGV[1]).each do |name, type|
|
7
|
+
HomeWorkChecker::Base.start(ARGV[0], ARGV[1], name, type)
|
8
8
|
end
|
9
|
-
rescue HomeWorkChecker::DirectoryExistError => error
|
9
|
+
rescue HomeWorkChecker::DirectoryExistError, HomeWorkChecker::DirectoryFormatError => error
|
10
10
|
puts error.message, error.backtrace
|
11
11
|
end
|
data/config/config.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#
|
2
|
+
# List of used languages is defined here
|
3
|
+
#
|
4
|
+
languages:
|
5
|
+
rb: ruby
|
6
|
+
py: python
|
7
|
+
|
8
|
+
modules:
|
9
|
+
ruby: HomeWorkChecker::ArchiveResult::RubyTestRun HomeWorkChecker::ArchiveResult::RubyCodeQuality
|
10
|
+
python: HomeWorkChecker::ArchiveResult::PythonTestRun HomeWorkChecker::ArchiveResult::PythonCodeQuality
|
11
|
+
|
12
|
+
archives: .zip .7z
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module HomeWorkChecker
|
2
|
+
module ArchiveResult
|
3
|
+
def self.execute(tmp_path, name)
|
4
|
+
language_name = LANGUAGE_TYPES[name.split('_')[1] ]
|
5
|
+
raise DirectoryFormatError, "Directory '#{name}' does not match needed format" if language_name.nil?
|
6
|
+
stats = MODULE_TYPES[language_name].split(' ').map do |class_name|
|
7
|
+
class_name.constatize.new(tmp_path, name).perform
|
8
|
+
end
|
9
|
+
[language_name, stats.first, stats.last ]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/hw_checker/base.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module HomeWorkChecker
|
2
2
|
class Base
|
3
|
-
def self.start(
|
3
|
+
def self.start(archive_path, result_path, name, type, tmp_path = '/tmp')
|
4
4
|
`rm -r #{tmp_path}/#{name}` if Dir.exist?("#{tmp_path}/#{name}")
|
5
5
|
time_start, xml_content = Time.now, {}
|
6
|
-
Unarchive::Zip.new("#{
|
7
|
-
|
8
|
-
|
6
|
+
Unarchive::Zip.new("#{archive_path}/#{name+type}", tmp_path)
|
7
|
+
stats = ArchiveResult.execute(tmp_path, name)
|
8
|
+
stats << (Time.now - time_start).round(2)
|
9
9
|
|
10
|
-
File.open("#{
|
11
|
-
file.write(generate_xml_content(name,
|
10
|
+
File.open("#{result_path}/#{name}.xml", 'w') do |file|
|
11
|
+
file.write(generate_xml_content(name, stats) )
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,7 +16,7 @@ module HomeWorkChecker
|
|
16
16
|
def self.generate_xml_content(identity, info)
|
17
17
|
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
18
18
|
xml.root {
|
19
|
-
xml.student identity.split('_').first # name
|
19
|
+
xml.student identity.split('_').first # student name
|
20
20
|
xml.homework identity.split('_').last # homework
|
21
21
|
xml.language info[0] # language
|
22
22
|
xml.ratio info[1] # ratio of passed and failed tests
|
data/lib/hw_checker/file_scan.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module HomeWorkChecker
|
2
2
|
class FileScan
|
3
|
-
def initialize(
|
4
|
-
raise DirectoryExistError, "Directory #{
|
5
|
-
raise DirectoryExistError, "Directory #{
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
def initialize(archive_path, result_path, tmp_path = '/tmp')
|
4
|
+
raise DirectoryExistError, "Directory '#{archive_path}' does not exist" unless Dir::exist?(archive_path)
|
5
|
+
raise DirectoryExistError, "Directory '#{result_path}' does not exist" unless Dir::exist?(result_path)
|
6
|
+
raise DirectoryExistError, "Directory '#{tmp_path}' does not exist" unless Dir::exist?(tmp_path)
|
7
|
+
@archive_path, @result_path, @tmp_path, @files = archive_path, result_path, tmp_path, []
|
8
|
+
Dir.foreach(@archive_path) do |p|
|
9
|
+
if File.file?("#{archive_path}/#{p}") && ARCHIVE_TYPES.include?(File.extname p) && !exist_xml?(p)
|
9
10
|
@files << p
|
10
11
|
end
|
11
12
|
end
|
@@ -26,8 +27,8 @@ module HomeWorkChecker
|
|
26
27
|
|
27
28
|
private
|
28
29
|
def exist_xml?(archive_name)
|
29
|
-
|
30
|
-
File.exist? "#{@
|
30
|
+
name = archive_name.chomp(File.extname archive_name)
|
31
|
+
File.exist? "#{@result_path}/#{name}.xml"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module HomeWorkChecker
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module ArchiveResult
|
3
|
+
class PythonCodeQuality
|
4
4
|
def initialize(tmp_path, dirname)
|
5
5
|
@work_path = "#{tmp_path}/#{dirname}/tests/statistic"
|
6
6
|
raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
|
@@ -18,7 +18,18 @@ module HomeWorkChecker
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def calc_percent_quality(filename)
|
21
|
-
|
21
|
+
=begin
|
22
|
+
rake = ((`tail -n 75 #{filename}`).scan(/\d{1,2}\.\d{1,2}\\/).shift.to_f)
|
23
|
+
if rake > 10
|
24
|
+
(rake / 10).round(2)
|
25
|
+
else
|
26
|
+
(rake * 10).round(2)
|
27
|
+
end
|
28
|
+
=end
|
29
|
+
File.open(filename).each_line do |line|
|
30
|
+
next unless line.match(/^Your\scode\shas\sbeen\srated\sat/)
|
31
|
+
return ( line.scan(/[\d\.]+/).shift.to_f * 10 )
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module HomeWorkChecker
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module ArchiveResult
|
3
|
+
class RubyCodeQuality
|
4
4
|
def initialize(tmp_path, dirname)
|
5
5
|
@work_path = "#{tmp_path}/#{dirname}"
|
6
6
|
raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
|
@@ -17,6 +17,7 @@ module HomeWorkChecker
|
|
17
17
|
calc_percent_quality
|
18
18
|
end
|
19
19
|
|
20
|
+
private
|
20
21
|
def count_lines_failed(filename)
|
21
22
|
temp = []
|
22
23
|
File.open(filename).each_line do |line|
|
data/lib/hw_checker/zip.rb
CHANGED
data/lib/hw_checker.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
+
require 'yaml'
|
2
3
|
require 'hw_checker/directory_exist_error'
|
4
|
+
require 'hw_checker/directory_format_error'
|
5
|
+
require 'hw_checker/string'
|
3
6
|
require 'hw_checker/base'
|
4
7
|
require 'hw_checker/file_scan'
|
5
8
|
require 'hw_checker/unarchive'
|
6
9
|
require 'hw_checker/zip'
|
7
|
-
require 'hw_checker/
|
8
|
-
require 'hw_checker/
|
10
|
+
require 'hw_checker/archive_result'
|
11
|
+
require 'hw_checker/python_code_quality'
|
9
12
|
require 'hw_checker/python_test_run'
|
10
|
-
require 'hw_checker/
|
13
|
+
require 'hw_checker/ruby_code_quality'
|
11
14
|
require 'hw_checker/ruby_test_run'
|
12
15
|
|
13
16
|
|
14
17
|
module HomeWorkChecker
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
'.
|
19
|
-
|
18
|
+
def self.configurate
|
19
|
+
fname = File.expand_path('./config/config.yml')
|
20
|
+
hash_conf = YAML.load_file fname
|
21
|
+
archive_types, language_types, module_types = hash_conf['archives'].split(' '), {}, {}
|
22
|
+
hash_conf['languages'].each do |key, value|
|
23
|
+
language_types[key] = value
|
24
|
+
module_types[value] = hash_conf['modules'][value]
|
25
|
+
end
|
26
|
+
[archive_types, language_types, module_types]
|
27
|
+
end
|
28
|
+
|
29
|
+
ARCHIVE_TYPES, LANGUAGE_TYPES, MODULE_TYPES = self.configurate
|
20
30
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hw_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lv-LAMP-085
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -60,22 +60,20 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- lib/hw_checker/python_test_run.rb
|
62
62
|
- lib/hw_checker/ruby_test_run.rb
|
63
|
+
- lib/hw_checker/string.rb
|
64
|
+
- lib/hw_checker/directory_format_error.rb
|
65
|
+
- lib/hw_checker/python_code_quality.rb
|
63
66
|
- lib/hw_checker/base.rb
|
64
67
|
- lib/hw_checker/file_scan.rb
|
65
68
|
- lib/hw_checker/unarchive.rb
|
66
|
-
- lib/hw_checker/
|
69
|
+
- lib/hw_checker/ruby_code_quality.rb
|
70
|
+
- lib/hw_checker/archive_result.rb
|
67
71
|
- lib/hw_checker/directory_exist_error.rb
|
68
|
-
- lib/hw_checker/test_run_stat.rb
|
69
72
|
- lib/hw_checker/zip.rb
|
70
|
-
- lib/hw_checker/ruby_stat.rb
|
71
73
|
- lib/hw_checker.rb
|
72
74
|
- bin/hw_checker
|
73
|
-
- spec/
|
74
|
-
-
|
75
|
-
- spec/zip_spec.rb
|
76
|
-
- spec/base_spec.rb
|
77
|
-
- spec/ruby_test_run_spec.rb
|
78
|
-
- spec/file_scan_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
- config/config.yml
|
79
77
|
homepage:
|
80
78
|
licenses: []
|
81
79
|
metadata: {}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module HomeWorkChecker
|
2
|
-
module TestRunStat
|
3
|
-
def self.detect_language(path)
|
4
|
-
return '.py' unless Dir.exist?("#{path}/test")
|
5
|
-
Dir.foreach("#{path}/test") do |p|
|
6
|
-
if File.file?("#{path}/test/#{p}") && LANGUAGE_TYPES.include?(File.extname p)
|
7
|
-
return File.extname p
|
8
|
-
end
|
9
|
-
end
|
10
|
-
raise "Any .rb/.py file doesn't exist"
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.execute(work_path, tmp_path, dirname)
|
14
|
-
lang_needed = TestRunStat::detect_language("#{tmp_path}/#{dirname}")
|
15
|
-
class_names = LANGUAGE_TYPES[lang_needed]
|
16
|
-
test_passed = class_names.first.new(tmp_path, dirname).perform
|
17
|
-
code_quality = class_names.last.new(tmp_path, dirname).perform
|
18
|
-
[name_language(lang_needed), test_passed, code_quality]
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.name_language(extname)
|
22
|
-
extname == '.rb' ? 'ruby' : 'python'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/base_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
module HomeWorkChecker
|
4
|
-
describe Base do
|
5
|
-
before(:each) do
|
6
|
-
@archives = ['aaa.zip', 'bbb.7z']
|
7
|
-
@work_path = './support/'
|
8
|
-
@tmp_path = './support/tmp'
|
9
|
-
#@baza = HomeWorkChecker::Base.new(@work_path)
|
10
|
-
end
|
11
|
-
context '#start' do
|
12
|
-
it 'extracting should execute 5 times' do
|
13
|
-
files_to = double("FileScan", :work_path => @work_path)
|
14
|
-
files_to.stub(:files).and_return(@archives)
|
15
|
-
|
16
|
-
szip_files = stub("HomeWorkChecker::Unarchive::Zip")
|
17
|
-
szip_files.should_receive(:new).with("aaa.zip", @tmp_path).once
|
18
|
-
szip_files.should_receive(:new).with("bbb.7z", @tmp_path).once
|
19
|
-
|
20
|
-
run_files = double("HomeWorkChecker::TestRunStat")
|
21
|
-
run_files.stub(:detect_language).with("#{@tmp_path}/task1").and_return(".rb")
|
22
|
-
rtr = stub(LANGUAGE_TYPES[run_files.detect_language "#{@tmp_path}/task1"])
|
23
|
-
rtr.should_receive(:new).with("#{@tmp_path}/task1").once
|
24
|
-
|
25
|
-
files_to.stub(:each).
|
26
|
-
and_yield(stub(szip_files.new(files_to.files[0], @tmp_path)),
|
27
|
-
stub(rtr.new("#{@tmp_path}/task1"))).
|
28
|
-
and_yield(stub(szip_files.new(files_to.files[1], @tmp_path)))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/file_scan_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
module HomeWorkChecker
|
4
|
-
describe FileScan do
|
5
|
-
before(:each) do
|
6
|
-
@file_scan = FileScan.new('./support')
|
7
|
-
end
|
8
|
-
|
9
|
-
context '.new' do
|
10
|
-
def is_all_archives?
|
11
|
-
@file_scan.instance_variable_get(:@files).each do |item; ext_name|
|
12
|
-
ext_name = File::extname(item)
|
13
|
-
return false unless FILE_TYPES.include?(ext_name)
|
14
|
-
end
|
15
|
-
true
|
16
|
-
end
|
17
|
-
it 'should have exactly 6 items' do
|
18
|
-
@file_scan.instance_variable_get(:@files).should have(7).items
|
19
|
-
end
|
20
|
-
it 'should contain .zip/7z files only' do
|
21
|
-
is_all_archives?.should_not be_false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context '#each' do
|
26
|
-
before(:each) do
|
27
|
-
@file_scan.instance_variable_get(:@files).sort!
|
28
|
-
end
|
29
|
-
it 'should yield correct data' do
|
30
|
-
expect { |b| @file_scan.each(&b) }.to yield_successive_args(
|
31
|
-
["julia.tymo_creational.patterns", ".7z"],
|
32
|
-
["julia.tymo_iterators.in.ruby", ".zip"],
|
33
|
-
["pavlo.petryk_creational.patterns", ".zip"],
|
34
|
-
["pavlo.petryk_final.tasks", ".7z"],
|
35
|
-
["roman.horobets_creational.patterns", ".7z"],
|
36
|
-
["roman.horobets_final.tasks", ".zip"],
|
37
|
-
["roman.horobets_iterators.in.ruby", ".zip"]
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context '#exist_xml?' do
|
43
|
-
it 'xml-file should exist' do
|
44
|
-
@file_scan.should_not be_exist_xml('test.xml')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/spec/ruby_stat_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
module HomeWorkChecker
|
4
|
-
module TestRunStat
|
5
|
-
describe RubyStat do
|
6
|
-
before(:all) do
|
7
|
-
@ruby_stat = RubyStat.new('./support', 'julia.tymo_creational.patterns')
|
8
|
-
@ruby_stat.perform
|
9
|
-
end
|
10
|
-
|
11
|
-
context '#count_lines_failed' do
|
12
|
-
it 'should calculate failed lines correctly' do
|
13
|
-
@ruby_stat.instance_variable_get(:@lines_failed).should == 5
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context '#count_lines_all' do
|
18
|
-
it 'should calculate failed lines count correctly' do
|
19
|
-
@ruby_stat.instance_variable_get(:@lines_all).should == 7
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context '#calc_percent_quality' do
|
24
|
-
it 'should calculate percent correctly' do
|
25
|
-
@ruby_stat.send(:calc_percent_quality).should == 28.57
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/ruby_test_run_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
module HomeWorkChecker
|
4
|
-
module TestRunStat
|
5
|
-
describe RubyTestRun do
|
6
|
-
before(:all) do
|
7
|
-
@ruby_test_run = RubyTestRun.new('./support', 'julia.tymo_creational.patterns')
|
8
|
-
@ruby_test_run.perform
|
9
|
-
end
|
10
|
-
|
11
|
-
context '#count_passed_failed' do
|
12
|
-
it 'should calculate passed tests correctly' do
|
13
|
-
@ruby_test_run.instance_variable_get(:@passed).should == 0
|
14
|
-
end
|
15
|
-
it 'should calculate failed tests correctly' do
|
16
|
-
@ruby_test_run.instance_variable_get(:@failed).should == 1
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context '#calc_percent_passed' do
|
21
|
-
it 'should calculate percent passed tests correctly' do
|
22
|
-
@ruby_test_run.send(:calc_percent_passed).should == 0.00
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/test_run_stat_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
module HomeWorkChecker
|
4
|
-
describe HomeWorkChecker::TestRunStat do
|
5
|
-
context '.detect_language' do
|
6
|
-
before(:each) do
|
7
|
-
@detect_test = TestRunStat.detect_language('./support/julia.tymo_creational.patterns')
|
8
|
-
end
|
9
|
-
it 'should contain .rb/.py tests' do
|
10
|
-
@detect_test.should == '.rb'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/zip_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'hw_checker'
|
2
|
-
|
3
|
-
describe HomeWorkChecker::Unarchive::Zip do
|
4
|
-
before(:each) do
|
5
|
-
@path_filename = './support/julia.tymo_creational.patterns.7z'
|
6
|
-
@filename = 'julia.tymo_creational.patterns.7z'
|
7
|
-
@tmp_path = '/tmp/support/'
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:each) do
|
11
|
-
`rm -rf #{@tmp_path}/#{@filename.chomp(".7z") || filename.chomp(".zip")}`
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should exist in temp' do
|
15
|
-
@unarchive1 = HomeWorkChecker::Unarchive::Zip.new(@path_filename, @tmp_path)
|
16
|
-
Dir.exist?("#{@tmp_path}/#{@filename.chomp(".7z") || filename.chomp(".zip")}").should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'authenticity archive' do
|
20
|
-
@authenticity = `7za t #{@path_filename}`
|
21
|
-
@authenticity = @authenticity.include? "Everything is Ok"
|
22
|
-
@authenticity.should be_true
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'exit code' do
|
26
|
-
@unarchive1 = HomeWorkChecker::Unarchive::Zip.new(@path_filename, @tmp_path)
|
27
|
-
$?.to_s[-1].to_i.should equal(0)
|
28
|
-
end
|
29
|
-
end
|