added a test for the converter rake task

This commit is contained in:
maxwell 2010-12-09 17:17:20 -08:00
parent bf56364019
commit dfbc01ca7a
2 changed files with 31 additions and 1 deletions

View file

@ -1,4 +1,4 @@
namespace :migration do namespace :migrations do
desc 'make old registered services into the new class specific services' desc 'make old registered services into the new class specific services'
task :service_reclassify do task :service_reclassify do
Service.all.each do |s| Service.all.each do |s|

View file

@ -0,0 +1,30 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
require File.join(Rails.root, 'lib/hcard')
describe 'migrations' do
describe 'service_reclassify' do
it 'makes classless servcices have class' do
s1 = Service.new(:access_token => "foo", :access_secret => "barbar", :provider => "facebook")
s2 = Service.new(:access_token => "foo", :access_secret => "barbar", :provider => "twitter")
s1.save
s2.save
require "rake"
@rake = Rake::Application.new
Rake.application = @rake
Rake.application.rake_require "lib/tasks/migrations"
Rake::Task.define_task(:environment)
@rake['migrations:service_reclassify'].invoke
Service.all.any?{|x| x.class.name == "Services::Twitter"}.should be true
Service.all.any?{|x| x.class.name == "Services::Facebook"}.should be true
end
end
end