p8-file_stats_checker 0.0.1

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.
Files changed (3) hide show
  1. data/README +0 -0
  2. data/test/file_stats_checker_test.rb +87 -0
  3. metadata +55 -0
data/README ADDED
File without changes
@@ -0,0 +1,87 @@
1
+ require "test/unit"
2
+ require "rubygems"
3
+ require "mocha"
4
+ require(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'file_stats_checker')))
5
+
6
+ PORT = 3434
7
+
8
+ class FileStatsServerTest < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @server = FileStatsServer.new('localhost', PORT)
12
+ @server.start
13
+ @io = mock()
14
+ end
15
+
16
+ def teardown
17
+ @server.stop
18
+ end
19
+
20
+ def test_server_with_real_file_should_return_allowed_stat
21
+ file = "test/test.txt"
22
+ %w{mtime ctime size}.each do |stat|
23
+ @io.expects(:readline).returns("#{file}, #{stat}")
24
+ @io.expects(:puts).with(File.stat(file).send(stat))
25
+ @server.serve(@io)
26
+ end
27
+ end
28
+
29
+ def test_server_with_real_file_and_non_allowed_stat_should_keep_quit
30
+ file = "test/test.txt"
31
+ @io.expects(:readline).returns("#{file}, x")
32
+ @server.serve(@io)
33
+ end
34
+
35
+ def test_server_with_non_existing_file_should_keep_quit
36
+ @io.expects(:readline).returns('a, 1')
37
+ @server.serve(@io)
38
+ end
39
+
40
+ def test_server_empty_stat_should_keep_quit
41
+ file = "test/test.txt"
42
+ @io.expects(:readline).returns('#{file},')
43
+ @server.serve(@io)
44
+ end
45
+
46
+ def test_server_without_stat_should_keep_quit
47
+ file = "test/test.txt"
48
+ @io.expects(:readline).returns('#{file}')
49
+ @server.serve(@io)
50
+ end
51
+
52
+ def test_server_empty_input_should_keep_quit
53
+ @io.expects(:readline).returns('')
54
+ @server.serve(@io)
55
+ end
56
+
57
+ end
58
+
59
+ class FileStatsClientTest < Test::Unit::TestCase
60
+
61
+ def setup
62
+ @server = FileStatsServer.new('localhost', PORT)
63
+ @server.start
64
+ @io = mock()
65
+ end
66
+
67
+ def teardown
68
+ @server.stop
69
+ end
70
+
71
+ def test_stat_with_real_file_should_return_allowed_stat
72
+ file = "test/test.txt"
73
+ stat = "mtime"
74
+ client = FileStatsClient.new('localhost', PORT)
75
+ response = client.stat(file, stat)
76
+ assert_equal File.stat(file).send(stat).to_s, response
77
+ end
78
+
79
+ def test_stat_with_real_file_and_incorrect_stat_should_return_allowed_stat
80
+ file = "test/test.txt"
81
+ stat = "x"
82
+ client = FileStatsClient.new('localhost', PORT)
83
+ response = client.stat(file, stat)
84
+ assert_equal nil, response
85
+ end
86
+
87
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: p8-file_stats_checker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Petrik de Heus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ""
17
+ email:
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - lib/file_stat_stats_checker.rb
27
+ - test/file_stats_checker_test.rb
28
+ has_rdoc: false
29
+ homepage:
30
+ post_install_message:
31
+ rdoc_options: []
32
+
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ requirements: []
48
+
49
+ rubyforge_project:
50
+ rubygems_version: 1.2.0
51
+ signing_key:
52
+ specification_version: 2
53
+ summary: Grit is a Ruby library for extracting information from a git repository in an object oriented manner.
54
+ test_files: []
55
+