{"action":"created","issue":{"url":"https://api.github.com/repos/ashfurrow/Moya/issues/56","labels_url":"https://api.github.com/repos/ashfurrow/Moya/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/ashfurrow/Moya/issues/56/comments","events_url":"https://api.github.com/repos/ashfurrow/Moya/issues/56/events","html_url":"https://github.com/ashfurrow/Moya/issues/56","id":43881239,"number":56,"title":"Inline testing providers ","user":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ashfurrow/Moya/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ashfurrow/Moya/milestones/2","html_url":"https://github.com/ashfurrow/Moya/milestones/Long%20Term","labels_url":"https://api.github.com/repos/ashfurrow/Moya/milestones/2/labels","id":873021,"number":2,"title":"Long Term","description":"","creator":{"login":"ashfurrow","id":498212,"avatar_url":"https://avatars.githubusercontent.com/u/498212?v=3","gravatar_id":"","url":"https://api.github.com/users/ashfurrow","html_url":"https://github.com/ashfurrow","followers_url":"https://api.github.com/users/ashfurrow/followers","following_url":"https://api.github.com/users/ashfurrow/following{/other_user}","gists_url":"https://api.github.com/users/ashfurrow/gists{/gist_id}","starred_url":"https://api.github.com/users/ashfurrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashfurrow/subscriptions","organizations_url":"https://api.github.com/users/ashfurrow/orgs","repos_url":"https://api.github.com/users/ashfurrow/repos","events_url":"https://api.github.com/users/ashfurrow/events{/privacy}","received_events_url":"https://api.github.com/users/ashfurrow/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":1,"state":"open","created_at":"2014-11-19T16:42:58Z","updated_at":"2015-06-07T23:02:55Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2014-09-25T07:54:12Z","updated_at":"2015-06-16T16:31:43Z","closed_at":null,"body":"right now a test suite doing some networking looks like:\r\n\r\n``` swift\r\n    beforeSuite { () -> () in\r\n        // Force provider to stub responses\r\n        APIKeys.sharedKeys = APIKeys(key: \"\", secret: \"\")\r\n        Provider.sharedProvider = Provider.StubbingProvider()\r\n    }\r\n    \r\n    afterSuite { () -> () in\r\n        // Reset provider\r\n        APIKeys.sharedKeys = APIKeys()\r\n        Provider.sharedProvider = Provider.DefaultProvider()\r\n    }\r\n    \r\n    it(\"returns some data\") {\r\n        setDefaultsKeys(nil, nil)\r\n        \r\n        var called = false\r\n        XAppRequest(.Auctions).subscribeNext({ (object) -> Void in\r\n            called = true\r\n        })\r\n        \r\n        expect(called).to(beTruthy())\r\n    }\r\n    \r\n    ... etc\r\n```\r\n\r\nThis is fine, and it goes and access pre-rendered stubs etc. I'd like some choice, and to allow making something like this (excusing broken syntax):\r\n\r\n``` swift\r\n  let networkProvider = Provider.runtimeProvider()\r\n  beforeSuite { () -> () in\r\n      Provider.sharedProvider = networkProvider\r\n  }\r\n\r\n  afterSuite { () -> () in\r\n      Provider.sharedProvider = Provider.DefaultProvider()\r\n  }\r\n\r\n  it(\"returns some data\") {\r\n      \r\n      var called = false\r\n      \r\n      networkProvider.responseString(.Auctions) {\r\n        return \"{ 'foo':'bar' }\"\r\n      }\r\n\r\n      XAppRequest(.Auctions).subscribeNext({ (object) -> Void in\r\n          called = true\r\n      })\r\n      \r\n      expect(called).to(beTruthy())\r\n  }\r\n\r\n\r\n```\r\n\r\nwith maybe the potential of returning strings, json objects and data?"},"comment":{"url":"https://api.github.com/repos/ashfurrow/Moya/issues/comments/112489458","html_url":"https://github.com/ashfurrow/Moya/issues/56#issuecomment-112489458","issue_url":"https://api.github.com/repos/ashfurrow/Moya/issues/56","id":112489458,"user":{"login":"ashfurrow","id":498212,"avatar_url":"https://avatars.githubusercontent.com/u/498212?v=3","gravatar_id":"","url":"https://api.github.com/users/ashfurrow","html_url":"https://github.com/ashfurrow","followers_url":"https://api.github.com/users/ashfurrow/followers","following_url":"https://api.github.com/users/ashfurrow/following{/other_user}","gists_url":"https://api.github.com/users/ashfurrow/gists{/gist_id}","starred_url":"https://api.github.com/users/ashfurrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashfurrow/subscriptions","organizations_url":"https://api.github.com/users/ashfurrow/orgs","repos_url":"https://api.github.com/users/ashfurrow/repos","events_url":"https://api.github.com/users/ashfurrow/events{/privacy}","received_events_url":"https://api.github.com/users/ashfurrow/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T16:31:43Z","updated_at":"2015-06-16T16:31:43Z","body":"I'm thinking that the stubbed responses would be used for any request matching that `Api` enum. This makes sense to me as a simple use case, which is what this would provide. \r\n\r\nIt's already possible to create this behaviour using custom endpoint resolvers that are passed into the `MoyaProvider` initializer. What this feature would do, in my mind, would let you have a sort of shorthand for this where only one or two requests need to be stubbed differently, for a specific test case. \r\n\r\nDoes that make sense? So something like you have would work-ish, but the behaviour would be more consistent with the default Moya stubbing behaviour. "}}