spec/spec_helper.rb in flexmls_api-0.3.6 vs spec/spec_helper.rb in flexmls_api-0.4.5
- old
+ new
@@ -34,15 +34,29 @@
def mock_session()
FlexmlsApi::Authentication::Session.new("AuthToken" => "1234", "Expires" => (Time.now + 3600).to_s, "Roles" => "['idx']")
end
+def mock_oauth_session()
+ FlexmlsApi::Authentication::OAuthSession.new("access_token" => "1234", "expires_in" => 3600, "scope" => nil, "refresh_token"=> "1000refresh")
+end
class MockClient < FlexmlsApi::Client
- attr_accessor :connection, :session
+ attr_accessor :connection
+
+ def connection(ssl = false)
+ @connection
+ end
end
+class MockApiAuthenticator < FlexmlsApi::Authentication::ApiAuth
+ # Sign a request
+ def sign(sig)
+ "SignedToken"
+ end
+end
+
def mock_client(stubs)
c = MockClient.new
c.session = mock_session()
c.connection = test_connection(stubs)
c
@@ -58,21 +72,24 @@
builder.use Faraday::Response::ParseJson
builder.use FlexmlsApi::FaradayExt::FlexmlsMiddleware
end
end
-
def stub_auth_request()
stub_request(:post, "https://api.flexmls.com/#{FlexmlsApi.version}/session").
with(:query => {:ApiKey => "", :ApiSig => "806737984ab19be2fd08ba36030549ac"}).
to_return(:body => fixture("session.json"))
end
-
-
-
def fixture(file)
File.new(File.expand_path("../fixtures", __FILE__) + '/' + file)
end
+def reset_config()
+ FlexmlsApi.reset
+ FlexmlsApi.configure do |config|
+ config.api_user = "foobar"
+ end
+end
+reset_config
include FlexmlsApi::Models