Skip to content

Instantly share code, notes, and snippets.

@arthurschreiber
Created August 7, 2008 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurschreiber/4460 to your computer and use it in GitHub Desktop.
Save arthurschreiber/4460 to your computer and use it in GitHub Desktop.
<?php
namespace FsckUnit;
require_once(dirname(__FILE__) . "/spec_helper.php");
describe("ActiveRecord::Base::table_name()", function() {
it("returns the table name for the class", function() {
expect(::News::table_name())->to("==", "news");
expect(::Post::table_name())->to("==", "posts");
expect(::Person::table_name())->to("==", "people");
});
});
describe("ActiveRecord::Base::find() when passed 'first'", function() {
it("returns the first row from the Database", function() {
expect(::News::find("first"))->to("==", 'SELECT * FROM "news" LIMIT 1');
expect(::Post::find("first"))->to("==", 'SELECT * FROM "posts" LIMIT 1');
expect(::Person::find("first"))->to("==", 'SELECT * FROM "people" LIMIT 1');
});
});
describe("ActiveRecord::Base::find() when passed 'all'", function() {
it("returns all rows from the Database", function() {
expect(::News::find("all"))->to("==", 'SELECT * FROM "news"');
expect(::Post::find("all"))->to("==", 'SELECT * FROM "posts"');
expect(::Person::find("all"))->to("==", 'SELECT * FROM "people"');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment