attest 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -1
- data/README.rdoc +121 -36
- data/Rakefile +12 -1
- data/VERSION +1 -1
- data/attest.gemspec +61 -36
- data/bin/attest +18 -24
- data/doodle.txt +73 -29
- data/examples/{magic_calculator.rb → basic_functionality_example.rb} +42 -8
- data/examples/mocha_example.rb +43 -0
- data/examples/module_example.rb +49 -0
- data/examples/more/{placeholder.rb → multiple_context_example.rb} +0 -0
- data/examples/more/nesting/expectations_as_tests_example.rb +20 -0
- data/lib/attest.rb +4 -20
- data/lib/attest/config.rb +3 -6
- data/lib/attest/core_ext/kernel.rb +19 -1
- data/lib/attest/core_ext/object.rb +1 -2
- data/lib/attest/core_ext/proc.rb +35 -0
- data/lib/attest/execution_context.rb +156 -50
- data/lib/attest/expectation_result.rb +22 -1
- data/lib/attest/interface/output_writer_configurator.rb +25 -0
- data/lib/attest/interface/possible_tests_configurator.rb +35 -0
- data/lib/attest/interface/test_double_configurator.rb +40 -0
- data/lib/attest/output/basic_output_writer.rb +14 -46
- data/lib/attest/output/failures_only_output_writer.rb +47 -0
- data/lib/attest/output/output_writer.rb +124 -0
- data/lib/attest/output/output_writer_interface.rb +24 -0
- data/lib/attest/output/test_unit_output_writer.rb +32 -0
- data/lib/attest/proc/proc_source_reader.rb +49 -0
- data/lib/attest/rake/attesttask.rb +38 -0
- data/lib/attest/test_container.rb +15 -4
- data/lib/attest/test_loader.rb +28 -0
- data/lib/attest/test_object.rb +35 -29
- data/lib/attest/test_parser.rb +69 -11
- data/lib/trollop.rb +782 -0
- data/spec/interface/output_writer_configurator_test.rb +18 -0
- data/spec/interface/possible_tests_configurator_test.rb +55 -0
- data/spec/interface/test_double_configurator_test.rb +20 -0
- data/spec/output/output_writer_test.rb +20 -0
- data/spec/tmp/new_require_test.rb +10 -0
- metadata +55 -18
- data/.gitignore +0 -23
- data/examples/standard_calculator.rb +0 -28
- data/lib/attest/attest_error.rb +0 -7
- data/lib/attest/itself.rb +0 -34
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source :rubygems
|
2
|
-
gemspec
|
2
|
+
#gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
attest (0.
|
4
|
+
attest (0.2.0)
|
5
|
+
mocha
|
5
6
|
trollop
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: http://rubygems.org/
|
9
10
|
specs:
|
11
|
+
mocha (0.9.9)
|
12
|
+
rake
|
13
|
+
rake (0.8.7)
|
10
14
|
trollop (1.16.2)
|
11
15
|
|
12
16
|
PLATFORMS
|
@@ -14,4 +18,5 @@ PLATFORMS
|
|
14
18
|
|
15
19
|
DEPENDENCIES
|
16
20
|
attest!
|
21
|
+
mocha
|
17
22
|
trollop
|
data/README.rdoc
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
attest (vb) - to affirm the correctness or truth of
|
4
4
|
|
5
|
-
Attest allows you to define spec-like tests inline (within the same file as your actual code) which means almost non-existant overheads to putting some tests around your code. Of course that is just a feature that I wanted, you can just as easily put the tests into a separate file for a more traditional experience. Overall, attest tries to not be too prescriptive regarding the 'right' way to test. You want to test private methods - go ahead, access unexposed instance variables - no worries, pending and disabled tests are first class citizens. Don't like the output format, use a different one or write your own
|
5
|
+
Attest allows you to define spec-like tests inline (within the same file as your actual code) which means almost non-existant overheads to putting some tests around your code. Of course that is just a feature that I wanted, you can just as easily put the tests into a separate file for a more traditional experience. Overall, attest tries to not be too prescriptive regarding the 'right' way to test. You want to test private methods - go ahead, access unexposed instance variables - no worries, pending and disabled tests are first class citizens. Don't like the output format, use a different one or write your own. You should be allowed to test your code the way you want to, not the way someone else says you have to!
|
6
6
|
|
7
7
|
== A Quick Example
|
8
8
|
|
9
|
-
|
9
|
+
Below is an example of how to use the basic functionality, everything is reasonably straight forward, there are more examples in the examples directory including this one:
|
10
10
|
|
11
|
-
class
|
11
|
+
class ACalculator
|
12
12
|
def remember_value(value)
|
13
13
|
@value_in_memory = value
|
14
14
|
end
|
@@ -32,19 +32,19 @@ Currently the functionality is pretty minimal, almost fully described by the exa
|
|
32
32
|
end
|
33
33
|
|
34
34
|
if ENV["attest"]
|
35
|
-
this_tests
|
36
|
-
|
37
|
-
|
35
|
+
this_tests ACalculator do
|
36
|
+
before_each{@calculator = ACalculator.new}
|
37
|
+
after_each{@calculator = nil}
|
38
38
|
|
39
39
|
test("a pending test")
|
40
40
|
test("deliberately fail the test"){should_fail}
|
41
41
|
test("a successful empty test"){}
|
42
42
|
test("should NOT raise an error") {should_not_raise{@calculator.increment 4}}
|
43
43
|
test("it should raise an error, don't care what kind") {should_raise {@calculator.divide 5, 0}}
|
44
|
-
test("it should raise a ZeroDivisionError error with a message"){should_raise(ZeroDivisionError){@calculator.divide 5, 0}
|
45
|
-
test("adding 5 and 2 does not equal 8") { should_not_be_true
|
44
|
+
test("it should raise a ZeroDivisionError error with a message"){should_raise(ZeroDivisionError, :with_message => /divided by.*/){@calculator.divide 5, 0}}
|
45
|
+
test("adding 5 and 2 does not equal 8") { should_not_be_true(@calculator.add(5,2) == 8) }
|
46
46
|
test("this test will be an error when non-existant method called") {should_be_true{ @calculator.non_existant }}
|
47
|
-
test("should be able to call a private method like it was public"){should_be_true
|
47
|
+
test("should be able to call a private method like it was public"){should_be_true(@calculator.multiply(2,2) == 4)}
|
48
48
|
|
49
49
|
test "access an instance variable without explicitly exposing it" do
|
50
50
|
@calculator.remember_value(5)
|
@@ -55,33 +55,73 @@ Currently the functionality is pretty minimal, almost fully described by the exa
|
|
55
55
|
should_not_raise{@calculator.increment 4}
|
56
56
|
should_raise{ @calculator.non_existant }
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
|
+
nosetup
|
60
|
+
test("should not have access to calculator instance since run without setup"){should_be_true(@calculator == nil)}
|
61
|
+
|
62
|
+
test("should_equal expectations with and without block") do
|
63
|
+
should_equal 5, 5
|
64
|
+
should_equal(5){5}
|
65
|
+
should_not_equal 7, 8
|
66
|
+
should_not_be_equal(8){9}
|
67
|
+
end
|
68
|
+
|
69
|
+
test("should_be_same and should_not_be_same with and without block") do
|
70
|
+
should_be_same 5, 5
|
71
|
+
should_not_be_same(5){5.0}
|
72
|
+
string = "a"
|
73
|
+
should_be_same_as(string, string)
|
74
|
+
should_not_be_same_as("a"){string}
|
75
|
+
end
|
76
|
+
|
77
|
+
test("should_be_true without block") {should_be_true 5 == 5.0}
|
78
|
+
test("should_not_be_true without block") {should_be_false 5 == 6}
|
79
|
+
|
80
|
+
test("should_succeed test") do
|
81
|
+
should_succeed
|
82
|
+
end
|
83
|
+
|
84
|
+
test("should_be a lambda based matcher test") do
|
85
|
+
great = lambda{"great"}
|
86
|
+
should_be(great){"great"}
|
87
|
+
should_not_be(great){"bad"}
|
88
|
+
|
89
|
+
joke = lambda{"knock, knock"}
|
90
|
+
should_be_a(joke){"knock, knock"}
|
91
|
+
should_not_be_a(joke){"hello"}
|
92
|
+
end
|
59
93
|
end
|
60
94
|
end
|
61
95
|
|
62
|
-
|
96
|
+
== A Note About Inline Tests
|
63
97
|
|
64
|
-
|
98
|
+
The original premise was to define the tests inline, in the same file as the code, to that end we wrap the test code in an if statement controlled by an env variable. However this is not ideal, it does work, but if you have complex code it can cause issues. The issues are due to the fact that in order to execute the tests defined inline we potentially have to load the actual code under test twice, so if you have code that can potentially break because of this it likely will. For example alias chains are likely to cause spectacular death, method missing interactions might do the same. The point is, inline tests are only for simple code at the moment. In the future I am looking at parsing the test code separately at which point these issues will disappear and you will be able to play with inline tests fully. In the meantime, inline tests for simple code, otherwise do the traditional thing and split the test code out into its own file. If you do split out into separate file, you won't need to wrap the if statement with the env variable around your test code so there is some advantage to doing that. For an example see some of the test under the spec/ directory in the code these use attest to test some of its own classes (i.e. eating own dogfood).
|
65
99
|
|
66
|
-
The if statement with the ENV is necessary so that the test code is comlpetely ignored unless you're running it via the 'attest' executable. If anyone can think of a better way of doing it, I am open to ideas. If you have a bunch of files that live in a directory and you want to run the test that live in all of them:
|
67
100
|
|
68
|
-
|
101
|
+
== How Stuff Works
|
69
102
|
|
70
103
|
As per usual, to get some help:
|
71
104
|
|
72
105
|
attest --help
|
73
106
|
|
74
|
-
|
107
|
+
This should tell you how to launch stuff, but the short story is this. You need to provide some files and/or directories you want to include and optionally some you want to exclude e.g.:
|
108
|
+
|
109
|
+
attest -i file1.rb file2.rb dir_with_ruby_files/ -e dir_with_ruby_files/file3.rb
|
75
110
|
|
76
|
-
|
111
|
+
All the ruby files you provide will be used as is, all the directories will be trawled to find ruby files, in the end the system ends up with a bunch of ruby files to include and a bunch to exclude. The excludes trump the includes so if you have the same file in the includes list and the excludes it will be excluded. After we intersect the includes and the excludes we end up with a final list of files to execute. These will be deemed the test files and will be executed as such.
|
112
|
+
|
113
|
+
If your file needs other ruby files for it to function (as they often do :)), you will need to set up the requires yourself. So if your test code is in a separate file, you will need to require the file under test and whatever else it needs to work properly. Of course if your test is inline then this is hopefully not an issue.
|
77
114
|
|
78
115
|
Currently the output produces when running will look something like this:
|
79
116
|
|
80
|
-
>~/projects/attest$
|
81
|
-
/home/
|
82
|
-
|
117
|
+
>~/projects/attest$ attest -i examples/basic_functionality_example.rb
|
118
|
+
/home/alan/projects/attest/examples/basic_functionality_example.rb:
|
119
|
+
ACalculator
|
83
120
|
- a pending test [PENDING]
|
84
121
|
- deliberately fail the test [FAILURE]
|
122
|
+
|
123
|
+
/home/alan/projects/attest/examples/basic_functionality_example.rb:30
|
124
|
+
|
85
125
|
- a successful empty test
|
86
126
|
- should NOT raise an error
|
87
127
|
- it should raise an error, don't care what kind
|
@@ -89,26 +129,59 @@ Currently the output produces when running will look something like this:
|
|
89
129
|
- adding 5 and 2 does not equal 8
|
90
130
|
- this test will be an error when non-existant method called [ERROR]
|
91
131
|
|
92
|
-
NoMethodError: undefined method `non_existant' for #<
|
132
|
+
NoMethodError: undefined method `non_existant' for #<ACalculator:0x9e09050>
|
93
133
|
|
94
134
|
- should be able to call a private method like it was public
|
95
135
|
- access an instance variable without explicitly exposing it
|
96
136
|
- multiple expectations in one test
|
97
137
|
- should not have access to calculator instance since run without setup
|
138
|
+
- should_equal expectations with and without block
|
139
|
+
- should_be_same and should_not_be_same with and without block
|
140
|
+
- should_be_true without block
|
141
|
+
- should_not_be_true without block
|
142
|
+
- should_succeed test
|
143
|
+
- should_be a lambda based matcher test
|
144
|
+
|
98
145
|
|
146
|
+
18 tests 28 expectations 25 success 1 failure 1 error 1 pending 0 disabled
|
147
|
+
Finished in 19.01 milliseconds
|
99
148
|
|
100
|
-
|
149
|
+
The above output is produced by the Basic output format. There are two other output formats, the TestUnit and the FailuresOnly. The Basic one is used by default, but you can specify the others like this:
|
150
|
+
|
151
|
+
attest -i examples/basic_functionality_example.rb -o TestUnit
|
152
|
+
|
153
|
+
The above will produce output similar to:
|
154
|
+
|
155
|
+
PF.....E..........
|
156
|
+
|
157
|
+
18 tests 28 expectations 25 success 1 failure 1 error 1 pending 0 disabled
|
158
|
+
Finished in 20.05 milliseconds
|
159
|
+
|
160
|
+
In the above output the dots mean success, the letters can be F, E, P, D which stand for failure, error, pending, disabled - pretty simple.
|
161
|
+
|
162
|
+
The FailuresOnly output writer ignores everything except failure and error and outputs those.
|
163
|
+
|
164
|
+
== Test Double Integration
|
165
|
+
|
166
|
+
Currently if you want to mock and stub, the only thing that is built in is mocha integration. Mocha is also the default value for test double integration which means you need the mocha gem installed. If you don't want mocking and stubbing you can disable when you execute:
|
167
|
+
|
168
|
+
attest -i file1.rb -t none
|
169
|
+
|
170
|
+
If you want to be explicit regarding mocha you can do:
|
171
|
+
|
172
|
+
attest -i file1.rb -t mocha
|
173
|
+
|
174
|
+
There is an example of using mocha with attest in the examples directory, have a look. I do have plans to perhaps integrate other test double frameworks, and possibly to build a simple one to complement attest, but that's for the future. In the meantime hopefully mocha should fulfill most needs.
|
101
175
|
|
102
|
-
Currently that's the only kind of output format, I'll whip up some more output formats at a later date and/or give ability to supply your own.
|
103
176
|
|
104
177
|
== Current And Upcoming Features
|
105
178
|
|
106
179
|
- define tests inline
|
107
180
|
- call private methods as if they were public
|
108
181
|
- access instance variables as if they were exposed
|
109
|
-
-
|
110
|
-
-
|
111
|
-
- setup and teardown for all tests, but can
|
182
|
+
- three types of output writers with the possibility to define your own
|
183
|
+
- expectations such as should_fail, should_be_true, should_not_be_true, should_raise, should_not_raise, should_equal, should_be_same, should_match with aliases to other sensible names such as should_be_same_as etc. these work using both parameters or if you need to do fancy code, blocks
|
184
|
+
- setup and teardown for all tests, but can configure a test so that no setup is run for it, also there is a before_all and after_all that gets executed once before/after all the tests in a file
|
112
185
|
- automatically create a class that includes a module which methods you want to test (if you have a module called MyModule and you want to test its methods buy only after the module has been included in a class, a class called MyModuleClass will be automatically created and will include your module, an object of this new class will be instantiated for you to play with) e.g:
|
113
186
|
|
114
187
|
before_all do
|
@@ -116,32 +189,44 @@ Currently that's the only kind of output format, I'll whip up some more output f
|
|
116
189
|
end
|
117
190
|
|
118
191
|
- tries not to pollute core objects too much
|
192
|
+
- test can be pending if they have no body
|
193
|
+
- tests can be marked as disabled
|
194
|
+
- there is a rake task that is part of attest you can configure it in your project and execute your attest tests using rake instead of using the command line, the advantage is you configure once instead of every time you run, the disadvantage is less flexibility, i am looking to build this area out a bit more in future so you'll be able to do more with rake, here is an example of how to configure it:
|
195
|
+
|
196
|
+
<tt>
|
197
|
+
require 'attest/rake/attesttask'
|
198
|
+
Rake::AttestTask.new do |attest|
|
199
|
+
attest.include = ["spec/"]
|
200
|
+
attest.exclude = ["spec/tmp"]
|
201
|
+
attest.outputwriter = "Basic"
|
202
|
+
attest.testdouble = "mocha"
|
203
|
+
end
|
204
|
+
</tt>
|
205
|
+
|
206
|
+
- mocha integration to provide test double (mocking/stubbing) functionality, although I have a suspicion that it may not play nice with bundler the way it is now (need to confirm this), but if you have the gem installed normally everything should work fine, other test double frameworks are on the way
|
119
207
|
|
120
|
-
I've got a few things I want to try out in the future,
|
208
|
+
I've got a few things I want to try out in the future, like the ability to define your own output writers, more smarts in various areas, state across test executions, ability to execute only specific tests e.g. slowest from previous run etc. More specifically here are some things that are high on my radar:
|
121
209
|
|
122
|
-
- integrating with Mocha to provide at least some test double (i.e. mocking/stubbing) functionality
|
123
210
|
- writing my own test double project in the same general style as attest and integrating with it as well to give another more seamless mock/stub option
|
124
|
-
- default rake task for ability to run via rake rather than having to use the attest executable
|
125
|
-
- output the expectation count, not just the test count in the output report
|
126
|
-
- more smarts around classes that define their own method missing
|
127
|
-
- ability to disable tests and have the output list them as such
|
128
|
-
- write some basic unit tests for the framework using itself as the test framework (i.e. eating own dogfood style)
|
129
211
|
- allow for multiple setup and teardown blocks and ability to specify which tests they are relevant for
|
130
212
|
- haven't yet decided if I nested contexts are a good idea, I find they tend to confuse things
|
131
213
|
- maybe ability to do shared contexts, once again haven't decided if they are a good idea
|
132
|
-
- more types of expectations for convenience
|
133
|
-
- look at providing convenience stuff for web testing since that seems to be a big deal these days, ditto file system testing (requires mucho more thought)
|
214
|
+
- more types of expectations for convenience such as predicate expectations and more smarts regarding difining your own matchers
|
134
215
|
|
135
216
|
|
136
217
|
== More Examples
|
137
218
|
|
138
|
-
Go to the examples directory in the code, it contains the above example as well as a couple of others, reasonably easy to understand
|
219
|
+
Go to the examples directory in the code, it contains the above example as well as a couple of others, reasonably easy to understand. Also the spec directory contains some unit tests that utilise attest to test its own classes, this has examples of using mocha and fakefs as well as many of the features used in a real context.
|
220
|
+
|
221
|
+
== If You Have Questions/Found A Bug/Want A Feature
|
222
|
+
|
223
|
+
I am pretty open to ideas/conversation etc., just drop me a line (either through github or direct, just google skorks, you can't miss me :)) and we'll sort it out one way or another.
|
139
224
|
|
140
225
|
== Note on Patches/Pull Requests
|
141
226
|
|
142
227
|
* Fork the project.
|
143
228
|
* Make your feature addition or bug fix.
|
144
|
-
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
229
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally. If you can add some unit tests using attest itself then please do so, if it's too hard at least provide an example in the examples directory.
|
145
230
|
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
146
231
|
* Send me a pull request. Bonus points for topic branches.
|
147
232
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,9 @@ begin
|
|
10
10
|
gem.email = "alan@skorks.com"
|
11
11
|
gem.homepage = "http://github.com/skorks/attest"
|
12
12
|
gem.authors = ["Alan Skorkin"]
|
13
|
-
gem.add_runtime_dependency "
|
13
|
+
#gem.add_runtime_dependency "bundler"
|
14
|
+
gem.add_development_dependency "mocha"
|
15
|
+
gem.add_development_dependency "fakefs"
|
14
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
17
|
end
|
16
18
|
Jeweler::GemcutterTasks.new
|
@@ -25,6 +27,15 @@ Rake::TestTask.new(:test) do |test|
|
|
25
27
|
test.verbose = true
|
26
28
|
end
|
27
29
|
|
30
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '/lib/'))) unless $:.include?(File.expand_path(File.join(File.dirname(__FILE__), '/lib')))
|
31
|
+
require 'attest/rake/attesttask'
|
32
|
+
Rake::AttestTask.new do |attest|
|
33
|
+
attest.include = ["spec/"]
|
34
|
+
attest.exclude = ["spec/tmp"]
|
35
|
+
attest.outputwriter = "Basic"
|
36
|
+
attest.testdouble = "mocha"
|
37
|
+
end
|
38
|
+
|
28
39
|
begin
|
29
40
|
require 'rcov/rcovtask'
|
30
41
|
Rcov::RcovTask.new do |test|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/attest.gemspec
CHANGED
@@ -1,60 +1,82 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{attest}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alan Skorkin"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-21}
|
13
13
|
s.default_executable = %q{attest}
|
14
14
|
s.description = %q{Attest allows you to define spec-like tests inline (within the same file as your actual code) which means almost non-existant overheads to putting some tests around your code. It also tries to not be too prescriptive regarding the 'right' way to test. You want to test private methods - go ahead, access unexposed instance variables - no worries, pending and disabled tests are first class citizens. Don't like the output format, use a different one or write your own. Infact you don't even have to define you tests inline if you prefer the 'traditional' way, separate directory and all. You should be allowed to test your code the way you want to, not the way someone else says you have to!}
|
15
15
|
s.email = %q{alan@skorks.com}
|
16
16
|
s.executables = ["attest"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
|
19
|
+
"README.rdoc"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"attest.gemspec",
|
30
|
+
"bin/attest",
|
31
|
+
"doodle.txt",
|
32
|
+
"examples/basic_functionality_example.rb",
|
33
|
+
"examples/mocha_example.rb",
|
34
|
+
"examples/module_example.rb",
|
35
|
+
"examples/more/multiple_context_example.rb",
|
36
|
+
"examples/more/nesting/expectations_as_tests_example.rb",
|
37
|
+
"lib/attest.rb",
|
38
|
+
"lib/attest/config.rb",
|
39
|
+
"lib/attest/core_ext/kernel.rb",
|
40
|
+
"lib/attest/core_ext/object.rb",
|
41
|
+
"lib/attest/core_ext/proc.rb",
|
42
|
+
"lib/attest/execution_context.rb",
|
43
|
+
"lib/attest/expectation_result.rb",
|
44
|
+
"lib/attest/interface/output_writer_configurator.rb",
|
45
|
+
"lib/attest/interface/possible_tests_configurator.rb",
|
46
|
+
"lib/attest/interface/test_double_configurator.rb",
|
47
|
+
"lib/attest/output/basic_output_writer.rb",
|
48
|
+
"lib/attest/output/failures_only_output_writer.rb",
|
49
|
+
"lib/attest/output/output_writer.rb",
|
50
|
+
"lib/attest/output/output_writer_interface.rb",
|
51
|
+
"lib/attest/output/test_unit_output_writer.rb",
|
52
|
+
"lib/attest/proc/proc_source_reader.rb",
|
53
|
+
"lib/attest/rake/attesttask.rb",
|
54
|
+
"lib/attest/test_container.rb",
|
55
|
+
"lib/attest/test_loader.rb",
|
56
|
+
"lib/attest/test_object.rb",
|
57
|
+
"lib/attest/test_parser.rb",
|
58
|
+
"lib/trollop.rb",
|
59
|
+
"spec/interface/output_writer_configurator_test.rb",
|
60
|
+
"spec/interface/possible_tests_configurator_test.rb",
|
61
|
+
"spec/interface/test_double_configurator_test.rb",
|
62
|
+
"spec/output/output_writer_test.rb",
|
63
|
+
"spec/tmp/new_require_test.rb"
|
48
64
|
]
|
49
65
|
s.homepage = %q{http://github.com/skorks/attest}
|
50
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
51
66
|
s.require_paths = ["lib"]
|
52
67
|
s.rubygems_version = %q{1.3.7}
|
53
68
|
s.summary = %q{An inline unit testing/spec framework that doesn't force you to follow arbitrary rules}
|
54
69
|
s.test_files = [
|
55
|
-
"examples/
|
56
|
-
|
57
|
-
|
70
|
+
"examples/basic_functionality_example.rb",
|
71
|
+
"examples/mocha_example.rb",
|
72
|
+
"examples/module_example.rb",
|
73
|
+
"examples/more/multiple_context_example.rb",
|
74
|
+
"examples/more/nesting/expectations_as_tests_example.rb",
|
75
|
+
"spec/interface/output_writer_configurator_test.rb",
|
76
|
+
"spec/interface/possible_tests_configurator_test.rb",
|
77
|
+
"spec/interface/test_double_configurator_test.rb",
|
78
|
+
"spec/output/output_writer_test.rb",
|
79
|
+
"spec/tmp/new_require_test.rb"
|
58
80
|
]
|
59
81
|
|
60
82
|
if s.respond_to? :specification_version then
|
@@ -62,12 +84,15 @@ Gem::Specification.new do |s|
|
|
62
84
|
s.specification_version = 3
|
63
85
|
|
64
86
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
-
s.
|
87
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
88
|
+
s.add_development_dependency(%q<fakefs>, [">= 0"])
|
66
89
|
else
|
67
|
-
s.add_dependency(%q<
|
90
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
91
|
+
s.add_dependency(%q<fakefs>, [">= 0"])
|
68
92
|
end
|
69
93
|
else
|
70
|
-
s.add_dependency(%q<
|
94
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
95
|
+
s.add_dependency(%q<fakefs>, [">= 0"])
|
71
96
|
end
|
72
97
|
end
|
73
98
|
|
data/bin/attest
CHANGED
@@ -1,37 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
ENV["attest"] = "true"
|
6
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/attest")
|
3
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib/'))) unless $:.include?(File.expand_path(File.join(File.dirname(__FILE__), '../lib')))
|
4
|
+
require 'trollop'
|
7
5
|
|
8
6
|
opts = Trollop::options do
|
9
7
|
banner <<-EOS
|
10
8
|
Usage:
|
11
|
-
|
9
|
+
attest [options]
|
12
10
|
where [options] are:
|
13
|
-
EOS
|
14
|
-
|
15
|
-
opt :
|
16
|
-
opt :
|
11
|
+
EOS
|
12
|
+
opt :include, "Directories or files to search for tests, directories will be recursively expanded", :type => :strings, :required => true
|
13
|
+
opt :exclude, "Directories or files to exclude when searching for tests, will override entries that have been included", :type => :strings
|
14
|
+
opt :testdouble, "The identifier of the test double framework to use, can be 'none'", :type => :string, :default => "mocha"
|
15
|
+
opt :outputwriter, "The output writer to use when running the tests", :type => :string, :default => "Basic"
|
17
16
|
end
|
18
|
-
Trollop::die :file, "Must exist" unless File.exist?(opts[:file]) if opts[:file]
|
19
|
-
Trollop::die :directory, "Must exist" unless File.exist?(opts[:directory]) && File.directory?(opts[:directory]) if opts[:directory]
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
require 'attest'
|
19
|
+
require 'attest/interface/output_writer_configurator'
|
20
|
+
require 'attest/interface/test_double_configurator'
|
21
|
+
require 'attest/interface/possible_tests_configurator'
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
Attest.configure do |config|
|
24
|
+
config.output_writer = Attest::OutputWriterConfigurator.configure(opts[:outputwriter])
|
25
|
+
config.testdouble = Attest::TestDoubleConfigurator.configure(opts[:testdouble])
|
26
|
+
config.possible_tests = Attest::PossibleTestsConfigurator.configure(opts[:include], opts[:exclude])
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
Dir[File.join(File.expand_path(opts[:directory]), "**/*.rb")].each do |file|
|
32
|
-
Attest.config.current_file = file
|
33
|
-
load file
|
34
|
-
end
|
35
|
-
end
|
29
|
+
require 'attest/test_loader'
|
36
30
|
|
37
|
-
Attest.output_writer
|
31
|
+
Attest::TestLoader.execute(Attest.config.possible_tests, Attest.config.output_writer)
|