Sha256: a30780f0a2a145d1c5b44f4685e7209dd0d99438702565381cf3abd43ffb548d

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

# Copyright:: (c) Autotelik Media Ltd 2012
# Author ::   Tom Statter
# Date ::     April 20121
#
# License::   MIT - Free, OpenSource
#
# Details::   Specification for Thor tasks supplied with datashift
#
require 'thor'
require 'thor/group'
require 'thor/runner'

require File.dirname(__FILE__) + '/spec_helper'

describe 'Thor high level command line tasks' do
         
  before(:all) do
    DataShift::load_commands
  end
  
  before(:each) do
    db_clear_connections
  end
  
  #thor datashift:export:csv -m, --model=MODEL -r, --result=RESULT              ...
  #thor datashift:export:excel -m, --model=MODEL -r, --result=RESULT            ...
  #thor datashift:generate:excel -m, --model=MODEL -r, --result=RESULT          ...
  #thor datashift:import:csv -i, --input=INPUT -m, --model=MODEL                ...
  #thor datashift:import:excel -i, --input=INPUT -m, --model=MODEL              ...
  #thor datashift:paperclip:attach -a, --attachment-klass=ATTACHMENT_KLASS -f, -...                                     ...
  #thor datashift:tools:zip -p, --path=PATH -r, --results=RESULTS               ...

  it "should list available datashift thor tasks" do
    x = capture(:stdout){ Thor::Runner.start(["list"]) }
    x.should =~ /.+datashift.+\n---------\n/
    x.should =~ / csv -i/
    x.should =~ / excel -i/
  end

  # N.B Tasks that fire up Rails application need to be run in own Thread or else get
  #  ...  You cannot have more than one Rails::Application
        
  it "should be able to import a model from a complex excel through import CLI" do
    pending "How to run once rails already initialzed .. error : database configuration does not specify adapter"
    x = Thread.new {
      run_in(rails_sandbox()) do
        stdout = capture(:stdout){ 
          Thor::Runner.start(["datashift:import:excel", '-m', 'Project', '-i', ifixture_file('ProjectsSingleCategories.xls')]) 
          }
        puts stdout
      end
    }
    x.join
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datashift-0.13.0 spec/thor_spec.rb
datashift-0.12.1 spec/thor_spec.rb
datashift-0.12.0 spec/thor_spec.rb
datashift-0.11.1 spec/thor_spec.rb
datashift-0.11.0 spec/thor_spec.rb
datashift-0.10.2 spec/thor_spec.rb
datashift-0.10.1 spec/thor_spec.rb
datashift-0.10.0 spec/thor_spec.rb