spec/tests/Ask.rb in Checked-1.2.3 vs spec/tests/Ask.rb in Checked-2.0.0
- old
+ new
@@ -4,40 +4,46 @@
# ============================ ARRAYS
# ============================
describe "array! :include?" do
+ behaves_like :racked_dsl
+
it "returns true if array contains element." do
- BOX.array!([:a]).include?(:a)
+ Array!([:a]).include?(:a)
.should.be == true
end
it "returns false if array does not contain element" do
- BOX.array!([:a]).include?(:b)
+ Array!([:a]).include?(:b)
.should.be == false
end
end # === describe Ask :includes
describe "array! :exclude?" do
+ behaves_like :racked_dsl
+
it "returns true if array excludes element." do
- BOX.array!([:a]).exclude?(:b)
+ Array!([:a]).exclude?(:b)
.should.be == true
end
it "returns false if array does contains element" do
- BOX.array!([:a]).exclude?(:a)
+ Array!([:a]).exclude?(:a)
.should.be == false
end
end # === describe Ask :exclude
describe "array! symbols?" do
+ behaves_like :racked_dsl
+
it 'returns true if all elements are symbols' do
- BOX.array!([:a, :b]).symbols?
+ Array!([:a, :b]).symbols?
.should.be == true
end
end # === describe array! symbols?
#
@@ -63,69 +69,54 @@
# ============================
# ============================ STRINGS
# ============================
-describe "string! :include?" do
-
- it "returns true if string contains regexp." do
- BOX.string!(": a").include?(/: a/)
- .should.be == true
- end
-
- it "returns false if string does not element" do
- BOX.string!(" :a ").include?(/ :b /)
- .should.be == false
- end
-
-end # === describe Ask :includes
-describe "string! :exclude?" do
+# ============================
+# ============================ VARS
+# ============================
+
+describe "Var! :respond_to_all?" do
- it "returns true if string excludes regexp." do
- BOX.string!(": a").exclude?(/: b/)
- .should.be == true
- end
+ behaves_like :racked_dsl
- it "returns false if string does not excludes element" do
- BOX.string!(" :a ").exclude?(/ :a /)
- .should.be == false
+ it 'returns true if it responds to methods' do
+ Var!( [] ).respond_to_all?(:[], :to_s, :pop)
+ .should == true
end
-end # === describe Ask :excludes
-
-
-describe "ask empty?" do
-
- it "returns true if string is :empty? after applying :strip" do
- BOX.string!(" \n ").empty?.should.be === true
+ it 'returns false if it does not to at least one method' do
+ Var!( [] ).respond_to_all?(:[], :to_s, :keys)
+ .should == false
end
- it "returns false if string is not :empty? after applying :strip" do
- BOX.string!(" n ").empty?.should.be === false
+ it 'raises Demand::Failed if arg list is empty' do
+ lambda{ Var!( [] ).respond_to_all? }
+ .should.raise(Checked::Demand::Failed)
+ .message.should.match %r!can't be empty!
end
-
-end # === describe Ask Strings
+end # === describe var! :respond_to?
-# ============================
-# ============================ VARS
-# ============================
-describe "var! :respond_to?" do
+describe "Var! :respond_to_any?" do
- it 'returns true if it responds to methods' do
- BOX.var!( [] ).respond_to?(:[], :to_s, :pop)
+ behaves_like :racked_dsl
+
+ it 'returns true if it responds to any methods' do
+ Var!( [] ).respond_to_any?(:[], :jetsons, :jump_it)
.should == true
end
- it 'returns false if it does not to at least one method' do
- BOX.var!( [] ).respond_to?(:[], :to_s, :keys)
+ it 'returns false if it does not respond to all methods' do
+ Var!( [] ).respond_to_any?(:jetson, :to_flintstones, :thundar)
.should == false
end
- it 'returns false if arg list is empty' do
- BOX.var!( [] ).respond_to?
- .should == false
+ it 'raises Demand::Failed if arg list is empty' do
+ lambda{ Var!( [] ).respond_to_any? }
+ .should.raise(Checked::Demand::Failed)
+ .message.should.match %r!can't be empty!
end
end # === describe var! :respond_to?