I am working on a very small app, it is a RabbitMQ notification system. It triggers an API call when a state changes. That part is fine and I believe is working correctly. What I am having problems is testing the notification part, I am using rspec and I do not have a way to test the notification, or do not know of a way. I have heard of mocking the RabbitMQ call in the test, but I do not know what that means specifically. Can anybody explain? thank you.
For testing app working with rabbitmq you can try evented-spec or moqueue.
For example, stubbing connect to AMQP (in moqueue):
before(:each) do
reset_broker
producer.stub(:connect).and_return(mock_exchange(:topic => "common"))
end
Other examples you can see here
Related
I have a Rails app running on Apache/Passenger. It has a rufus-scheduler cron job that runs in the background and sends out notifications via email.
When I am running the app in development on the WEBrick server, the emails are sent like they are supposed to be sent.
When I start up the app in production on Apache/Passenger, the emails don't get sent. In the production logs it doesn't show any logs for rufus-scheduler.
I'm stuck in this problem. Your help will be appreciated, thank you in advance.
The easiest solution is to set PassengerSpawnMethod to direct. The Phusion Passenger documentation explains why this solves it: http://www.modrails.com/documentation/Users%20guide%20Apache.html#spawning_methods_explained
In particular, take a look at section "15.4. Smart spawning gotcha #2: the need to revive threads".
I would like to receive remote push notification when the app is on the foreground. I think I can use "didReceiveRemoteNotification" in Objective-C, but how about in Titanium? I've been searching solutions but can't find anything. Does anybody help me out?
Titanium currently only supports local notifications (by default) I believe. You might want to take a look at AppCelerator as a solution.
Sorry, i was wrong last time. It's very hard to find but Titanium supports a way of interacting with PushNotifications.
Please take a look at Ti.Network.registerForPushNotifications. It provides a callback that is executed when you receive a Push Notification.
The other posted solutions below may provide a better integration for titanium so it's up to you what you want to use. But this should answer your original question.
Unfortunately Titanium only supports local notifications on iOS. If
you want to support remote notifications you can use
Urban Airship
ACS (Appcelerator Cloud Services) or
you write your own module that provides "didReceiveRemoteNotifcation" as an app event to your app
As far as i know you can only listen on local notifications by
default but you can try this method if it reacts on remote
notifications..
Any strategies for doing this? We have a Rails codebase that is currently fully integrated (same app serves up JS assets as does the back-end heavy lifting), but are thinking of extracting the two out into separate services, each in their own git repository and running on separate servers.
I'm planning on unit/acceptance testing the API with a small ruby HTTP client that will also act as documentation for the API endpoints, and the JS front-end (Brunch.io, Backbone, Chaplin) will have unit/acceptance testing internally as well... but I feel like I should be writing cucumber tests that integrate the two together, right? Where do those cukes live? In which repo?
Appreciate any insight here. Thanks!
In a general sense, if you have code that is for both your server and your client, then the "right" place to keep it depends on which side of your app is more central or "heavier": the client or the server.
That being said, from the way your describe things in your question, it kind of sounds you consider the Rails app "primary". For instance, you mention that you currently have "JS assets" integrated/being served by your "Rails codebase" ... not Rails assets being served by your JS server ;-)
So that answers things on the theoretical level, but I also think it makes sense to put the code in your Rails codebase for a practical reason: Cucumber is a Rails tool, not a JS one. You might use it to test some non-Ruby code, but ultimately it's being run by Ruby.
I don't know for sure, but I suspect you'll create headaches for yourself if you try and put your Cucumber specs in your JS codebase, then try to run them from your Rails codebase. Plus, that really tightly couples the two codebases: to run your tests you need both codebases on your testrunner vs. if you keep the Cucumber stuff in Rails-land your test runner could just have your Rails code, and it could run against a different server that has your JS code.
So ultimately it sounds to me like the Cucumber stuff belongs in Rails-land ... but going the other way (and storing it with your JS repo) doesn't seem horrible to me either, just potentially more problematic.
I have worked with faye on node before, but now want to add it to a rails app. I've found plenty of quick integration guides and have it up and running, but my current implementation is pretty hacky. I've been unable to find any longer tutorials or examples including a good convention for the server to subscribe to the faye channels, interact with the rails models, and publish responses. Does anyone know of good resources?
The below links can be useful for you,
http://railscasts.com/episodes/260-messaging-with-faye?view=asciicast
First one exhibits the simple instant message application in Rails with the help of faye.
I found the How to Use Faye as a Real-Time Push Server in Rails tutorial to be a good start:
We’re going build a simple chat service. Now, Ryan Bates covered this on Railscast #260, however, we’re going to take a slightly different approach in this tutorial. First, we’ll create a chat service where users enter a public room, and everyone can chat with each other publicly. The second functionality we’ll be adding is private messages. Additionally, we’ll integrate some security to our implementation using Ryan Bate’s private_pub gem.
In about one hour you get a hands-on experience and understanding of Faye, both as a server and as a client. By the end of it you have a very basic chat; and not only that, your chat is also secure via private_pub.
Faye has moved towards rack compatibility, so using a config.ru file and booting with the command rackup is advised (the listen method will not work on the latest version of faye).
Booting Faye with rails isn't encouraged, because FAYE isn't compatible with development middleware in rails, meaning you will always need to run in production mode.
A minimalistic barebones example project was written, which deploys cleanly to heroku as observed live at faye-rails-example.herokuapp.com.
There are so many choices, i need a win/mac application capable of sending info to a rails app, i already have the rails app working on a server, so i just need basic crud activity via xml.
So what should you work this with , Realbasic, Java, Flex?
Thanks in advance.
If you feel like staying in Ruby then you could check out Monkeybars. I haven't done anything serious in it myself but it seems nice, except that the lack of new information on their site is a little discouraging.