|
1 | 1 | require "../../spec_helper"
|
2 | 2 |
|
3 |
| -{% for adapter in GraniteExample::ADAPTERS %} |
4 |
| -module {{adapter.capitalize.id}} |
5 |
| - describe "{{ adapter.id }} belongs_to" do |
6 |
| - it "provides a getter for the foreign entity" do |
7 |
| - teacher = Teacher.new |
8 |
| - teacher.name = "Test teacher" |
9 |
| - teacher.save |
| 3 | +describe "belongs_to" do |
| 4 | + it "provides a getter for the foreign entity" do |
| 5 | + teacher = Teacher.new |
| 6 | + teacher.name = "Test teacher" |
| 7 | + teacher.save |
10 | 8 |
|
11 |
| - klass = Klass.new |
12 |
| - klass.name = "Test klass" |
13 |
| - klass.teacher_id = teacher.id |
14 |
| - klass.save |
| 9 | + klass = Klass.new |
| 10 | + klass.name = "Test klass" |
| 11 | + klass.teacher_id = teacher.id |
| 12 | + klass.save |
15 | 13 |
|
16 |
| - klass.teacher.id.should eq teacher.id |
17 |
| - end |
| 14 | + klass.teacher.id.should eq teacher.id |
| 15 | + end |
18 | 16 |
|
19 |
| - it "provides a setter for the foreign entity" do |
20 |
| - teacher = Teacher.new |
21 |
| - teacher.name = "Test teacher" |
22 |
| - teacher.save |
| 17 | + it "provides a setter for the foreign entity" do |
| 18 | + teacher = Teacher.new |
| 19 | + teacher.name = "Test teacher" |
| 20 | + teacher.save |
23 | 21 |
|
24 |
| - klass = Klass.new |
25 |
| - klass.name = "Test klass" |
26 |
| - klass.teacher = teacher |
27 |
| - klass.save |
| 22 | + klass = Klass.new |
| 23 | + klass.name = "Test klass" |
| 24 | + klass.teacher = teacher |
| 25 | + klass.save |
28 | 26 |
|
29 |
| - klass.teacher_id.should eq teacher.id |
30 |
| - end |
| 27 | + klass.teacher_id.should eq teacher.id |
| 28 | + end |
31 | 29 |
|
32 |
| - it "supports custom types for the join" do |
33 |
| - book = Book.new |
34 |
| - book.name = "Screw driver" |
35 |
| - book.save |
| 30 | + it "supports custom types for the join" do |
| 31 | + book = Book.new |
| 32 | + book.name = "Screw driver" |
| 33 | + book.save |
36 | 34 |
|
37 |
| - review = BookReview.new |
38 |
| - review.book = book |
39 |
| - review.body = "Best book ever!" |
40 |
| - review.save |
| 35 | + review = BookReview.new |
| 36 | + review.book = book |
| 37 | + review.body = "Best book ever!" |
| 38 | + review.save |
41 | 39 |
|
42 |
| - review.book.name.should eq "Screw driver" |
43 |
| - end |
| 40 | + review.book.name.should eq "Screw driver" |
| 41 | + end |
44 | 42 |
|
45 |
| - it "supports custom method name" do |
46 |
| - author = Person.new |
47 |
| - author.name = "John Titor" |
48 |
| - author.save |
| 43 | + it "supports custom method name" do |
| 44 | + author = Person.new |
| 45 | + author.name = "John Titor" |
| 46 | + author.save |
49 | 47 |
|
50 |
| - book = Book.new |
51 |
| - book.name = "How to Time Traveling" |
52 |
| - book.author = author |
53 |
| - book.save |
| 48 | + book = Book.new |
| 49 | + book.name = "How to Time Traveling" |
| 50 | + book.author = author |
| 51 | + book.save |
54 | 52 |
|
55 |
| - book.author.name.should eq "John Titor" |
56 |
| - end |
| 53 | + book.author.name.should eq "John Titor" |
| 54 | + end |
57 | 55 |
|
58 |
| - it "supports both custom method name and custom types for the join" do |
59 |
| - publisher = Company.new |
60 |
| - publisher.name = "Amber Framework" |
61 |
| - publisher.save |
| 56 | + it "supports both custom method name and custom types for the join" do |
| 57 | + publisher = Company.new |
| 58 | + publisher.name = "Amber Framework" |
| 59 | + publisher.save |
62 | 60 |
|
63 |
| - book = Book.new |
64 |
| - book.name = "Introduction to Granite" |
65 |
| - book.publisher = publisher |
66 |
| - book.save |
| 61 | + book = Book.new |
| 62 | + book.name = "Introduction to Granite" |
| 63 | + book.publisher = publisher |
| 64 | + book.save |
67 | 65 |
|
68 |
| - book.publisher.name.should eq "Amber Framework" |
69 |
| - end |
| 66 | + book.publisher.name.should eq "Amber Framework" |
70 | 67 | end
|
71 | 68 | end
|
72 |
| -{% end %} |
0 commit comments