spec/rocketstarter_spec.rb in rocketstarter-0.0.3 vs spec/rocketstarter_spec.rb in rocketstarter-0.1.0

- old
+ new

@@ -1,11 +1,95 @@ +# This file was wrote by Japanese with UTF8 +# This spec needs sandbox directory, please make "~/sandbox/rocketstarter" directory first! + require File.dirname(__FILE__) + '/spec_helper.rb' +require "~/Sources/secret.rb" -# Time to add your specs! -# http://rspec.info/ -describe "Place your specs here" do + +describe "のspec用のメソッドが動作するとき:" do + it "Hash.includes_hash?を使うと、ハッシュを含むかどうかがわかる事" do + target = {"1" => "a", "2" => "b", "3" => "c"} + target.includes_hash?(target).should be_true + target.includes_hash?({"1" => "a"}).should be_true + target.includes_hash?({"5" => "a"}).should be_false + target.includes_hash?(target.merge({"4" => "d"})).should be_false + end - it "find this spec in spec directory" do - violated "Be sure to write your specs" + it "build_option_stringはハッシュからパラメータ用文字列を生成できる事" do + options = { + "bystring" => "string", + "byflag" => "true", + "project" => "testproj", + } + build_option_string(options).should == " --project=testproj --byflag --bystring=string" end + it 'options.delete("project")を使うと、プロジェクト名を取り出し、ハッシュからは抜ける事' do + options = { + "bystring" => "string", + "byflag" => "true", + "project" => "testproj", + } + project_name = options.delete("project") + project_name.should == "testproj" + build_option_string(options).should == " --byflag --bystring=string" + end end + +describe "のspecが実行された場合:" do + before do + move_to_sandbox + clean_up_sandbox + end + + it "sandboxに移動できる事" do + move_to_sandbox.should be_true + end + + it "sandboxをclean upできる事" do + clean_up_sandbox.should be_true + end + +end + + +describe "に--initオプションを付けた場合:" do + before do + move_to_sandbox + clean_up_sandbox + setup_config_directory + end + + it "最初はconfigファイルとプラグインリストファイルが無い事" do + FileTest::file?(path_of_config_file).should be_false + end + + it "--initを付けるとconfigファイルとプラグインリストファイルのテンプレートが生成される事" do + setup_config_file.should be_true + FileTest::file?(path_of_config_file).should be_true + FileTest::file?(path_of_plugin_list_file).should be_true + end + + it "最初の初期化時はファイルを上書きしない事" do + setup_config_file.should be_true + FileTest::file?(path_of_config_file).should be_true + FileTest::file?(path_of_plugin_list_file).should be_true + end + + it "2回目の初期化時はファイルの上書き確認が表示される事" do + setup_config_file.should be_true + setup_config_file(nil, 4).should be_true + FileTest::file?(path_of_config_file).should be_true + FileTest::file?(path_of_plugin_list_file).should be_true + end + + it "--init時に他のパラメータを付けておくと、デフォルトではなく、パラメータを保存する事" do + options = { + "database" => "sqlite3", + "verbose" => "true", + } + + setup_config_file(options).should be_true + parse_setting.includes_hash?(options).should be_true + end +end +