spec/lib/cbaoth_spec.rb in cbaoth-0.0.5 vs spec/lib/cbaoth_spec.rb in cbaoth-0.0.6
- old
+ new
@@ -1,36 +1,31 @@
require 'spec_helper'
describe Cbaoth::Generator do
before :all do
- FileUtils.mkdir_p("spec/testing_dir/test")
- Dir.chdir("spec/testing_dir/test")
- end
- before :each do
+ FileUtils.mkdir_p("spec/testing_dir")
+ Dir.chdir("spec/testing_dir")
@generator = Cbaoth::Generator.new
end
- describe '#generate' do
+ describe 'methods' do
+ it { should respond_to :init_variables }
it { should respond_to :generate }
+ it { should respond_to :create_dir_structure }
+ it { should respond_to :generate_base_files }
+ it { should respond_to :alert_user }
end
- describe '#init_variables' do
- it { should respond_to :init_variables }
- it 'initializes and returns 2 instance variables' do
- vars = {}
- vars = @generator.init_variables 'test'
- expect(vars.length).to eq 2
+ describe '#generate' do
+ it 'throws an argument error if arguments are not passed' do
+ expect { @generator.generate }.to raise_error(ArgumentError)
end
- end
- describe '#create_dir_structure' do
- it { should respond_to :create_dir_structure }
- previous_dir = Dir.pwd
- before do
- # Dir.chdir("spec/testing_dir/test")
- dirs = @generator.init_variables 'test'
- @generator.create_dir_structure dirs[:working_directory]
+ it 'generates a base ruby app' do
+ n = nil
+ @generator.generate "test", n
+ Dir.chdir "test"
end
it 'creates the bin dir' do
expect(Dir.exist?("bin")).to be_true
end
@@ -52,18 +47,10 @@
end
it 'creates the log dir' do
expect(Dir.exist?('log')).to be_true
end
- end
-
- describe '#generate_base_files' do
- it { should respond_to :generate_base_files }
- before {
- wd = Dir.pwd
- @generator.generate_base_files wd, "../../../"
- }
it 'creates a rakefile' do
expect(File.exist?("Rakefile")).to be_true
end
it 'creates a gemfile' do
@@ -75,12 +62,25 @@
end
it 'creates a database.yml file' do
expect(File.exist?("config/database.yml")).to be_true
end
- end
- describe '#alert_user' do
- it { should respond_to :alert_user }
+ describe 'git init' do
+ it 'inits git' do
+ n = ""
+ @generator.generate "test", n
+ Dir.chdir "test"
+ expect(Dir.exist?('.git')).to be_true
+ end
+ end
+
+ describe 'ignore git init' do
+ it 'inits git' do
+ n = "-g"
+ @generator.generate "test", n
+ Dir.chdir "test"
+ expect(Dir.exist?('.git')).to be_false
+ end
+ end
end
-
end
\ No newline at end of file