to_activerecord 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.1 2007-06-17
2
+
3
+ * Added tests (using mocha)
4
+
1
5
  == 0.1.0 2007-06-16
2
6
 
3
7
  * 1 major enhancement:
@@ -2,7 +2,7 @@ module ToActiverecord #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -5,7 +5,7 @@ require 'to_activerecord/version'
5
5
 
6
6
  begin
7
7
  require 'active_support'
8
- rescue
8
+ rescue LoadError
9
9
  require 'rubygems'
10
10
  require 'active_support'
11
11
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../lib/to_activerecord'
3
- # require 'mocha'
3
+ require 'mocha'
@@ -1,11 +1,34 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
+ class PostError < StandardError
4
+ end
5
+
6
+ class Post
7
+ def self.find(*args)
8
+ raise PostError, "Cannot find #{args.inspect}"
9
+ end
10
+ end
11
+
3
12
  class TestToActiverecord < Test::Unit::TestCase
4
13
 
5
14
  def setup
6
15
  end
7
16
 
8
- def test_truth
9
- assert true
17
+ def test_to_known_post_id
18
+ post = Post.new
19
+ Post.expects(:find).with(60).returns(post)
20
+ assert_equal(post, Post.find(60), "mock not working")
21
+
22
+ Post.expects(:find).with(60).returns(post)
23
+ assert_equal(post, 60.to_post, "to_activerecord not working")
24
+ end
25
+
26
+
27
+ def test_to_unknown_post_id
28
+ assert_raise(PostError) { 999.to_post }
29
+ end
30
+
31
+ def test_to_unknown_class
32
+ assert_raise(NoMethodError) { 30.to_foobar }
10
33
  end
11
34
  end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>to_activerecord</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/to_activerecord"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/to_activerecord" class="numbers">0.1.0</a>
36
+ <a href="http://rubyforge.org/projects/to_activerecord" class="numbers">0.1.1</a>
37
37
  </div>
38
38
  <h1>&#x2192; 7.to_car == Car.find(7)</h1>
39
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.1
3
3
  specification_version: 1
4
4
  name: to_activerecord
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-06-16 00:00:00 +02:00
6
+ version: 0.1.1
7
+ date: 2007-06-17 00:00:00 +02:00
8
8
  summary: "Find ActiveRecord instances via their ID value. Now you can use 37.to_post instead of Post.find(37). Used in conjunction with the map_by_method gem: [37,103].map_by_to_post"
9
9
  require_paths:
10
10
  - lib