Skip to content
This repository
Browse code

Fix spec dependency on Rails being vendored

  • Loading branch information...
commit e00842845b504049f5c398c44701385813a0e00a 1 parent 949329f
Shane Mingins authored December 14, 2009

Showing 1 changed file with 40 additions and 41 deletions. Show diff stats Hide diff stats

  1. 81  spec/localize_spec.rb
81  spec/localize_spec.rb
@@ -9,59 +9,58 @@
9 9
     @backend.cache_store.clear
10 10
   end
11 11
 
12  
-  # load database with default active_support translations for english locale
13  
-  # FIXME:  remove this dependency
14  
-  unless File.exists?('vendor/rails/activesupport/lib/active_support/locale/en.yml')
15  
-    puts "\n[warn] A few date tests require rails to be vendorized.  See spec/localize_spec.rb.  This needs to be fixed.\n"
16  
-  else
17  
-    describe "with default locale en" do
18  
-      before(:each) do
19  
-        I18n.default_locale = "en"
  12
+  describe "with default locale en" do
  13
+    before(:each) do
  14
+      I18n.default_locale = "en"
  15
+      if File.exists?('vendor/rails/activesupport/lib/active_support/locale/en.yml')
20 16
         I18nUtil.load_from_yml 'vendor/rails/activesupport/lib/active_support/locale/en.yml'
  17
+      else
  18
+        activesupport_gem = Gem.cache.find_name('activesupport').sort_by { |g| g.version.version }.last
  19
+        I18nUtil.load_from_yml "#{activesupport_gem.full_gem_path}/lib/active_support/locale/en.yml"
21 20
       end
  21
+    end
22 22
 
23  
-      describe "and locale en" do
24  
-        before(:each) do
25  
-          I18n.locale = "en"
26  
-        end
  23
+    describe "and locale en" do
  24
+      before(:each) do
  25
+        I18n.locale = "en"
  26
+      end
27 27
 
28  
-        it "should localize dates in different formats" do
29  
-          dates = {
30  
-            Date.new(2009,1,1)   => {:default => "2009-01-01", :short => "Jan 01", :long => "January 01, 2009"},
31  
-            Date.new(2009,1,31)  => {:default => "2009-01-31", :short => "Jan 31", :long => "January 31, 2009"},
32  
-            Date.new(2009,2,2)   => {:default => "2009-02-02", :short => "Feb 02", :long => "February 02, 2009"},
33  
-            Date.new(2009,2,28)  => {:default => "2009-02-28", :short => "Feb 28", :long => "February 28, 2009"},
34  
-            Date.new(2008,2,29)  => {:default => "2008-02-29", :short => "Feb 29", :long => "February 29, 2008"},
35  
-            Date.new(2009,3,11)  => {:default => "2009-03-11", :short => "Mar 11", :long => "March 11, 2009"},
36  
-            Date.new(2010,4,30)  => {:default => "2010-04-30", :short => "Apr 30", :long => "April 30, 2010"},
37  
-            Date.new(2020,12,31) => {:default => "2020-12-31", :short => "Dec 31", :long => "December 31, 2020"}
38  
-          }
  28
+      it "should localize dates in different formats" do
  29
+        dates = {
  30
+          Date.new(2009,1,1)   => {:default => "2009-01-01", :short => "Jan 01", :long => "January 01, 2009"},
  31
+          Date.new(2009,1,31)  => {:default => "2009-01-31", :short => "Jan 31", :long => "January 31, 2009"},
  32
+          Date.new(2009,2,2)   => {:default => "2009-02-02", :short => "Feb 02", :long => "February 02, 2009"},
  33
+          Date.new(2009,2,28)  => {:default => "2009-02-28", :short => "Feb 28", :long => "February 28, 2009"},
  34
+          Date.new(2008,2,29)  => {:default => "2008-02-29", :short => "Feb 29", :long => "February 29, 2008"},
  35
+          Date.new(2009,3,11)  => {:default => "2009-03-11", :short => "Mar 11", :long => "March 11, 2009"},
  36
+          Date.new(2010,4,30)  => {:default => "2010-04-30", :short => "Apr 30", :long => "April 30, 2010"},
  37
+          Date.new(2020,12,31) => {:default => "2020-12-31", :short => "Dec 31", :long => "December 31, 2020"}
  38
+        }
39 39
 
40  
-          dates.each do |date, formats|
41  
-            formats.each do |format, expected_value|
42  
-              @backend.localize("en", date, format).should == expected_value
43  
-            end
  40
+        dates.each do |date, formats|
  41
+          formats.each do |format, expected_value|
  42
+            @backend.localize("en", date, format).should == expected_value
44 43
           end
45 44
         end
  45
+      end
46 46
 
47  
-        it "should localize times in different formats" do
48  
-          time = DateTime.new(y=2008,m=3,d=22,h=16,min=30,s=12)
49  
-
50  
-          @backend.localize("en", time, :default).should == "Sat, 22 Mar 2008 16:30:12 +0000"
51  
-          @backend.localize("en", time, :short).should == "22 Mar 16:30"
52  
-          @backend.localize("en", time, :long).should == "March 22, 2008 16:30"
53  
-          @backend.localize("en", time, '%B %d, %Y %H:%M %p').should == "March 22, 2008 16:30 pm"
54  
-        end
  47
+      it "should localize times in different formats" do
  48
+        time = DateTime.new(y=2008,m=3,d=22,h=16,min=30,s=12)
55 49
 
  50
+        @backend.localize("en", time, :default).should == "Sat, 22 Mar 2008 16:30:12 +0000"
  51
+        @backend.localize("en", time, :short).should == "22 Mar 16:30"
  52
+        @backend.localize("en", time, :long).should == "March 22, 2008 16:30"
  53
+        @backend.localize("en", time, '%B %d, %Y %H:%M %p').should == "March 22, 2008 16:30 pm"
56 54
       end
57 55
 
58  
-      describe "and locale es" do
59  
-        before(:each) do
60  
-          I18n.locale = "es"
61  
-          @spanish_locale = Locale.create!(:code => 'es')
62  
-        end
  56
+    end
63 57
 
  58
+    describe "and locale es" do
  59
+      before(:each) do
  60
+        I18n.locale = "es"
  61
+        @spanish_locale = Locale.create!(:code => 'es')
64 62
       end
  63
+
65 64
     end
66 65
   end
67  
-end
  66
+end

0 notes on commit e008428

Please sign in to comment.
Something went wrong with that request. Please try again.