Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/dbexpect/table.rb
Instance Attribute Summary collapse
-
#dirty ⇒ Object
writeonly
Sets the attribute dirty.
Instance Method Summary collapse
- #add_expected_row(column_values) ⇒ Object
- #add_fixture_row(column_values) ⇒ Object
-
#initialize(db_name, schema, name) ⇒ Table
constructor
A new instance of Table.
- #new_expectation(row) ⇒ Object
- #row_count_check(count) ⇒ Object
- #set_default(column, value) ⇒ Object
- #set_expected_default(column, value) ⇒ Object
- #set_up_for_test(databases) ⇒ Object
Constructor Details
#initialize(db_name, schema, name) ⇒ Table
Returns a new instance of Table.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dbexpect/table.rb', line 24 def initialize(db_name,schema,name) @schema = schema @name = name @db_name = db_name @expected_row_factory = DefaultingRowSet.new @fixture_rows = DefaultingRowSet.new @dirty = false end |
Instance Attribute Details
#dirty=(value) ⇒ Object (writeonly)
Sets the attribute dirty
55 56 57 |
# File 'lib/dbexpect/table.rb', line 55 def dirty=(value) @dirty = value end |
Instance Method Details
#add_expected_row(column_values) ⇒ Object
47 48 49 |
# File 'lib/dbexpect/table.rb', line 47 def add_expected_row(column_values) new_expectation(@expected_row_factory.add_row(column_values)) end |
#add_fixture_row(column_values) ⇒ Object
43 44 45 |
# File 'lib/dbexpect/table.rb', line 43 def add_fixture_row(column_values) @fixture_rows.add_row(column_values) end |
#new_expectation(row) ⇒ Object
51 52 53 |
# File 'lib/dbexpect/table.rb', line 51 def new_expectation(row) RowExpectation.new(@db_name,@schema,@name,row) end |
#row_count_check(count) ⇒ Object
67 68 69 |
# File 'lib/dbexpect/table.rb', line 67 def row_count_check(count) RowCountExpectation.new(@db_name,@schema,@name,count) end |
#set_default(column, value) ⇒ Object
35 36 37 |
# File 'lib/dbexpect/table.rb', line 35 def set_default(column,value) @fixture_rows.set_default(column, value) end |
#set_expected_default(column, value) ⇒ Object
39 40 41 |
# File 'lib/dbexpect/table.rb', line 39 def set_expected_default(column,value) @expected_row_factory.set_default(column,value) end |
#set_up_for_test(databases) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dbexpect/table.rb', line 56 def set_up_for_test(databases) database = databases[@db_name] raise "Could not find #{@db_name} in #{databases.inspect}" unless database unless @dirty database.truncate_table(@schema,@name) end database.insert_rows(@fixture_rows.insert_statements(@schema,@name)) end |