okitan / capybara-json

60 stars 23 forks source link

Well this is sort of awkward #2

Closed jnicklas closed 12 years ago

jnicklas commented 12 years ago

So this is kind of my Jon Stewart on Crossfire moment. I don't mean to offend you, but I feel that the premise of this gem is fundamentally flawed. You're basically (badly) replicating the functionality of RackTest, by going through a private undocumented Capybara API. Not only is this going to break in the future, but there's also not really a point to doing this, when you could just use RackTest directly.

I've seen people make this mistake a lot, so you're definitely not alone in this. I've blogged about it here: http://elabs.se/blog/34-capybara-and-testing-apis

Again, I really hope you don't take this personally. And I apologize for voicing this in a public forum, but there doesn't seem to be an email address on your GitHub profile.

(I previously sent this from my employer's GitHub account by accident, I want to stress that this is my opinion, and not my employer's)

okitan commented 12 years ago

Jonas,

Thank you for advising me.

I know that Capybara is aimed to test user behavior, not to test APIs. And that's why I develop capybara-json instad of requesting such functionalities or making a pull request to capybara.

I totally apologize my bad (but easy) implementation of using capybara's hidden APIs. I understand it may break in the future. I think I should stop using Capybara::RackTest::Driver and use Rack::Test directly.

In your blog post, you said "Do not test APIs with Capybara". But I'd like to continue using capybara from my capybara-json. Because when I stop using Capybara, I should design the same function of it: driver interface, rack app booting, and so on. This is the kind of reinventing the wheel.

If you don't like using the name of Capybara for the tool of testing APIs, I should rename capybara-json.

Thanks,

jnicklas commented 12 years ago

The thing is, all that extra functionality that Capybara provides, you don't really need it. If you're testing Rack apps, you don't need to start a server, if you're testing something that isn't a Rack app, Capybara doesn't help you in starting it, and your library doesn't help in testing it. All the other stuff which is in Capybara is specific to testing HTML pages, not APIs.

Your library pretty much replicates the functionality which is already in RackTest, so I'd suggest you take a look at RackTest and try to use that instead. It's quite a nice library.

okitan commented 12 years ago

I also know rack-test is pretty good. But I think rack-test is not enough for integration test.

capybara-json has two drivers. One is rack_test_json driver, another is httpclient_json driver. If I only have rack_test_json driver, your suggestion is pretty reasonable. I also think rack_test will satisfy it.

But for integration test, especially using some middleware in front of a rack app, rack-test is not a appropriate solution. I'd like to provide the same interface between two drivers above.

I think capybara-json does not potentially need Capybara, but it is reinventing the wheel.

patrickberkeley commented 12 years ago

@okitan not to be rude, but please take this repo down or make it private. Until reading @jnicklas's comments I was on my way to using it.