Sha256: 103d051c1fbebc6f88ab4687dfc16d8ee8d8c9b3ee53991dbeeea77aa80e2b5b

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
require 'classicCMS/cli'
require 'stringio'

describe 'Base' do
  before :all do
    #set directory
    $default[:dir] = Dir.pwd
    $default[:log] = $stdout
    $stdout = StringIO.new
  end
  before :each do
    clear_tmp
    @cli = ClassicCMS::Cli.command ['new']
  end

  it "should display an help message when the app name isn't displayed" do
    capture_log do
      ClassicCMS::Cli.command ['new']
      $stdout.string.should == "hmm you are using the command wrong: classicCMS new [app name]\n"
    end
  end
  it "should display error message when app name already exist" do
    capture_log do
      Dir.mkdir 'app'
      ClassicCMS::Cli.command ['new', 'app']
      $stdout.string.should == "hmm I think that app already exists!\n"
    end
  end
  it "should display message when command is finished" do
    capture_log do
      app_name = 'app'
      ClassicCMS::Cli.command ['new', app_name]
      $stdout.string.should == "#{app_name} created!\n"
    end
  end
  it "should copy scaffolding" do
    capture_log do
      app_name = 'app'
      ClassicCMS::Cli.command ['new', app_name]

      File.directory?(app_name).should == true
    end
  end

  it "should display message that server is starting" do
    capture_log do
      ClassicCMS::Cli.command ['server']
      $stdout.string.should == "going to start server...\n"
    end
  end
  it "should display an error message when command isn't recognized" do
    capture_log do
      ClassicCMS::Cli.command ['nonexistant']
      $stdout.string.should == "you are so smart! I don't know what you mean!\n"
    end
  end

  after :all do
    Dir::chdir $default[:dir]
    $stdout = $default[:log]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
classicCMS-0.2.1 spec/cli_spec.rb
classicCMS-0.2.0 spec/cli_spec.rb