Sha256: 2f93a070b01284f95496691108f1e26143807d3a5cab51ac13a1c695e7373b1a
Contents?: true
Size: 1.81 KB
Versions: 6
Compression:
Stored size: 1.81 KB
Contents
require "spec_helper" require "fakefs/spec_helpers" describe SequelRails::Migrations do let!(:db) { ::Sequel::Model.db } [:migrate_up!, :migrate_down!].each do |migration_method| describe ".#{migration_method}" do let(:result) { mock :result } context "with no version specified" do let(:opts) { {} } it "runs migrations using Sequel::Migrator" do ::Sequel::Migrator.should_receive(:run).with( db, Rails.root.join("db/migrate"), opts ).and_return result described_class.send(migration_method).should be result end end context "with version specified" do let(:opts) { {:target => 1} } it "runs migrations using Sequel::Migrator" do ::Sequel::Migrator.should_receive(:run).with( db, Rails.root.join("db/migrate"), opts ).and_return result described_class.send(migration_method, 1).should be result end end end end describe ".pending_migrations?" do include FakeFS::SpecHelpers let(:path) { Rails.root.join("db/migrate") } it "returns false if no db/migrate directory exists" do described_class.pending_migrations?.should == false end context "when db/migrate directory exists" do before { FileUtils.mkdir_p path } it "returns true if any pending migration" do ::Sequel::Migrator.should_receive(:is_current?).with( db, Rails.root.join("db/migrate") ).and_return false described_class.pending_migrations?.should == true end it "returns false if no pending migration" do ::Sequel::Migrator.should_receive(:is_current?).with( db, Rails.root.join("db/migrate") ).and_return true described_class.pending_migrations?.should == false end end end end
Version data entries
6 entries across 6 versions & 1 rubygems