test/resource_set_test.rb in ray-0.1.0.pre1 vs test/resource_set_test.rb in ray-0.1.0
- old
+ new
@@ -25,14 +25,10 @@
asserts "uses the missing_pattern method when a string isn't matched" do
topic["Hello world"] == ["Hello world"]
end
- asserts("using it with another arguments") {
- topic["foo", 3]
- }.raises(ArgumentError)
-
asserts "can select objects from cache" do
first, sec = topic["string:first"], topic["string:sec"]
topic.select! { |key, val| key == "string:first" }
first.equal?(topic["string:first"]) && !sec.equal?(topic["string:sec"])
@@ -42,58 +38,25 @@
first, sec = topic["string:first"], topic["string:sec"]
topic.reject! { |key, val| key == "string:first" }
!first.equal?(topic["string:first"]) && sec.equal?(topic["string:sec"])
end
+
+ asserts "can clear the cache" do
+ old = topic["string:first"]
+ topic.clear
+
+ !(old.equal? topic["string:first"])
+ end
end
context "a resource set without missing_pattern" do
setup do
Module.new { extend Ray::ResourceSet }
end
asserts("using an unmatched string") {
topic["anything"]
- }.raises(Ray::NoPatternError)
-end
-
-context "a resource set with more arugments" do
- setup do
- Module.new do
- extend Ray::ResourceSet
-
- need_argument_count 1
-
- def self.missing_pattern(*args)
- args
- end
-
- add_set(/^string:(.+)$/) do |str, times|
- str * times
- end
- end
- end
-
- denies("using it with more arguments") {
- topic["string:foo", 3]
- }.raises(StandardError)
-
- asserts "provides user arguments after captures" do
- res = []
-
- topic.add_set(/my_(.)/) do |char, times|
- res << char
- res << times
-
- true
- end
-
- topic["my_a", 3]
- res == ["a", 3]
- end
-
- asserts "passes all the arguments to missing_pattern" do
- topic["a", 3] == ["a", 3]
- end
+ }.raises_kind_of Ray::NoPatternError
end
run_tests if __FILE__ == $0