Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EPDQ::Client #3

Merged
merged 1 commit into from
May 26, 2016
Merged

Add EPDQ::Client #3

merged 1 commit into from
May 26, 2016

Conversation

andypearson
Copy link

EPDQ configuration no longer relies on class variables, hooray!

@alkesh
Copy link

alkesh commented May 26, 2016

would it be better to have it so that you do:

client.request

instead of

EPDQ::Request.new

or is that too big of a refactor?

@andypearson
Copy link
Author

@alkesh I did that already! You can do it both ways (below is an example of they way you would like). I would make Request and Response classes private if I could, they are an implementation detail now :)

class ClientTest < Test::Unit::TestCase
  # ...snip...

  test "can create a request" do
    client = EPDQ::Client.new(
      pspid: "MYPSPID",
      sha_in: "MYSHAIN",
      sha_out: "MYSHAOUT"
    )

    EPDQ::Request.expects(:new).with(client, param: 1).returns(:result)
    assert_equal :result, client.request(param: 1)
  end

  test "can create a response" do
    client = EPDQ::Client.new(
      pspid: "MYPSPID",
      sha_in: "MYSHAIN",
      sha_out: "MYSHAOUT"
    )

    EPDQ::Response.expects(:new).with(client, "query_string").returns(:result)
    assert_equal :result, client.response("query_string")
  end
end

@alkesh
Copy link

alkesh commented May 26, 2016

neat – it's practically perfect 👍

@andypearson andypearson merged commit a225e03 into master May 26, 2016
@andypearson
Copy link
Author

Merged!

@andypearson andypearson deleted the ajp/refactor-to-add-client branch May 26, 2016 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants