-
Notifications
You must be signed in to change notification settings - Fork 10
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
No support for subdomains #31
Comments
Thanks. I'll try to look at it this weekend. |
This doesn't seem to be a free standing test. It's got a minor syntax error which is easy to fix, but I'm not sure the context is should be placed in. Did you have one? |
I just noticed the 'require "test_helper"'. You should be able to remove that. It's an integration test. So if you put in test/integration and run a rake test:integration it should run right? |
Nope. It's giving me some kind of error on uninitialized constant ActionController. I'm not really that familiar with rails integration tests (I use rspec) so if you could throw together whatever it wants ... |
OK, I created a very simple app that illustrates the problem: http://github.com/iamnader/envjs-subdomain-example From the README: This is a very simple app that illustrates this bug in capybara-envjs: http://github.com/smparkes/capybara-envjs/issues#issue/31 Should be very straightforward to run, directions below from the README. Let me know if you have any issues. == Getting Started
|
Thanks. I appreciate the effort. I'll look at it in the morning (I already spent as much time as I can for today tracking down an envjs bug that surfaced with the newest capy changes). |
Okay. I've tweaked things. First, as far as I can tell, your test isn't testing envjs, it's testing rack::test. I tweaked it and pushed to http://github.com/smparkes/envjs-subdomain-example. Next, you have to set default_host if you want to use rack test. I'm not 100% sure if that's what you wanted. Did you want this to run a server like it does with selenium, or run within envjs? I kinda assumed the later. Was I wrong? At this point, the envjs driver won't start a server like the selenium server does. It's possible, but I haven't needed it. It's come up once, that I'm aware of. Next, I fixed envjs so it will actually do this. Before, it wasn't allowing default_host and app_host to be changed on the fly. I guess that's okay ... Fixed in master (which requires capy master) Finally, rack-test does not support port numbers, as far as I can tell. envjs passes them on happily, but rack test will barf on them. That would be a rack-test issue ... |
Excellent. I was actually testing envjs, it was just set as the default driver in the test_helper file. I would prefer to always use it, I only use Selenium right now for subdomain tests because of the limitation. Yes, you're correct I don't want to run a server, just envjs. So I want to take your updated version of my sample app, and point it at capy_envjs master to use your latest code and see if the test passes. But it looks like the capybara-envjs github repo doesn't have a Gemfile. How would you recommend I use the version on master? Install it as a plugin? Adding this to my Gemfile: gives me this error: |
I thought you were probably testing envjs ... seemed like you'd notice the difference. Do you need the port in there? It didn't look like it'd be too terribly hard to hack rack::test to support ports. You'll need to point at both capy_envjs master and capy master: I try to make capy_envjs master track capy and there are a number of unreleased changes in capy that capy_envjs is tied to. I usually just download the repo, build the gem, and install it (which means I need to pre-bump the version in the repo, which I haven't done yet). I've heard that you should just be able to point bundler at a git clone and it should work? |
OK, I pre-bumped the version # to 0.1.7, and installed the gem. My gemfile: source 'http://rubygems.org' Rails essentialsgem 'rails', '3.0.0.rc' Testinggroup :test do Everything else is the same and I'm getting a new exception when running the test. E
1 tests, 0 assertions, 0 failures, 1 errors Is it working for you? |
No, that's what I got, too. But, then, I don't actually see that id anywhere in the document. Did I miss something? |
If you comment out the default_host line you added the test at least finishes, but the assert fails. However, the selenium version that previously passed now fails, because it requires the port. Can you update the sample app so that the test passes? Or am I missing something? I thought you said that subdomains were now supported in the version of capy-envjs on master? |
Don't know what this means. Do you mean the Johnson error? Have you actually tried loading that page in a browser and looked a the Javascript console? You get the same error. So I think capy-envjs is doing the right thing ... ... as long as you add default_host == app_host without http:// and without a port. If you're adding the port simply because you can't bind to port 80, then you can just leave the port off when testing. If you need port support, somebody needs to add it to Rack::Test. This isn't a limitation of capy or capy-envjs, it's something rack test doesn't support, which both capy and capy-envjs use. |
You were right about the Johnson error. Weird thing is the rails generator creates that. So the good news is I got basic subdomain support working with envjs! The bad news is it looks like it only works once per test. So for example if at the beginning of my test I set the default and app hosts they are set correctly and the navigation goes to the subdomains. If half way through a test I want to go to a different subdomain and I change the app_host and default_host values they don't take and requests still go to the first subdomain. Any thoughts on how to handle that? Thanks for the effort on this. envjs is SO much more convenient than Selenium |
Yeah, I didn't look at it at first for that reason, as well. Are you saying you're hitting visit("/foo") and the changing values? I guess I'm not sure what should happen. Maybe that should work. If you're trying to hit a link on a page and have it go to a different url, I don't see that ever working: the page knows where it was loaded from and hacking that seems like a bad idea: to un-browser-like. Doing more than one visit in a test, I'm not sure about. Is that what you're doing? Do you have an example? |
Yep, I'm doing more than one visit. Just set the default and app hosts, visit a page, check the url. All good. Set the default and app to a different subdomain, visit a page, the url is still set to the original. My test is checking that actions I do on one subdomain, don't show up on another. |
If you want to push a test somewhere, I can look at it, and either make it work or tell you why it can't. |
Hi, it's hard to bundle a test using your latest because I can't reference your head from bundler. But if you take the same test from here: http://github.com/smparkes/envjs-subdomain-example/blob/master/test/integration/subdomain_test.rb And just do two visits like this:
|
I'll give it a shot ... |
Hmm ... works for me? I've updated my version of the example. Am I testing it wrong? Jonas says a new version of the capy should be out soon ... (though it sounds like I'm not the only one backed up ...) |
Sorry, I just got around to testing this. Unfortunately I can't get your test to pass. The version in rubygems doesn't work. If I build a new gem from your master using the capybara rubygem I get an XHR can't connect error. If I use your master and the capy master I get this error: Capybara::DriverNotFoundError: no driver called :envjs was found, available drivers: :culerity, :celerity, :rack_test, :selenium And this is all basically moot as I can't deploy your master as it isn't bundle friendly (vendoring doesn't work). So I guess I'm back to Selenium til there are new official envjs/capy gem versions Thanks |
I'll try to get the gemspec stuff fixed ... |
Jonas did the hoe->bundler conversion so you should be able to use the git repo as a gem. |
Has this been addressed yet? I'm having issues with getting this to work. |
Last I checked, it worked. Do you have a failing example? |
I finally got it working. I had to tweak my settings before I finally got it right. |
I'm having an issue with subdomains too. When I switch the subdomain in one test, then switch it again in another test, then again in another test, in every test after the first, rails still thinks its on the first subdomain. I've created a sample app too with failing tests using rspec and steak. This test fails: https://github.com/snelson/capybara-envjs-steak-subdomain-example/blob/master/spec/acceptance/subdomains_spec.rb I also can't get iamnader's example to pass. Any advice would be much appreciated. Thanks |
I was able to find a workaround for this by using multiple sessions, and opening a new session when the subdomain is switched. I wouldn't consider this a fix though as I think there should be able to do this within one session, like if to test domain-wide authentication. This may not even be a capybara-envjs issue, it might be a capybara issue. The workaround can be found here: snelson/capybara-envjs-steak-subdomain-example@3dc26a0 I came to this workaround when reading about a similar problem and solution at: http://www.automation-excellence.com/blog/racking-my-brains What's strange about his issue is that it seemed to be reverse, where selenium was working and rack test wasn't. I'd love to help get a fix into either capybara-envjs or capybara, so any insight would be much appreciated, as the code is all still pretty unfamiliar to me. |
I've always had a hard time keeping track of this. If you look at the capy google group, you'll find a few threads about it. I don't use it, so I've tried to make it work now and again, but either I've never gotten it to work quite right or it gets broken again. I'm not entirely sure Jonas thinks it should be supported. I seem to remember him saying that mucking with .default_host/.app_host was evil. |
Jonas says in a number of places to use visit('http://subdomain.example.com'), that is, a FQDN, to switch the domain name, one of those places is here: That doesn't work either though. I've modified the test on another branch to show it using the default driver. I'll setup an issue with Capybara and post the url here. Thanks for getting back, and thanks for all the work you've put into the envjs driver, we owe you big time. |
I've started a pull request with capybara so that we can use visit() to switch the subdomain and have it persist across subsequent requests. We'll see what happens with that. I'll follow up here. |
Thanks! |
Looks like its already in the works, hopefully we'll see it soon. |
Cool. Let me know how it falls out. Depending on what the changes are, they might require driver changes. |
Absolutely, will do. |
Details described in this thread: http://groups.google.com/group/ruby-capybara/browse_thread/thread/69e85fa4bbc40cb1
Here is a simple test that passes using selenium, but fails using envjs: http://gist.github.com/551764
Thanks
The text was updated successfully, but these errors were encountered: