From: Martin Hansen Date: 2010-05-12T23:11:49+09:00 Subject: Re: Unit Test of method calling system() - how? Aha! Great! This seems to work great: test "Options.parse with --help in argv and existing wiki output long usage" do opt_parser = Options.new opt_parser.expects(:print_usage_and_exit).with(true) assert_nil( opt_parser.parse(["--help"],SCRIPT_PATH) ) end (Probably the assertion should be something more sane) Thanks Brian, much appreciated! Martin Brian Candler wrote: > he error is pretty clear when you break it down. > >> optparse_swapcase_seq_test.rb:183:in `block in ']: >> unexpected invocation: #.print_usage_and_exit(true) > > "You called print_usage_and_exit(true), and I wasn't expecting that" > >> unsatisfied expectations: >> - expected exactly once, not yet invoked: >> #.print_usage_and_exit(:full) > > "I was expecting you to call print_usage_and_exit(:full), and you never > did" > > So the expectation you set (that the method would be called with > argument ':full') doesn't match the reality (that your code calls the > method with argument 'true') -- Posted via http://www.ruby-forum.com/.