From f924d7d87689bf83d3b297abbaf4ce577bf23eb8 Mon Sep 17 00:00:00 2001 From: 7rans Date: Mon, 18 Jun 2012 19:21:32 -0400 Subject: [PATCH] Add alias mustnt and optional will syntax. --- lib/fluidity/must.rb | 6 +++++- lib/fluidity/will.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 lib/fluidity/will.rb diff --git a/lib/fluidity/must.rb b/lib/fluidity/must.rb index 5baa14e..300226a 100644 --- a/lib/fluidity/must.rb +++ b/lib/fluidity/must.rb @@ -28,7 +28,11 @@ def must_not(matcher=nil) end end - alias_method :musnt, :must_not + # Contraction do must not. + # + # 10.mustnt.be.kind_of?(Integer) + # + alias_method :mustnt, :must_not end diff --git a/lib/fluidity/will.rb b/lib/fluidity/will.rb new file mode 100644 index 0000000..d6712c3 --- /dev/null +++ b/lib/fluidity/will.rb @@ -0,0 +1,36 @@ +require 'fluidity/grammer' + +class Object #BasicObject + + # Use `will` nomenclature for assertions. + # + # 10.will.be.kind_of(Integer) + # + def will(matcher=nil) + if matcher + matcher =~ self + else + ::Fluidity::Grammer::Must.new(self) + end + end + + # Also, `will_not` nomenclature for assertions. + # + # 10.will_not.be.kind_of?(Integer) + # + def must_not(matcher=nil) + if matcher + matcher !~ self + else + ::Fluidity::Grammer::Must.new(self, true) + end + end + + # Contraction of will not. + # + # 10.wont.be.kind_of?(Integer) + # + alias_method :wont, :will_not + +end +