spec/base_spec.rb in reviewed-0.1.2 vs spec/base_spec.rb in reviewed-0.1.4

- old
+ new

@@ -24,78 +24,52 @@ obj = Example.new( { foo: 'bar' } ) obj.instance_variable_get(:@attributes).should eql( { foo: 'bar' } ) end end - describe 'find' do - use_vcr_cassette 'base/article/find' + describe 'path' do - it 'returns an article' do - Reviewed::Article.find("#{article_id}").should be_an_instance_of(Reviewed::Article) + it 'should the demodulized resource name' do + Reviewed::Article.path.should eql("articles") end - - it 'calls object_from_response with correct params' do - Reviewed::Article.should_receive(:object_from_response).with( - :get, "articles/#{article_id}", {} - ) - Reviewed::Article.find("#{article_id}") - end end - describe 'resource_url' do + describe 'association_name' do - it 'should the demodulized resource name' do - Reviewed::Article.resource_url.should eql("articles") + it 'returns the demodulized & pluralized version of itself' do + Reviewed::Article.association_name.should eql("articles") end end - describe 'where' do - use_vcr_cassette 'base/where_collection' - - it 'returns a collection' do - collection = Reviewed::Article.where - collection.class.should == Reviewed::Collection + describe 'attributes' do + before(:each) do + @timestamp = Time.parse("01/01/2013 10:00:00 GMT") + @model = Example.new(id: 'id', super_awesome: 'true', created_at: @timestamp.to_s, updated_at: @timestamp.to_s) end - it 'returns the appropriate page of results' do - collection = Reviewed::Article.where(:page => 2) - collection.total.should > 1 - collection.current_page.should == 2 + it 'returns the named attribute (via method missing)' do + @model.super_awesome.should == 'true' end - it 'filters collections using other supported options' do - collection = Reviewed::Article.where(:keywords => 'minden') - collection.total.should == 1 - collection.last_page.should be_true + it 'has a created at timestamp' do + @model.created_at.should == @timestamp end - it 'returns an empty set if no matching data was found' do - collection = Reviewed::Article.where(:keywords => 'doesnotcompute') - collection.should be_empty - collection.total.should == 0 - collection.out_of_bounds.should be_true + it 'has an updated at timestamp' do + @model.updated_at.should == @timestamp end end - describe 'all' do - - it 'calls where with empty params' do - Reviewed::Article.should_receive(:where).with({}) - Reviewed::Article.all + describe 'respond_to?' do + before(:each) do + @model = Example.new(id: 'id', super_awesome: 'true') end - end - describe 'attributes' do - it 'returns the named attribute (via method missing)' do - model = Example.new(:id => 'id', :super_awesome => 'true') - model.super_awesome.should == 'true' + it 'takes attributes into consideration' do + @model.respond_to?(:super_awesome).should be_true end - end - describe 'resource_url' do - - it 'returns the pluralized demodulized class name' do - Reviewed::Article.resource_url.should eql('articles') - Example.resource_url.should eql('examples') + it 'preserves the original behavior' do + @model.respond_to?(:fafafa).should be_false end end end