8. JRuby
A Ruby language
implementation on JVM
10 years (+ 1 day) since
the first recorded commit
Supporting Rails since
May, 2006
Latest release is 1.6.4 (22
August, 2011)
9. JRuby Jam Session
15:00 BST 15 Setembro, 2011
http://pages.engineyard.com/JRubyInDepth.html
10. Warbler
From a Ruby/Rails/
Merb/Rack application,
create a WAR file for
use with Java
application container
such as Tomcat and
Glassfish
http://www.pbase.com/wwcsig/image/59657656
12. $ jruby -S bundle install
Using backports (2.0.3)
Using builder (3.0.0)
⋮
Using cucumber (0.10.2)
Using cucumber-rails (0.4.0)
Using database_cleaner (0.6.6)
Using launchy (1.0.0) from https://github.com/copiousfreetime/launchy.git (at v1.0.0)
Using monkey-lib (0.5.4)
Using rspec-core (2.1.0)
Using rspec-expectations (2.1.0)
Using rspec-mocks (2.1.0)
Using rspec (2.1.0)
Using rspec-rails (2.1.0)
Using tilt (1.2.2)
Using sinatra (1.2.1)
Using sinatra-sugar (0.5.0)
Using sinatra-advanced-routes (0.5.1)
Using sinatra-reloader (0.5.0)
Using spoon (0.0.1)
Using bundler (1.0.17)
Your bundle is complete! It was installed into ./bundler
20. Cucumber
Feature: Pets
Scenario: Edit Pet
Given I am on the owners search page
And I press "Find Owners"
And I follow "George Franklin"
And I follow "Edit Pet"
When I fill in "Name" with "Leoni"
And press "Update Pet"
Then I should see "Leoni"
26. Cucumber test
Stand by while Tomcat finishes booting...
Using the default profile...
............................................................F-.............
(::) failed steps (::)
expected: /xml/,
got: "text/html;charset=utf-8" (using =~)
Diff:
@@ -1,2 +1,2 @@
-/xml/
+text/html;charset=utf-8
(RSpec::Expectations::ExpectationNotMetError)
org/jruby/RubyProc.java:268:in `call'
./features/step_definitions/xml_json_steps.rb:12:in `(root)':in `/^I should see
an XML document$/'
features/vets.feature:6:in `Then I should see an XML document'
Failing Scenarios:
cucumber features/vets.feature:3 # Scenario: View vets as XML
13 scenarios (1 failed, 12 passed)
75 steps (1 failed, 1 skipped, 73 passed)
0m7.709s
rake aborted!
Cucumber failed
29. diff --git a/src/main/webapp/WEB-INF/lib/app.rb b/src/main/webapp/WEB-INF/lib/
app.rb
index 6ab5b3c..4398fb4 100644
--- a/src/main/webapp/WEB-INF/lib/app.rb
+++ b/src/main/webapp/WEB-INF/lib/app.rb
@@ -1,6 +1,33 @@
require 'builder'
require 'erb'
+require 'spring_helpers'
+
+helpers do
+ include Spring
+end
get '/rack/' do
'<h1>Sinatra</h1>'
end
+
+get '/rack/vets.xml' do
+ content_type 'application/vnd.petclinic+xml'
+ builder do |xml|
+ xml.instruct!
+ xml.vets do
+ clinic.vets.each do |vet|
+ xml.vetList do
+ xml.id vet.id
+ xml.firstName vet.firstName
+ xml.lastName vet.lastName
+ vet.specialties.each do |spec|
+ xml.specialties do
+ xml.id spec.id
+ xml.name spec.name
+ end
+ end
+ end
+ end
+ end
+ end
+end
36. Large refactoring
Change directory structure; move files from
WEB-INF/* to Rails directory structure
In Rails initializer, create a Spring context to boot
the Spring app
Ensure classpath includes Spring jars.