mrproper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # MrProper
1
+ # MrProper [![Build Status](https://secure.travis-ci.org/porras/mrproper.png)](http://travis-ci.org/porras/mrproper)
2
2
 
3
- MrProper is a [MiniTest](http://rubydoc.info/stdlib/minitest/1.9.2/frames)-based library to do Property Based Testing a la [Haskell](http://haskell.org/haskellwiki/Haskell)'s [QuickCheck](http://hackage.haskell.org/package/QuickCheck).
3
+ MrProper is a Test::Unit-based library to do Property Based Testing a la [Haskell](http://haskell.org/haskellwiki/Haskell)'s [QuickCheck](http://hackage.haskell.org/package/QuickCheck).
4
4
 
5
5
  Property Based Testing is an alternative approach to unit testing for testing functional style functions/methods. Instead of using examples and testing the return value of your function for each example, you:
6
6
 
@@ -24,7 +24,7 @@ In order to do so, MrProper provides a very simple DSL, with just three methods,
24
24
 
25
25
  ## Running the properties
26
26
 
27
- After implementing `double` (we'll leave that as an exercise `;)`), we run the properties as a regular MiniTest test file:
27
+ After implementing `double` (we'll leave that as an exercise `;)`), we run the properties as a regular test file:
28
28
 
29
29
  $ testrb double_properties.rb
30
30
  Run options:
@@ -92,9 +92,13 @@ In case this is not enough, you can just use a block and do whatever you want to
92
92
  rand > 0.5 ? Wadus.new(rand(9)) : FooBar.new(rand(9))
93
93
  end
94
94
 
95
- ## Todo
95
+ ## Further reading
96
96
 
97
- * Make it work in other rubies than 1.9.3
97
+ * [Slides](http://mrproper-railscamp.heroku.com/) of a quick and dirty pesentation about MrProper at [railscamp-es](https://rails-camp-es.jottit.com/) '2011. Those slides eventually became this README's first version
98
+ * [Chapter](http://book.realworldhaskell.org/read/testing-and-quality-assurance.html) of the book *“Real World Haskell”* talking about QuickCheck
99
+ * [RushCheck](https://github.com/IKEGAMIDaisuke/rushcheck), an old (and apparently abandoned) implementation of this idea in Ruby
100
+ * [rqc](https://github.com/seancribbs/rqc), a Ruby port of [QC.js](http://willowbend.cx/2009/12/05/qc-js-quickcheck-javascript/) (a property-based testing framework in Javascript)
101
+ * [ProTest](http://www.protest-project.eu/index.html), another implementation in Erlang
98
102
 
99
103
  ## License
100
104
 
data/lib/mrproper.rb CHANGED
@@ -1,6 +1,7 @@
1
- require 'minitest/autorun'
1
+ require 'test/unit'
2
2
  require 'mrproper/base'
3
3
  require 'mrproper/dsl'
4
+ require 'mrproper/errors'
4
5
  require 'mrproper/core_extensions/string_extensions'
5
6
 
6
7
  include MrProper
data/lib/mrproper/base.rb CHANGED
@@ -3,8 +3,8 @@ module MrProper
3
3
  def properties(name, &block)
4
4
  dsl = MrProper::DSL.new
5
5
  dsl.instance_eval(&block)
6
- Class.new(MiniTest::Unit::TestCase).class_eval do
7
- include PropertiesHelper if const_defined?(:PropertiesHelper)
6
+ Class.new(Test::Unit::TestCase).class_eval do
7
+ eval("def self.name; #{name.inspect}; end")
8
8
  dsl.properties.each do |message, test_block|
9
9
  define_method "test_property: #{message.inspect}" do
10
10
  dsl.data_blocks.each do |data_block|
@@ -12,8 +12,8 @@ module MrProper
12
12
  data = data_block.call
13
13
  begin
14
14
  instance_exec(data, &test_block)
15
- rescue MiniTest::Assertion => e
16
- raise MiniTest::Assertion.new("Property #{message.inspect} is falsable for data #{data.inspect}\n#{e.message}")
15
+ rescue Test::Unit::AssertionFailedError, MiniTest::Assertion => e
16
+ raise FalsableProperty.new("Property #{message.inspect} is falsable for data #{data.inspect}\n#{e.message}")
17
17
  end
18
18
  end
19
19
  end
data/lib/mrproper/dsl.rb CHANGED
@@ -29,7 +29,7 @@ module MrProper
29
29
  if spec.size == 1
30
30
  Proc.new { rand(20).times.map { data_block(spec.first).call } }
31
31
  else
32
- Proc.new { spec.map { |spec| data_block(spec).call }}
32
+ Proc.new { spec.map { |s| data_block(s).call }}
33
33
  end
34
34
  when Hash
35
35
  Proc.new do
@@ -0,0 +1,13 @@
1
+ module MrProper
2
+ class FalsableProperty < Exception; end
3
+ end
4
+
5
+ unless Test::Unit.const_defined?('AssertionFailedError')
6
+ class Test::Unit::AssertionFailedError < Exception; end
7
+ end
8
+
9
+ unless Object.const_defined?('MiniTest')
10
+ module MiniTest
11
+ class Assertion < Exception; end
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrproper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-06 00:00:00.000000000 Z
13
+ date: 2011-11-09 00:00:00.000000000Z
14
14
  dependencies: []
15
15
  description:
16
16
  email: sgilperez@gmail.com
@@ -23,6 +23,7 @@ files:
23
23
  - lib/mrproper/base.rb
24
24
  - lib/mrproper/core_extensions/string_extensions.rb
25
25
  - lib/mrproper/dsl.rb
26
+ - lib/mrproper/errors.rb
26
27
  - lib/mrproper.rb
27
28
  homepage: http://github.com/porras/mrproper
28
29
  licenses: []