Skip to content

Instantly share code, notes, and snippets.

@croaky
Created July 30, 2008 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save croaky/3354 to your computer and use it in GitHub Desktop.
Save croaky/3354 to your computer and use it in GitHub Desktop.
Tests for Hoptoad API via ActiveResource
# implementation at http://gist.github.com/3350
class HoptoadTest < Test::Unit::TestCase
context 'Error.find :all' do
setup do
@errors = Error.find :all
end
should 'find errors' do
assert @errors.any?
end
should 'find no more than 30 errors' do
assert @errors.size < 30
end
should 'find errors with a controller attribute' do
assert @errors.all? { |each| each.respond_to? :controller }
end
should 'find errors with a action attribute' do
assert @errors.all? { |each| each.respond_to? :action }
end
should 'find errors with a id attribute' do
assert @errors.all? { |each| each.respond_to? :id }
end
should 'find errors with a project_id attribute' do
assert @errors.all? { |each| each.respond_to? :project_id }
end
should 'find errors with a visible attribute' do
assert @errors.all? { |each| each.respond_to? :visible }
end
should 'find errors with a file attribute' do
assert @errors.all? { |each| each.respond_to? :file }
end
should 'find errors with a line_number attribute' do
assert @errors.all? { |each| each.respond_to? :line_number }
end
should 'find errors with a error_message attribute' do
assert @errors.all? { |each| each.respond_to? :error_message }
end
should 'find errors with a notices_count attribute' do
assert @errors.all? { |each| each.respond_to? :notices_count }
end
should 'find errors with a last_notice_at attribute' do
assert @errors.all? { |each| each.respond_to? :last_notice_at }
end
should 'find errors with a rails_env attribute' do
assert @errors.all? { |each| each.respond_to? :rails_env }
end
should 'find errors with a created_at attribute' do
assert @errors.all? { |each| each.respond_to? :created_at }
end
should 'find errors with a updated_at attribute' do
assert @errors.all? { |each| each.respond_to? :updated_at }
end
end
context 'Error.find :all, :params => { :page => 2 }' do
setup do
@errors = Error.find :all, :params => { :page => 2 }
end
should 'find errors' do
assert @errors.any?
end
should 'find no more than 30 errors' do
assert @errors.size < 30
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment