spec/environment_spec.rb in seed_dump-3.2.1 vs spec/environment_spec.rb in seed_dump-3.2.2
- old
+ new
@@ -75,48 +75,40 @@
SeedDump.dump_using_environment('LIMIT' => '5')
end
end
- describe 'MODEL' do
- it 'if MODEL is not specified it should dump all non-empty models' do
- FactoryGirl.create(:another_sample)
+ ['', 'S'].each do |model_suffix|
+ model_env = 'MODEL' + model_suffix
- [Sample, AnotherSample].each do |model|
- SeedDump.should_receive(:dump).with(model, anything)
- end
+ describe model_env do
+ context "if #{model_env} is not specified" do
+ it "should dump all non-empty models" do
+ FactoryGirl.create(:another_sample)
- SeedDump.dump_using_environment
- end
+ [Sample, AnotherSample].each do |model|
+ SeedDump.should_receive(:dump).with(model, anything)
+ end
- it 'if MODEL is specified it should only dump the specified model' do
- FactoryGirl.create(:another_sample)
-
- SeedDump.should_receive(:dump).with(Sample, anything)
-
- SeedDump.dump_using_environment('MODEL' => 'Sample')
- end
- end
-
- describe 'MODELS' do
- it 'if MODELS is not specified it should dump all non-empty models' do
- FactoryGirl.create(:another_sample)
-
- [Sample, AnotherSample].each do |model|
- SeedDump.should_receive(:dump).with(model, anything)
+ SeedDump.dump_using_environment
+ end
end
- SeedDump.dump_using_environment
- end
+ context "if #{model_env} is specified" do
+ it "should dump only the specified model" do
+ FactoryGirl.create(:another_sample)
- it 'if MODELS is specified it should only dump those models' do
- FactoryGirl.create(:another_sample)
- FactoryGirl.create(:yet_another_sample)
+ SeedDump.should_receive(:dump).with(Sample, anything)
- SeedDump.should_receive(:dump).with(Sample, anything)
- SeedDump.should_receive(:dump).with(AnotherSample, anything)
+ SeedDump.dump_using_environment(model_env => 'Sample')
+ end
- SeedDump.dump_using_environment('MODELS' => 'Sample, AnotherSample')
+ it "should not dump empty models" do
+ SeedDump.should_not_receive(:dump).with(EmptyModel, anything)
+
+ SeedDump.dump_using_environment(model_env => 'EmptyModel, Sample')
+ end
+ end
end
end
it 'should run ok without ActiveRecord::SchemaMigration being set (needed for Rails Engines)' do
schema_migration = ActiveRecord::SchemaMigration