test/script_test.rb in cuco-0.0.7 vs test/script_test.rb in cuco-0.1.0

- old
+ new

@@ -1,53 +1,29 @@ require "test_helper" -require "script" describe Script do - let(:script) { Script.new } - - it "checks script instance" do + it "checks script" do + script = Script.new "" assert script.instance_of?(Script) - assert script.respond_to?(:__rules) + assert_equal %i[watch __rules].sort, script.public_methods(false).sort end it "has no watcher" do - script.load "n = 123" + script = Script.new "n = 123" assert_equal 0, script.__rules.size end it "has one watcher" do - script.load "n = 456; watch('.rb') { }" + script = Script.new "n = 456; watch('.rb') { }" assert_equal 1, script.__rules.size end it "calls a watcher" do pattern = '\.rb' value = 123 - # script.load "n = value; watch(pattern) { n }" # WHAT?? - script.load "n = #{value}; watch('#{pattern}') { n }" + script = Script.new "n = #{value}; watch('#{pattern}') { n }" rule = script.__rules.last assert_equal [pattern, value], [rule.pattern, rule.proc.call] - end - - it "receives a matchdata" do - script.load "watch('ab(.)') { |m| [m[0], m[1]] }" - - rule = script.__rules.last - assert_equal ["abc", "c"], script.match_run(rule, "abc") - end - - it "run" do - pattern = '.*\.rb' - script.load "watch('#{pattern}') { raise IOError }" - - assert_raises(IOError) { script.run "a.rb" } - end - - it "does not run" do - pattern = '.*\.rb' - script.load "watch('#{pattern}') { raise IOError }" - - script.run "a.no" # no exception end end