Commit 2f53505825c380b1b2d5f30c006c22b68a205213
1 parent
05e6bab4
Exists in
master
and in
1 other branch
Not require 'rake' in test suite
To test the rake db:seeds task require the db/seeds.rb file instead of require 'task' and launch the task. Avoid useless output on test to stubing Kernel.puts
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
spec/models/user_spec.rb
| ... | ... | @@ -71,10 +71,12 @@ describe User do |
| 71 | 71 | |
| 72 | 72 | context "First user" do |
| 73 | 73 | it "should be created this admin access via db:seed" do |
| 74 | - require 'rake' | |
| 75 | - Errbit::Application.load_tasks | |
| 76 | - Rake::Task["db:seed"].execute | |
| 77 | - User.first.admin.should be_true | |
| 74 | + expect { | |
| 75 | + $stdout.stub(:puts => true) | |
| 76 | + require Rails.root.join('db/seeds.rb') | |
| 77 | + }.to change { | |
| 78 | + User.where(:admin => true).count | |
| 79 | + }.from(0).to(1) | |
| 78 | 80 | end |
| 79 | 81 | end |
| 80 | 82 | ... | ... |