Rails test offline application - ruby-on-rails

Does anyone know how to test offline part of the application using cucumber or jasmine?
Currently our team is developing application using backbonejs,localStorage,backbone-queues libraries for making possible for users to work offline in the modern browsers and syncing data through ajax requests.
But we need to test our application using user scenarios like cucumber steps because we need to clarify all our development steps with our customer.
We got the next following issue with cucumber/capybara-webkit gem. it doesn't support html5 features like localStorage(ok, we made fork of one guy from github and merged it with the latest sources of capybara-webkit). but we got another problem. How to simulate reopen/close browser actions or how to clean localStorage for each scenario. now scenarios are using the same localStorage.
May be someone has experience in such of testing applications.
Thanks in advance!

You should be able to clear the local storage by calling:
Capybara.current_session.driver.execute_script("localStorage.setItem('YOUR_KEY', '{}')")

Related

Using rails with phonegap

I have a fully functional rails app but, I want to create a mobile version using Phonegap. I've got Phonegap and Xcode set up but, I'm not quite sure how to go about it.
I want the mobile version to pull from the same database as the web version.
What technology can I use to achieve this?
Thanks,
Ramario
You should probably expose your database through a REST API abstraction layer either with Rails or a separate application using something like Sinatra, which I personally find better suited to API development.
Then your mobile app can make REST calls to allow users to manipulate data from the same database.
Or you can of course just make your existing web UI mobile-friendly and have people just as easily work with your Rails app through the browsers in their phones as they do the browsers on their laptops.

Is it possible to pass on user session from a PHP or Rails app to a meteor app?

I want to create a web application in which the main application shall be built using a PHP Framework or RoR. However, there are some sections only, that need real time updates (e.g., collaborative editing, real time feeds) etc. Is it possible that if a user is authenticated on the PHP/RoR app, the user session data can be passed on to the meteor app ? Can the 2 applications share the same database? Any insight on how do I go about implementing this ?
While it is possible to do what you've asked you should possibly ask yourself if you can't achieve your goals with one tech stack. Having multiple tech stacks like Meteor and RoR / PHP means anyone that wants to work on your codebase needs to know all of these frameworks. Additionally you might be able to achieve your requirements around collaborative editing and real time feeds using PHP or RoR.
Since you have not posted your requirements it is hard to make concrete recommendations but maybe you should list your requirements use the least complicated tech stack to implement it.
Are you aware that RoR 4 has built in support for streaming: http://tenderlovemaking.com/2012/07/30/is-it-live.html
You might be able to implement your collabaration requirements using a JS library liek Angular or Ember JS which uses Ajax to keep the users screen in sync with what other users are doing.
Also, this blog post on how Trello is implemented might give you some ideas. They have a great web interface for collaboration: http://blog.fogcreek.com/the-trello-tech-stack/
With regards to your questions:
Two applications implemented in two different technologies can share the same database. You will need to choose a database that is supported by both technology stacks that you want to use. After that, point both applications at the same database.
If you authenticate a user in PHP/RoR app, you can then set a cookie for the user. Assuming your Meteor app is served from the same domain, you can then read in this cookie which might contain some kind of identifier for the authenticated users session. Your Meteor app could then check the db to see if this is a valid session for an authenticated user.

Ruby on rails making an app for smartphone

I want to build an app that use in the backend Ruby on Rails. However my problem comes in the lack of information i found on it. My goals is not just to create a website but an application that interacts with it, like my android facebook app when pressing menu I get button like logout and so on.
I am wondering if their exists tutorial on how to build an application but using rails or should i scrap my entire website and do it in php. I am looking for guide and tutorial. Thanks in advance
You can build an app on any platform and make it interact with your Rails-based server using HTTP requests (like AJAX).
You can send information back and forth using JSON or XML; you would probably need to make a new set of actions for the app to use.
There is no reason to use PHP. ever.
A little unclear from your original question, but if you are looking to create a mobile app using Ruby (and a structure similar to Ruby on Rails) then you may be interested in Rhomobile. It is a cross-platform mobile application framework that uses Ruby for its backend code, and follows a structure similar to (older) Ruby on Rails versions.
From what I understand of your problem, you want to use the robustness of Ruby to develop a native app (not just another app that mirrors a website).
The best thing I know of for this is RubyMotion. The bummer is the cost ($200). But then you would get to accomplish your task.

Building a Twitter Reader / SMTP Mailer

So I want to build an app that constantly monitors a certain hashtag/phase like #cookies and sends out an email to me (and anyone else who signs up on the site) every day with a list of all the tweets.
I have some Ruby/Rails experience and was considering building this on Heroku, but I was wondering if there was an easier platform to build it on, like say, Google App Engine (which I know very little about)
Assuming you want this to be a web application (not necessarily true from your description), I'd recommend Rails. You have some experience with it, and it's a solid platform. Heroku should work fine for this, but it's certainly not the only viable option. I'm not an expert on Heroku, and I don't know much about your app other than its primary function, so I couldn't tell you if Heroku is the optimal choice. As for Google App Engine, I'm pretty ignorant, but I've heard Rails isn't currently its sweet spot. (Just hearsay.) You could also consider a VPS, which is probably more work but also very educational.
The app itself should be pretty easy to use. Plug in to the Twitter Search API (http://dev.twitter.com/doc/get/search) or piggyback off some third-party Twitter aggregator. Then set up a cron job that accesses whatever data stream you've picked (Twitter API or third-party) and plug the results into ActionMailer.

Is there a Ruby on Rails site thumbnail generator available?

I'm hoping to avoid building this if it already exists. Does anyone know of a plugin for Ruby on Rails that will generate a screenshot of a web site? Thanks in advance to anyone who can help me find one.
As far as I am aware you need a server with a desktop (eg. Gnome, X11, KDE) and a web browser with thumbnail capabilities installed (eg. webkit and CutyCapt). Of course this is not usual for a Linux server.
I have used the service suggested by Soufiane using code based on Peter Coopers snippet and it works very well.
Generating website thumbnails would require significant server resources and some sort of background process and job queue so using a web thumbnail generation service might be a better alternative to generating your own.
Yes there is a wonderful solution:
http://webthumb.bluga.net/
It has an great API and there are some Ruby Wrappers (i.e. http://github.com/simplificator/rwebthumb)
It allows you to process 100 thumbnails a month, if you need more the price for credits is very generous if you ask me.
This is not a plugin, but I found this snippet which is using an external site to do what you want (I think.). I didn't test it though.
This is getting a little dated now, but just for posterity's sake there is an answer over here

Resources