spec/plaza/models/restful_model_spec.rb in plaza-0.1.0 vs spec/plaza/models/restful_model_spec.rb in plaza-0.1.1
- old
+ new
@@ -17,11 +17,11 @@
class Amabob
include Plaza::RestfulModel
plaza_config :foobar
has_many 'Foobar::Amajing'
- attribute :amajig_id, Integer
+ attribute :amajing_id, Integer
end
class Amajing
include Plaza::RestfulModel
plaza_config :foobar
@@ -73,11 +73,11 @@
let(:amabob_hash){
{
'amabob' => {
'id' => 3,
- 'amajig_id' => 2
+ 'amajing_id' => 2
}
}
}
let(:amabobs_hash){
@@ -247,9 +247,15 @@
describe 'belongs_to relations' do
it 'get related object' do
thing = Thing.new(thing_hash['thing'])
stub_request(:get, 'http://example.com/rest/amajigs/2.json').to_return(body:amajig_hash.to_json)
thing.amajig.name.should == 'Jigger'
+ end
+
+ it 'should get reltated object in module' do
+ bob = Foobar::Amabob.new(amabob_hash['amabob'])
+ stub_request(:get, 'http://www.example.com/rest/amajings/2.json').to_return(body:amabobs_hash.to_json)
+ bob.amajing.class.name.should == 'Foobar::Amajing'
end
end
describe 'has_many relationships' do
it 'gets first has_many relationships' do