Populating Mock self.data

8 views
Skip to first unread message

Dave Johnston

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

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

        Excon::Response.new(
          :body   => { 'resources' => resources },
          :status => 200
        )
    end
end


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)

unread,
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
Forward
0 new messages