Sha256: 9deae7ec211ef3d9b6bfa86da1254dafc9c2314fd8bfcb648a385e055227d393
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require File.dirname(__FILE__)+'/../spec_helper' describe Ginst::Project do context "Validations" do before(:each) do ::Grit::Repo.stub!(:new).and_return(true) File.stub!(:read).with('projects.yml').and_return("--- \n- !ruby/object:Ginst::Project \n dir: /home/guille\n name: guille\n") Ginst::Project.load_projects @prj = Ginst::Project.projects.first end it "should have errors on name if there is no name" do @prj.name = nil @prj.should_not be_valid @prj.name = '' @prj.should_not be_valid end it "should have errors on dir if the dir doesn't exists" do ::Grit::Repo.should_receive(:new).and_raise(::Grit::NoSuchPathError) @prj.should_not be_valid @prj.errors["dir"].should be end it "should have errors on dir if the dir is not a valid git dir" do ::Grit::Repo.should_receive(:new).and_raise(::Grit::InvalidGitRepositoryError) @prj.should_not be_valid @prj.errors["dir"].should be end it "should be able to save a valid project" do ::Grit::Repo.should_receive(:new).with('dir').and_return(true) Ginst::Project.projects.size.should be(1) prj = Ginst::Project.new(VALID_ARGS) prj.should be_valid end it "should not be valid if there is one with the same slug name" do p = Ginst::Project.new(:name => 'guille++', :dir => 'dir') p.should_not be_valid p.errors["name"].should be end it "should not be valid if there is one with the same dir" do p = Ginst::Project.new(:name => 'guille++', :dir => '/home/guille') p.should_not be_valid p.errors["dir"].should be end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ginst-0.2.2 | spec/models/project_validations_spec.rb |