test-construct 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.devver/hooks/build +11 -0
- data/.devver/hooks/install_dependencies +3 -0
- data/.devver/hooks/notify +50 -0
- data/.devver/hooks/prepare_database +1 -0
- data/History.txt +4 -0
- data/README.markdown +144 -0
- data/Rakefile +36 -0
- data/bin/construct +8 -0
- data/bugs/issue-0127c8c6ba1d31b5488f4551f8d869e57d53956d.yaml +29 -0
- data/bugs/issue-404e5da7b128e5b34e7a33fbcd56603618010d92.yaml +22 -0
- data/bugs/issue-50798912193be32b1dc610d949a557b3860d96fd.yaml +23 -0
- data/bugs/issue-5a10ec7298127df3c62255ea59e01dcf831ff1d3.yaml +22 -0
- data/bugs/issue-67f704f8b7190ccc1157eec007c3d584779dc805.yaml +18 -0
- data/bugs/issue-881ae950569b6ca718fae0060f2751710b972fd2.yaml +22 -0
- data/bugs/issue-bc8dfdf3834bb84b1d942ab2a90ac8c82b4389fb.yaml +22 -0
- data/bugs/issue-d05e9a907202348d47c4bf92062c1f4673dcae68.yaml +18 -0
- data/bugs/issue-f30a3db19d917f8e72ca8689e099ef0cb2681fd3.yaml +20 -0
- data/bugs/project.yaml +16 -0
- data/construct.gemspec +40 -0
- data/geminstaller.yml +7 -0
- data/lib/construct.rb +68 -0
- data/lib/construct/helpers.rb +29 -0
- data/lib/construct/path_extensions.rb +52 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/zentest.rake +36 -0
- data/test-construct.gemspec +39 -0
- data/test/construct_test.rb +469 -0
- data/test/test_helper.rb +35 -0
- metadata +114 -0
data/.devver/hooks/build
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
# build
|
5
|
+
#
|
6
|
+
# This hook is responsible for running a full "build" of the project for the
|
7
|
+
# purpose of Continuus Integration
|
8
|
+
#
|
9
|
+
################################################################################
|
10
|
+
|
11
|
+
rake
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
# notify
|
5
|
+
#
|
6
|
+
# This hook is reponsible for notifying the user of the results of a task, such
|
7
|
+
# as a Continuous Integration build.
|
8
|
+
#
|
9
|
+
# PARAMETERS:
|
10
|
+
#
|
11
|
+
# This hook will be called with the form:
|
12
|
+
#
|
13
|
+
# .devver/hooks/notify TASK EXIT_STATUS
|
14
|
+
#
|
15
|
+
# * TASK is the name of the task that triggered the notification
|
16
|
+
# * EXIT_STATUS is the numeric exit status of the task. 0 indicates success.
|
17
|
+
#
|
18
|
+
# INPUT:
|
19
|
+
#
|
20
|
+
# This hook will be provided with a transcript of the triggering task's output.
|
21
|
+
# Both STDOUT and STDERR output will be included in the transcript.
|
22
|
+
#
|
23
|
+
# OUTPUT:
|
24
|
+
#
|
25
|
+
# This task should exit with a 0 status if the notification was successful, and
|
26
|
+
# a nonzero status if the notification failed.
|
27
|
+
#
|
28
|
+
################################################################################
|
29
|
+
require 'net/smtp'
|
30
|
+
require 'time'
|
31
|
+
to = "devs@devver.net"
|
32
|
+
|
33
|
+
success = ARGV[0].to_i == 0
|
34
|
+
recipient = ENV.fetch('NOTIFY_RECIPIENT'){to}
|
35
|
+
message = <<"EOF"
|
36
|
+
From: support@devver.net
|
37
|
+
To: #{recipient}
|
38
|
+
Subject: Build #{success ? 'succeeded' : 'failed'}
|
39
|
+
Date: #{Time.now.rfc2822}
|
40
|
+
|
41
|
+
The task "#{ARGV[1]}" #{success ? 'succeeded' : 'failed'}.
|
42
|
+
|
43
|
+
Output:
|
44
|
+
|
45
|
+
#{$stdin.read}
|
46
|
+
EOF
|
47
|
+
|
48
|
+
Net::SMTP.start('localhost', 25) do |smtp|
|
49
|
+
smtp.send_message(message, 'application@devver.net', recipient)
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#!/bin/sh
|
data/History.txt
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
Construct
|
2
|
+
=========
|
3
|
+
by Ben Brinckerhoff and Avdi Grimm
|
4
|
+
http://github.com/devver/construct
|
5
|
+
|
6
|
+
DESCRIPTION:
|
7
|
+
============
|
8
|
+
|
9
|
+
"This is the construct. It's our loading program. We can load anything, from clothing to equipment, weapons, and training simulations, anything we need" -- Morpheus
|
10
|
+
|
11
|
+
Construct is a DSL for creating temporary files and directories during testing.
|
12
|
+
|
13
|
+
SYNOPSIS:
|
14
|
+
========
|
15
|
+
|
16
|
+
class ExampleTest < Test::Unit::TestCase
|
17
|
+
include Construct::Helpers
|
18
|
+
|
19
|
+
def test_example
|
20
|
+
within_construct do |c|
|
21
|
+
c.directory 'alice/rabbithole' do |d|
|
22
|
+
d.file 'white_rabbit.txt', "I'm late!"
|
23
|
+
|
24
|
+
assert_equal "I'm late!", File.read('white_rabbit.txt')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
USAGE
|
32
|
+
=====
|
33
|
+
|
34
|
+
To use Construct, you need to include the Construct module in your class like so:
|
35
|
+
|
36
|
+
include Construct::Helpers
|
37
|
+
|
38
|
+
Using construct is as simple as calling `within_construct` and providing a block. All files and directories that are created within that block are created within a temporary directory. The temporary directory is always deleted before `within_construct` finishes.
|
39
|
+
|
40
|
+
There is nothing special about the files and directories created with Construct, so you can use plain old Ruby IO methods to interact with them.
|
41
|
+
|
42
|
+
Creating files
|
43
|
+
--------------
|
44
|
+
|
45
|
+
The most basic use of Construct is creating an empty file with the:
|
46
|
+
|
47
|
+
within_construct do |construct|
|
48
|
+
construct.file('foo.txt')
|
49
|
+
end
|
50
|
+
|
51
|
+
Note that the working directory is, by default, automatically change to the temporary directory created by Construct, so the following assertion will pass:
|
52
|
+
|
53
|
+
within_construct do |construct|
|
54
|
+
construct.file('foo.txt')
|
55
|
+
assert File.exist?('foo.txt')
|
56
|
+
end
|
57
|
+
|
58
|
+
You can also provide content for the file, either with an optional argument or using the return value of a supplied block:
|
59
|
+
|
60
|
+
within_construct do |construct|
|
61
|
+
construct.file('foo.txt','Here is some content')
|
62
|
+
construct.file('bar.txt') do
|
63
|
+
<<-EOS
|
64
|
+
The block will return this string, which will be used as the content.
|
65
|
+
EOS
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
If you provide block that accepts a parameter, construct will pass you the IO object. In this case, you are responsible for writing content to the file yourself - the return value of the block will not be used:
|
70
|
+
|
71
|
+
within_construct do |construct|
|
72
|
+
construct.file('foo.txt') do |file|
|
73
|
+
file << "Some content\n"
|
74
|
+
file << "Some more content"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Finally, you can provide the entire path to a file and the parent directories will be created automatically:
|
79
|
+
|
80
|
+
within_construct do |construct|
|
81
|
+
construct.file('foo/bar/baz.txt')
|
82
|
+
end
|
83
|
+
|
84
|
+
Creating directories
|
85
|
+
--------------
|
86
|
+
|
87
|
+
It is easy to create a directory:
|
88
|
+
|
89
|
+
within_construct do |construct|
|
90
|
+
construct.directory('foo')
|
91
|
+
end
|
92
|
+
|
93
|
+
You can also provide a block. The object passed to the block can be used to create nested files and directories (it's just a [Pathname](http://www.ruby-doc.org/stdlib/libdoc/pathname/rdoc/index.html) instance with some extra functionality, so you can use it to get the path of the current directory).
|
94
|
+
|
95
|
+
Again, note that the working directory is automatically changed while in the block:
|
96
|
+
|
97
|
+
within_construct do |construct|
|
98
|
+
construct.directory('foo') do |dir|
|
99
|
+
dir.file('bar.txt')
|
100
|
+
assert File.exist?('bar.txt') # This assertion will pass
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
Again, you can provide paths and the necessary directories will be automatically created:
|
105
|
+
|
106
|
+
within_construct do |construct|
|
107
|
+
construct.directory('foo/bar/') do |dir|
|
108
|
+
dir.directory('baz')
|
109
|
+
dir.directory('bazz')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Please read test/construct_test.rb for more examples.
|
114
|
+
|
115
|
+
INSTALL
|
116
|
+
=======
|
117
|
+
|
118
|
+
gem install devver-construct --source http://gems.github.com
|
119
|
+
|
120
|
+
LICENSE
|
121
|
+
=======
|
122
|
+
|
123
|
+
(The MIT License)
|
124
|
+
|
125
|
+
Copyright (c) 2009
|
126
|
+
|
127
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
128
|
+
a copy of this software and associated documentation files (the
|
129
|
+
'Software'), to deal in the Software without restriction, including
|
130
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
131
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
132
|
+
permit persons to whom the Software is furnished to do so, subject to
|
133
|
+
the following conditions:
|
134
|
+
|
135
|
+
The above copyright notice and this permission notice shall be
|
136
|
+
included in all copies or substantial portions of the Software.
|
137
|
+
|
138
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
139
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
140
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
141
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
142
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
143
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
144
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bones'
|
7
|
+
Bones.setup
|
8
|
+
rescue LoadError
|
9
|
+
begin
|
10
|
+
load 'tasks/setup.rb'
|
11
|
+
rescue LoadError
|
12
|
+
raise RuntimeError, '### please install the "bones" gem ###'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ensure_in_path 'lib'
|
17
|
+
require 'construct'
|
18
|
+
|
19
|
+
task :default => 'test'
|
20
|
+
|
21
|
+
PROJ.name = 'test-construct'
|
22
|
+
|
23
|
+
PROJ.authors = 'Ben Brinckerhoff (ben@devver.net) and Avdi Grimm (avdi@devver.net)'
|
24
|
+
PROJ.email = 'ben@devver.net, avdi@devver.net'
|
25
|
+
PROJ.url = 'http://github.com/devver/construct'
|
26
|
+
PROJ.version = Construct::VERSION
|
27
|
+
PROJ.rubyforge.name = 'test-construct'
|
28
|
+
PROJ.test.files = FileList['test/**/*_test.rb']
|
29
|
+
PROJ.ruby_opts = []
|
30
|
+
PROJ.readme_file = "README.markdown"
|
31
|
+
PROJ.summary = "Construct is a DSL for creating temporary files and directories during testing."
|
32
|
+
PROJ.ignore_file = ".gitignore"
|
33
|
+
|
34
|
+
PROJ.gem.development_dependencies << ["jeremymcanally-pending", "~> 0.1"]
|
35
|
+
|
36
|
+
# EOF
|
data/bin/construct
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Fix Construct::VERSION to not conflict with other VERSION constants when Constuct is included
|
3
|
+
desc: |-
|
4
|
+
We have two options:
|
5
|
+
1. We could move the includable module to a submodule on Construct, so VERSION would not be added
|
6
|
+
2. We could change VERSION to CONSTRUCT_VERSION or something
|
7
|
+
type: :feature
|
8
|
+
component: construct
|
9
|
+
release: neo
|
10
|
+
reporter: Benjamin Brinckerhoff <ben@devver.net>
|
11
|
+
status: :closed
|
12
|
+
disposition: :fixed
|
13
|
+
creation_time: 2009-08-18 17:16:31.006045 Z
|
14
|
+
references: []
|
15
|
+
|
16
|
+
id: 0127c8c6ba1d31b5488f4551f8d869e57d53956d
|
17
|
+
log_events:
|
18
|
+
- - 2009-08-18 17:16:33.750549 Z
|
19
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
20
|
+
- created
|
21
|
+
- ""
|
22
|
+
- - 2009-08-18 18:23:37.187486 Z
|
23
|
+
- Avdi Grimm <avdi@avdi.org>
|
24
|
+
- changed status from unstarted to in_progress
|
25
|
+
- ""
|
26
|
+
- - 2009-08-18 19:23:37.387572 Z
|
27
|
+
- Avdi Grimm <avdi@avdi.org>
|
28
|
+
- closed with disposition fixed
|
29
|
+
- Moved test helpers to Construct::Helpers
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Make it possible to use Construct without including the module
|
3
|
+
desc: E.g. Construct.within_construct do ... end
|
4
|
+
type: :feature
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Avdi Grimm <avdi@avdi.org>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2009-08-18 18:08:34.555757 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 404e5da7b128e5b34e7a33fbcd56603618010d92
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 18:08:37.083969 Z
|
16
|
+
- Avdi Grimm <avdi@avdi.org>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2009-08-18 20:06:07.792831 Z
|
20
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
21
|
+
- closed with disposition fixed
|
22
|
+
- ""
|
@@ -0,0 +1,23 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Add gemspec file
|
3
|
+
desc: We'll need to be sure to include all our dependencies. Note that some dependencies (like Mocha) are only necessary if the user wants to run our tests.
|
4
|
+
type: :task
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Benjamin Brinckerhoff <ben@devver.net>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2009-08-18 17:18:22.309778 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 50798912193be32b1dc610d949a557b3860d96fd
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 17:18:23.566713 Z
|
16
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2009-08-18 19:37:27.228428 Z
|
20
|
+
- Avdi Grimm <avdi@devver.net>
|
21
|
+
- closed with disposition fixed
|
22
|
+
- This was closed by adding Bones-ifying the project
|
23
|
+
git_branch:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Block form of file creation yields file IO object
|
3
|
+
desc: ""
|
4
|
+
type: :feature
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Avdi Grimm <avdi@avdi.org>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2009-08-18 15:17:32.937884 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 5a10ec7298127df3c62255ea59e01dcf831ff1d3
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 15:17:37.603386 Z
|
16
|
+
- Avdi Grimm <avdi@avdi.org>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2009-08-18 15:26:09.385442 Z
|
20
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
21
|
+
- closed with disposition fixed
|
22
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Switch to development/release branch structure
|
3
|
+
desc: ""
|
4
|
+
type: :task
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Avdi Grimm <avdi@avdi.org>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2009-08-18 18:22:21.091404 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 67f704f8b7190ccc1157eec007c3d584779dc805
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 18:22:23.004080 Z
|
16
|
+
- Avdi Grimm <avdi@avdi.org>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Write synoposis with examples
|
3
|
+
desc: We need to give the basic usage for construct.
|
4
|
+
type: :task
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Benjamin Brinckerhoff <ben@devver.net>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2009-08-18 17:19:03.766097 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 881ae950569b6ca718fae0060f2751710b972fd2
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 17:19:04.502056 Z
|
16
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2009-08-18 20:15:40.057331 Z
|
20
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
21
|
+
- closed with disposition fixed
|
22
|
+
- ""
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Add files to make construct a proper gem
|
3
|
+
desc: We'll need a Rakefile, a license.txt, an authors file, and will want to move tests to their own directory. Also, we'll need a gemspec file
|
4
|
+
type: :task
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Benjamin Brinckerhoff <ben@devver.net>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2009-08-18 15:31:45.185804 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: bc8dfdf3834bb84b1d942ab2a90ac8c82b4389fb
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 15:31:49.976522 Z
|
16
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2009-08-18 20:19:55.937027 Z
|
20
|
+
- Benjamin Brinckerhoff <ben@devver.net>
|
21
|
+
- closed with disposition fixed
|
22
|
+
- ""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Make Dir.chdir play nicely with ruby-debug
|
3
|
+
desc: ""
|
4
|
+
type: :bugfix
|
5
|
+
component: construct
|
6
|
+
release: neo
|
7
|
+
reporter: Avdi Grimm <avdi@avdi.org>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2009-08-18 15:21:33.793706 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: d05e9a907202348d47c4bf92062c1f4673dcae68
|
14
|
+
log_events:
|
15
|
+
- - 2009-08-18 15:21:37.449671 Z
|
16
|
+
- Avdi Grimm <avdi@avdi.org>
|
17
|
+
- created
|
18
|
+
- ""
|