Populating Mock self.data

Skip to first unread message

Dave Johnston

Apr 25, 2016, 9:47:12 AM4/25/16
to ruby-fog

I've been trying to write some tests for code that uses the Fog::Orchestration::Openstack class.

I call a request method called 'list_resources'.  The Mock for this request looks like this:
class Mock
    def list_resources(options = {}, options_deprecated = {})
        resources = self.data[:resources].values

          :body   => { 'resources' => resources },
          :status => 200

The tests fail because self.data[:resources] is nil.  Does the Fog mock framework provide a mechanism to populate the 'data' hash prior to executing the test?

geemus (Wesley Beary)

Apr 25, 2016, 10:06:53 AM4/25/16
to ruby...@googlegroups.com
I haven't used the openstack side of things in particular much, but the general pattern in fog is to use the create methods to populate the mocks. So if you have mock on and create some resources, then call list_resources, they should be included. Hope that helps, but if not somebody with more specific knowledge around this may be able to chime in.

You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
0 new messages