Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's up in ruby for Java developers

1,446 views

Published on

Show to Java developers how things are developed in Ruby and the Ruby/Rails equivalent of Java frameworks.

Presentation I gave at the Tours Java User Group (Wednesday, the 20th of April 2010).

Published in: Technology
  • Be the first to comment

  • Be the first to like this

What's up in ruby for Java developers

  1. 1. What's up in Ruby for Java Developers Tours JUG 2011.04 Thomas Queste www.tomsquest.com
  2. 2. Rspec <ul><li>Junit : loooong test methods </li></ul><ul><li>public myMethod_ should DoSomething_ when Something() </li></ul>
  3. 3. Rspec <ul><li>Rspec : test contexts </li></ul><ul><li>describe ”MyClass” </li></ul><ul><li>describe ”MyMethod” </li></ul><ul><li>context ”With something” </li></ul><ul><li>it ”should do something” </li></ul><ul><li>context ”With something else” </li></ul><ul><li>it ”should do something else” </li></ul>
  4. 4. Rspec <ul><li>Search </li></ul><ul><li>#find_offers </li></ul><ul><li>when a spread type is specified </li></ul><ul><li>should filter by spread_type </li></ul><ul><li>for the currency pair 'EUR/USD' </li></ul><ul><li>should search by min spread </li></ul><ul><li>should search by typical spread </li></ul><ul><li>should search by min OR typical spread </li></ul><ul><li>should ignore a spread of 0 </li></ul>
  5. 5. Factory Girl <ul><li>Generate test data </li></ul><ul><li>my_user = Factory(:user) </li></ul><ul><li>Factory.define :user do |b| </li></ul><ul><li>email ” [email_address] ” </li></ul><ul><li># email Faker::Internet.email </li></ul><ul><li>end </li></ul>
  6. 6. Active Record <ul><li>Relations </li></ul><ul><ul><li>class Article < ActiveRecord::Base </li></ul></ul><ul><ul><li>has_many :authors </li></ul></ul><ul><li>Query </li></ul><ul><ul><li>Article </li></ul></ul><ul><ul><li>.where( :language => ”en” ) </li></ul></ul><ul><ul><li>.order(”updated_at desc”) </li></ul></ul>
  7. 7. Migration <ul><li>Versionned database </li></ul><ul><ul><li>class CreateArticles < ActiveRecord::Migration </li></ul></ul><ul><ul><li>def self.up </li></ul></ul><ul><ul><li>create_table :articles do |t| </li></ul></ul><ul><ul><li>t.string :title </li></ul></ul><ul><ul><li>t.text :body </li></ul></ul><ul><ul><li>t.timestamps </li></ul></ul><ul><ul><li>end </li></ul></ul><ul><ul><li>end </li></ul></ul><ul><ul><li>def self.down </li></ul></ul><ul><ul><li>drop_table :articles </li></ul></ul><ul><ul><li>end </li></ul></ul><ul><ul><li>end </li></ul></ul>
  8. 8. Bundler <ul><li>Dependency management </li></ul><ul><ul><li>gem 'rails', '3.0.6' </li></ul></ul><ul><ul><li>gem 'formtastic', '~> 1.1.0' </li></ul></ul><ul><ul><li>group :test do </li></ul></ul><ul><ul><li>gem 'factory_girl_rails' </li></ul></ul><ul><ul><li>end </li></ul></ul>
  9. 9. Heroku <ul><li>Simple Cloud deployment </li></ul><ul><ul><li>heroku create myapp </li></ul></ul><ul><ul><li>git push heroku master </li></ul></ul><ul><li>Addons </li></ul><ul><ul><li>heroku addons:add sendgrid </li></ul></ul>
  10. 10. GitHub <ul><li>Souce management </li></ul><ul><li>Social </li></ul><ul><li>Fork/Pull Request </li></ul><ul><li>... </li></ul>
  11. 11. Thanks Thomas Queste www.tomsquest.com @ThomasQueste [email_address]

×