Sha256: 98f6a0fd270d4c744abc837f7beaa81b708f1fbe92f899394ce810b9adecfe5e
Contents?: true
Size: 1.71 KB
Versions: 9
Compression:
Stored size: 1.71 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' describe "Associations" do describe "when included in a class" do attr_reader :klass, :obj before(:each) do @klass = Class.new @klass.class_eval do include Associations end @obj = @klass.new end describe "#has_many" do before(:each) do klass.instance_methods.should_not include("topics") Associations.instance_methods.should_not include("topics") obj.methods.should_not include("topics") obj.has_many :topics, :url => "/path/topics" end it "should create a method on the object the method is invoked on" do obj.methods.should include("topics") end it "should not create an instance method on the including class" do klass.instance_methods.should_not include("topics") end it "should not create an instance method on Associations" do Associations.instance_methods.should_not include("topics") end end describe "#belongs_to" do before(:each) do klass.instance_methods.should_not include("company") Associations.instance_methods.should_not include("company") obj.methods.should_not include("company") obj.belongs_to :company, :url => "/path/company" end it "should create a method on the object the method is invoked on" do obj.methods.should include("company") end it "should create an instance method on the including class" do klass.instance_methods.should_not include("company") end it "should not create an instance method on Associations" do Associations.instance_methods.should_not include("company") end end end end
Version data entries
9 entries across 9 versions & 1 rubygems