On Wed, Jan 23, 2013 at 9:35 PM, John Julien <[email protected]> wrote: > I'm trying to write a test case that expects an array to come back from a > function and I want to make sure at least 2 elements exist > "/usr/sbin/usermod" and "-e" > > My code is: > provider.expects(:execute).with(includes('/usr/sbin/usermod'), > includes('-e'))
That isn't valid syntax, and I can't even quite guess what you are trying to do: Calling `.with` using arguments means "expect the function to be invoked with *exactly* these arguments". If you want to check only the first two, you need to use the block version instead. You are also calling the top level `include` function there, which is unlikely to work. You can only invoke matchers after a `.should` or equivalent is applied to them. That also doesn't seem to be testing what you say you are testing: you said you wanted to test "an array to come back from a function", but your example is testing the arguments that a function is called with. Generally speaking, the former is a much better test. Testing what the function returns is often much less tied to the implementation details than testing how a different function is called (presumably with the results of your own function.) -- Daniel Pittman ⎋ Puppet Labs Developer – http://puppetlabs.com ♲ Made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-dev?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
