class ActiveRecord::PostgreSQLStructureLoadTest
Public Instance Methods
setup()
click to toggle source
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 327 def setup @connection = stub @configuration = { "adapter" => "postgresql", "database" => "my-app-db" } ActiveRecord::Base.stubs(:connection).returns(@connection) ActiveRecord::Base.stubs(:establish_connection).returns(true) Kernel.stubs(:system) end
test_structure_load()
click to toggle source
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 339 def test_structure_load filename = "awesome-file.sql" Kernel.expects(:system).with("psql", "-v", "ON_ERROR_STOP=1", "-q", "-f", filename, @configuration["database"]).returns(true) ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) end
test_structure_load_accepts_path_with_spaces()
click to toggle source
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 357 def test_structure_load_accepts_path_with_spaces filename = "awesome file.sql" Kernel.expects(:system).with("psql", "-v", "ON_ERROR_STOP=1", "-q", "-f", filename, @configuration["database"]).returns(true) ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) end
test_structure_load_with_extra_flags()
click to toggle source
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 346 def test_structure_load_with_extra_flags filename = "awesome-file.sql" expected_command = ["psql", "-v", "ON_ERROR_STOP=1", "-q", "-f", filename, "--noop", @configuration["database"]] assert_called_with(Kernel, :system, expected_command, returns: true) do with_structure_load_flags(["--noop"]) do ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) end end end
Private Instance Methods
with_structure_load_flags(flags) { || ... }
click to toggle source
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 365 def with_structure_load_flags(flags) old = ActiveRecord::Tasks::DatabaseTasks.structure_load_flags ActiveRecord::Tasks::DatabaseTasks.structure_load_flags = flags yield ensure ActiveRecord::Tasks::DatabaseTasks.structure_load_flags = old end