minilab 1.0.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +2 -0
- data/CHANGES +2 -0
- data/LICENSE +19 -0
- data/README +107 -0
- data/Rakefile +145 -0
- data/config/environment.rb +15 -0
- data/config/objects.yml +22 -0
- data/lib/analog_io.rb +30 -0
- data/lib/digital_auxport_io.rb +49 -0
- data/lib/digital_configuration.rb +66 -0
- data/lib/digital_port_io.rb +68 -0
- data/lib/extension/extconf.rb +4 -0
- data/lib/extension/minilab_hardware.c +235 -0
- data/lib/extension/minilab_hardware.so +0 -0
- data/lib/library_translator.rb +48 -0
- data/lib/minilab.rb +149 -0
- data/lib/minilab_context.rb +39 -0
- data/lib/result_verifier.rb +14 -0
- data/test/integration/analog_input_output_test.rb +43 -0
- data/test/integration/connect_to_hardware_test.rb +13 -0
- data/test/integration/digital_input_output_test.rb +114 -0
- data/test/integration/integration_test.rb +53 -0
- data/test/integration/require_minilab_test.rb +9 -0
- data/test/system/analog_input.test +3 -0
- data/test/system/analog_output.test +37 -0
- data/test/system/digital_port_input.test +5 -0
- data/test/system/digital_port_output.test +39 -0
- data/test/system/digital_port_read_byte.test +26 -0
- data/test/system/digital_screw_terminals_input.test +2 -0
- data/test/system/digital_screw_terminals_output.test +11 -0
- data/test/system/minilab_driver.rb +85 -0
- data/test/test_helper.rb +11 -0
- data/test/unit/analog_io_test.rb +87 -0
- data/test/unit/digital_auxport_io_test.rb +114 -0
- data/test/unit/digital_configuration_test.rb +136 -0
- data/test/unit/digital_port_io_test.rb +117 -0
- data/test/unit/library_translator_test.rb +100 -0
- data/test/unit/minilab_context_test.rb +82 -0
- data/test/unit/minilab_hardware_test.rb +83 -0
- data/test/unit/minilab_test.rb +131 -0
- data/test/unit/result_verifier_test.rb +33 -0
- data/vendor/behaviors/lib/behaviors.rb +50 -0
- data/vendor/behaviors/tasks/behaviors_tasks.rake +140 -0
- data/vendor/behaviors/test/behaviors_tasks_test.rb +71 -0
- data/vendor/behaviors/test/behaviors_test.rb +50 -0
- data/vendor/behaviors/test/tasks_test/Rakefile +16 -0
- data/vendor/behaviors/test/tasks_test/doc/behaviors.html +55 -0
- data/vendor/behaviors/test/tasks_test/lib/user.rb +2 -0
- data/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -0
- data/vendor/constructor/Rakefile +44 -0
- data/vendor/constructor/config/environment.rb +12 -0
- data/vendor/constructor/lib/constructor.rb +132 -0
- data/vendor/constructor/test/constructor_test.rb +366 -0
- data/vendor/constructor/test/helper.rb +3 -0
- data/vendor/diy/README +26 -0
- data/vendor/diy/Rakefile +18 -0
- data/vendor/diy/lib/constructor.rb +114 -0
- data/vendor/diy/lib/diy.rb +329 -0
- data/vendor/diy/proto/context.rb +117 -0
- data/vendor/diy/proto/context.yml +20 -0
- data/vendor/diy/test/diy_test.rb +370 -0
- data/vendor/diy/test/files/broken_construction.yml +7 -0
- data/vendor/diy/test/files/cat/cat.rb +4 -0
- data/vendor/diy/test/files/cat/extra_conflict.yml +5 -0
- data/vendor/diy/test/files/cat/heritage.rb +2 -0
- data/vendor/diy/test/files/cat/needs_input.yml +3 -0
- data/vendor/diy/test/files/cat/the_cat_lineage.rb +1 -0
- data/vendor/diy/test/files/dog/dog_model.rb +4 -0
- data/vendor/diy/test/files/dog/dog_presenter.rb +4 -0
- data/vendor/diy/test/files/dog/dog_view.rb +2 -0
- data/vendor/diy/test/files/dog/file_resolver.rb +2 -0
- data/vendor/diy/test/files/dog/other_thing.rb +2 -0
- data/vendor/diy/test/files/dog/simple.yml +11 -0
- data/vendor/diy/test/files/donkey/foo.rb +8 -0
- data/vendor/diy/test/files/donkey/foo/bar/qux.rb +7 -0
- data/vendor/diy/test/files/fud/objects.yml +13 -0
- data/vendor/diy/test/files/fud/toy.rb +15 -0
- data/vendor/diy/test/files/gnu/objects.yml +14 -0
- data/vendor/diy/test/files/gnu/thinger.rb +8 -0
- data/vendor/diy/test/files/goat/base.rb +8 -0
- data/vendor/diy/test/files/goat/can.rb +6 -0
- data/vendor/diy/test/files/goat/goat.rb +6 -0
- data/vendor/diy/test/files/goat/objects.yml +12 -0
- data/vendor/diy/test/files/goat/paper.rb +6 -0
- data/vendor/diy/test/files/goat/plane.rb +8 -0
- data/vendor/diy/test/files/goat/shirt.rb +6 -0
- data/vendor/diy/test/files/goat/wings.rb +8 -0
- data/vendor/diy/test/files/horse/holder_thing.rb +4 -0
- data/vendor/diy/test/files/horse/objects.yml +7 -0
- data/vendor/diy/test/files/yak/core_model.rb +4 -0
- data/vendor/diy/test/files/yak/core_presenter.rb +4 -0
- data/vendor/diy/test/files/yak/core_view.rb +1 -0
- data/vendor/diy/test/files/yak/data_source.rb +1 -0
- data/vendor/diy/test/files/yak/fringe_model.rb +4 -0
- data/vendor/diy/test/files/yak/fringe_presenter.rb +4 -0
- data/vendor/diy/test/files/yak/fringe_view.rb +1 -0
- data/vendor/diy/test/files/yak/my_objects.yml +21 -0
- data/vendor/diy/test/test_helper.rb +40 -0
- data/vendor/hardmock/CHANGES +8 -0
- data/vendor/hardmock/LICENSE +7 -0
- data/vendor/hardmock/README +48 -0
- data/vendor/hardmock/Rakefile +100 -0
- data/vendor/hardmock/TODO +7 -0
- data/vendor/hardmock/config/environment.rb +12 -0
- data/vendor/hardmock/homepage/demo.rb +21 -0
- data/vendor/hardmock/homepage/hardmock_sample.png +0 -0
- data/vendor/hardmock/homepage/index.html +65 -0
- data/vendor/hardmock/init.rb +3 -0
- data/vendor/hardmock/lib/hardmock.rb +634 -0
- data/vendor/hardmock/lib/method_cleanout.rb +14 -0
- data/vendor/hardmock/rcov.rake +18 -0
- data/vendor/hardmock/test/functional/assert_error_test.rb +52 -0
- data/vendor/hardmock/test/functional/auto_verify_test.rb +192 -0
- data/vendor/hardmock/test/functional/direct_mock_usage_test.rb +396 -0
- data/vendor/hardmock/test/functional/hardmock_test.rb +380 -0
- data/vendor/hardmock/test/test_helper.rb +23 -0
- data/vendor/hardmock/test/unit/expectation_builder_test.rb +18 -0
- data/vendor/hardmock/test/unit/expector_test.rb +56 -0
- data/vendor/hardmock/test/unit/method_cleanout_test.rb +35 -0
- data/vendor/hardmock/test/unit/mock_control_test.rb +172 -0
- data/vendor/hardmock/test/unit/mock_test.rb +273 -0
- data/vendor/hardmock/test/unit/simple_expectation_test.rb +345 -0
- data/vendor/hardmock/test/unit/trapper_test.rb +60 -0
- data/vendor/hardmock/test/unit/verify_error_test.rb +34 -0
- data/vendor/systir/systir.rb +403 -0
- data/vendor/systir/test/unit/ui/xml/testrunner.rb +192 -0
- data/vendor/systir/test/unit/ui/xml/xmltestrunner.xslt +109 -0
- metadata +235 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'constructor'
|
2
|
+
|
3
|
+
class Toy
|
4
|
+
constructor :widget, :trinket, :accessors => true, :strict => true
|
5
|
+
end
|
6
|
+
|
7
|
+
class Widget
|
8
|
+
end
|
9
|
+
|
10
|
+
class ThingAmaJack
|
11
|
+
end
|
12
|
+
|
13
|
+
class Trinket
|
14
|
+
constructor :thing_ama_jack, :accessors => true, :strict => true
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class CoreView; end
|
@@ -0,0 +1 @@
|
|
1
|
+
class DataSource; end
|
@@ -0,0 +1 @@
|
|
1
|
+
class FringeView; end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
core_model:
|
3
|
+
compose: data_source
|
4
|
+
|
5
|
+
core_view:
|
6
|
+
|
7
|
+
core_presenter:
|
8
|
+
model: core_model
|
9
|
+
view: core_view
|
10
|
+
|
11
|
+
data_source:
|
12
|
+
|
13
|
+
+fringe_context:
|
14
|
+
|
15
|
+
fringe_model:
|
16
|
+
connected: core_model
|
17
|
+
|
18
|
+
fringe_view:
|
19
|
+
|
20
|
+
fringe_presenter:
|
21
|
+
compose: fringe_model, fringe_view
|
@@ -0,0 +1,40 @@
|
|
1
|
+
here = File.expand_path(File.dirname(__FILE__))
|
2
|
+
PROJ_ROOT = File.expand_path("#{here}/..")
|
3
|
+
$: << "#{PROJ_ROOT}/src"
|
4
|
+
$: << "#{PROJ_ROOT}/test"
|
5
|
+
$: << "#{PROJ_ROOT}/lib"
|
6
|
+
require 'test/unit'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'find'
|
9
|
+
require 'yaml'
|
10
|
+
require 'ostruct'
|
11
|
+
|
12
|
+
class Test::Unit::TestCase
|
13
|
+
include FileUtils
|
14
|
+
|
15
|
+
def path_to(file)
|
16
|
+
File.expand_path(File.dirname(__FILE__)) + file
|
17
|
+
end
|
18
|
+
|
19
|
+
def not_done
|
20
|
+
flunk "IMPLEMENT ME"
|
21
|
+
end
|
22
|
+
alias :implement_me :not_done
|
23
|
+
|
24
|
+
def poll(time_limit)
|
25
|
+
(time_limit * 10).to_i.times do
|
26
|
+
return true if yield
|
27
|
+
sleep 0.1
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.method_added(msym)
|
33
|
+
# Prevent duplicate test methods
|
34
|
+
if msym.to_s =~ /^test_/
|
35
|
+
@_tracked_tests ||= {}
|
36
|
+
raise "Duplicate test #{msym}" if @_tracked_tests[msym]
|
37
|
+
@_tracked_tests[msym] = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Hardmock 1.0.3
|
2
|
+
|
3
|
+
* "expects" replaces "expect" ("expect" now raises Hardmock::DeprecationError)
|
4
|
+
* "verify_mocks" is now implicit in teardown, you needn't call it anymore
|
5
|
+
* Mocking methods that Mock would otherwise inherit from Object (eg, to_s) is now possible
|
6
|
+
* require 'hardmock' is all that's required to use the library now; no need to include in TestCase
|
7
|
+
|
8
|
+
(previously called CMock, translated to Hardmock on 2006-12-10)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2006 Atomic Object, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
== Hardmock
|
2
|
+
|
3
|
+
Strict, ordered mock objects using very lightweight syntax in your tests.
|
4
|
+
|
5
|
+
|
6
|
+
== How
|
7
|
+
|
8
|
+
The basic procedure for using Hardmock in your tests is:
|
9
|
+
|
10
|
+
* require 'hardmock'
|
11
|
+
* Create some mocks
|
12
|
+
* Setup some expectations
|
13
|
+
* Execute the target code
|
14
|
+
* Verification of calls is automatic in =teardown=
|
15
|
+
|
16
|
+
The expectations you set when using mocks are <b>strict</b> and <b>ordered</b>.
|
17
|
+
Expectations you declare by creating and using mocks are all considered together.
|
18
|
+
|
19
|
+
* Hardmock::Mock#expects will show you more examples
|
20
|
+
* Hardmock::SimpleExpectation will teach you more about expectation methods
|
21
|
+
|
22
|
+
== Example
|
23
|
+
|
24
|
+
create_mocks :garage, :car
|
25
|
+
|
26
|
+
# Set some expectations
|
27
|
+
@garage.expects.open_door
|
28
|
+
@car.expects.start(:choke)
|
29
|
+
@car.expects.drive(:reverse, 5.mph)
|
30
|
+
|
31
|
+
# Execute the code (this code is usually, obviously, in your class under test)
|
32
|
+
@garage.open_door
|
33
|
+
@car.start :choke
|
34
|
+
@car.drive :reverse, 5.mph
|
35
|
+
|
36
|
+
verify_mocks # OPTIONAL, teardown will do this for you
|
37
|
+
|
38
|
+
Expects <tt>@garage.open_door</tt>, <tt>@car.start(:choke)</tt> and <tt>@car.drive(:reverse, 5.mph)</tt> to be called in that order, with those specific arguments.
|
39
|
+
* Violations of expectations, such as mis-ordered calls, calls on wrong objects, or incorrect methods result in Hardmock::ExpectationError
|
40
|
+
* <tt>verify_mocks</tt> will raise VerifyError if not all expectations have been met.
|
41
|
+
|
42
|
+
== Download and Install
|
43
|
+
|
44
|
+
* Homepage: http://hardmock.rubyforge.org
|
45
|
+
* GEM or TGZ or ZIP: http://rubyforge.org/frs/?group_id=2742
|
46
|
+
* Rails plugin: script/plugin install
|
47
|
+
* SVN access: svn co svn://rubyforge.org/var/svn/hardmock/trunk
|
48
|
+
* Developer SVN access: svn co svn://developername@rubyforge.org/var/svn/hardmock/trunk
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/contrib/sshpublisher'
|
7
|
+
load 'rcov.rake'
|
8
|
+
|
9
|
+
HARDMOCK_VERSION = "1.2.0"
|
10
|
+
|
11
|
+
task :default => [ :alltests ]
|
12
|
+
|
13
|
+
desc "Run all the tests"
|
14
|
+
Rake::TestTask.new("alltests") { |t|
|
15
|
+
t.libs << "test"
|
16
|
+
t.pattern = 'test/**/*_test.rb'
|
17
|
+
t.verbose = true
|
18
|
+
}
|
19
|
+
|
20
|
+
def add_rdoc_options(options)
|
21
|
+
options << '--line-numbers' << '--inline-source' << '--main' << 'README' << '--title' << 'Hardmock'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Generate RDoc documentation"
|
25
|
+
Rake::RDocTask.new { |rdoc|
|
26
|
+
rdoc.rdoc_dir = 'doc'
|
27
|
+
rdoc.title = "Hardmock: Strict expectation-based mock object library "
|
28
|
+
# rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' << '--main'
|
29
|
+
add_rdoc_options(rdoc.options)
|
30
|
+
rdoc.rdoc_files.include('lib/**/*.rb', 'README','CHANGES','LICENSE')
|
31
|
+
}
|
32
|
+
|
33
|
+
task :showdoc => [ :rerdoc ] do
|
34
|
+
sh "open doc/index.html"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Generate and upload api docs to rubyforge"
|
38
|
+
task :upload_doc => :rerdoc do
|
39
|
+
sh "scp -r doc/* rubyforge.org:/var/www/gforge-projects/hardmock/doc"
|
40
|
+
sh "scp -r homepage/* rubyforge.org:/var/www/gforge-projects/hardmock/"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
gem_spec = Gem::Specification.new do | s |
|
46
|
+
s.name = "hardmock"
|
47
|
+
s.version = HARDMOCK_VERSION
|
48
|
+
s.author = "David Crosby"
|
49
|
+
s.email = "crosby@atomicobject.com"
|
50
|
+
s.platform = Gem::Platform::RUBY
|
51
|
+
s.summary = "A strict, ordered, expectation-oriented mock object library."
|
52
|
+
s.rubyforge_project = 'hardmock'
|
53
|
+
s.homepage = "http://hardmock.rubyforge.org"
|
54
|
+
s.autorequire = 'hardmock'
|
55
|
+
|
56
|
+
s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*'].exclude('TODO').to_a
|
57
|
+
|
58
|
+
s.require_path = "lib"
|
59
|
+
s.test_files = Dir.glob("test/**/*test.rb")
|
60
|
+
|
61
|
+
s.has_rdoc = true
|
62
|
+
s.extra_rdoc_files = ["README","CHANGES","LICENSE"]
|
63
|
+
add_rdoc_options(s.rdoc_options)
|
64
|
+
end
|
65
|
+
|
66
|
+
Rake::GemPackageTask.new(gem_spec) do |pkg|
|
67
|
+
pkg.need_zip = true
|
68
|
+
pkg.need_tar = true
|
69
|
+
end
|
70
|
+
|
71
|
+
task :verify_svn_clean do
|
72
|
+
# Get clean
|
73
|
+
sh 'svn up'
|
74
|
+
status = `svn status`
|
75
|
+
raise "Please get checked-in and cleaned up before releasing.\n#{status}" unless status == ""
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Create a release tar.gz file."
|
79
|
+
task :release => [:verify_svn_clean, :alltests, :upload_doc, :repackage] do
|
80
|
+
require 'fileutils'
|
81
|
+
include FileUtils::Verbose
|
82
|
+
proj_root = File.expand_path(File.dirname(__FILE__))
|
83
|
+
begin
|
84
|
+
cd proj_root
|
85
|
+
|
86
|
+
|
87
|
+
# Tag the release by number, then re-tag for stable release (makes nicey nicey for Rails plugin installation)
|
88
|
+
sh "svn cp . svn+ssh://dcrosby42@rubyforge.org/var/svn/hardmock/tags/rel-#{HARDMOCK_VERSION} -m 'Releasing version #{HARDMOCK_VERSION}'"
|
89
|
+
sh "svn del svn+ssh://dcrosby42@rubyforge.org/var/svn/hardmock/tags/hardmock -m 'Preparing to update stable release tag'"
|
90
|
+
sh "svn cp . svn+ssh://dcrosby42@rubyforge.org/var/svn/hardmock/tags/hardmock -m 'Updating stable tag to version #{HARDMOCK_VERSION}'"
|
91
|
+
|
92
|
+
puts "UPLOAD #{Dir['pkg/*.*']} TO RUBYFORGE RELEASE ZONE"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
namespace :ci do
|
98
|
+
desc "Continuous integration target"
|
99
|
+
task :continuous => [ 'alltests', 'rcov:coverage' ]
|
100
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# The path to the root directory of your application.
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
ADDITIONAL_LOAD_PATHS = []
|
5
|
+
ADDITIONAL_LOAD_PATHS.concat %w(
|
6
|
+
lib
|
7
|
+
).map { |dir| "#{APP_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
8
|
+
|
9
|
+
# Prepend to $LOAD_PATH
|
10
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
11
|
+
|
12
|
+
# Require any additional libraries needed
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'hardmock'
|
2
|
+
|
3
|
+
class MyTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
create_mocks :garage, :car
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_the_mocks
|
10
|
+
# Set some expectations
|
11
|
+
@garage.expects.open_door
|
12
|
+
@car.expects.start(:choke)
|
13
|
+
@car.expects.drive(:reverse, 5.mph)
|
14
|
+
|
15
|
+
# Execute the code (normally your own classes do this)
|
16
|
+
@garage.open_door
|
17
|
+
@car.start :choke
|
18
|
+
@car.drive :reverse, 5.mph
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|