Skip to content

Instantly share code, notes, and snippets.

@clowder
Forked from croaky/hoptoad_api_test.rb
Created October 5, 2010 15:59
Show Gist options
  • Save clowder/611786 to your computer and use it in GitHub Desktop.
Save clowder/611786 to your computer and use it in GitHub Desktop.
# implementation at http://gist.github.com/3350
require 'spec_helper'
describe HoptoadErrors do
describe '.find :all' do
before(:each) do
@errors = HoptoadErrors.find :all
end
it 'finds errors' do
@errors.should_not be_nil
end
it 'finds no more than 30 errors' do
@errors.size.should have_at_most(30).items
end
it 'find errors with a controller attribute' do
@errors.all? { |each| each.should respond_to(:controller) }
end
it 'find errors with a action attribute' do
@errors.all? { |each| each.should respond_to(:action) }
end
it 'find errors with a id attribute' do
@errors.all? { |each| each.should respond_to(:id) }
end
it 'find errors with a project_id attribute' do
@errors.all? { |each| each.should respond_to(:project_id) }
end
# => CHANGED: Removed the test, the attribute seems to be depricated
# it 'find errors with a visible attribute' do
# @errors.all? { |each| each.should respond_to(:visible) }
# end
it 'find errors with a file attribute' do
@errors.all? { |each| each.should respond_to(:file) }
end
it 'find errors with a line_number attribute' do
@errors.all? { |each| each.should respond_to(:line_number) }
end
it 'find errors with a error_message attribute' do
@errors.all? { |each| each.should respond_to(:error_message) }
end
it 'find errors with a notices_count attribute' do
@errors.all? { |each| each.should respond_to(:notices_count) }
end
# => CHANGED: Removed the test, the attribute seems to be depricated
# it 'find errors with a last_notice_at attribute' do
# @errors.all? { |each| each.should respond_to(:last_notice_at) }
# end
it 'find errors with a rails_env attribute' do
@errors.all? { |each| each.should respond_to(:rails_env) }
end
it 'find errors with a created_at attribute' do
@errors.all? { |each| each.should respond_to(:created_at) }
end
it 'find errors with a updated_at attribute' do
@errors.all? { |each| each.should respond_to(:updated_at) }
end
end
describe 'Error.find :all, :params => { :page => 2 }' do
before(:each) do
@errors = HoptoadErrors.find :all, :params => { :page => 2 }
end
it 'finds errors' do
@errors.should_not be_nil
end
it 'finds no more than 30 errors' do
@errors.size.should have_at_most(30).items
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment