spec/shelly/structure_validator_spec.rb in shelly-0.1.14 vs spec/shelly/structure_validator_spec.rb in shelly-0.1.15
- old
+ new
@@ -1,13 +1,14 @@
require "spec_helper"
describe Shelly::StructureValidator do
before do
@validator = Shelly::StructureValidator.new
- Grit::Repo.stub_chain(:new, :status).and_return([
- mock(:path => "Gemfile"), mock(:path => "Gemfile.lock")
- ])
+ statuses = [mock(:type => nil, :path => "Gemfile"),
+ mock(:type => nil, :path => "Gemfile.lock"),
+ mock(:type => nil, :path => "config.ru")]
+ Grit::Repo.stub_chain(:new, :status, :files, :map => statuses)
end
describe "#gemfile?" do
context "when Gemfile exists" do
it "should return true" do
@@ -15,12 +16,13 @@
end
end
context "when Gemfile doesn't exist" do
it "should return false" do
- Grit::Repo.stub_chain(:new, :status) \
- .and_return([mock(:path => "Gemfile.lock")])
+ Grit::Repo.stub_chain(:new, :status, :files,
+ :map => [mock(:type => 'D', :path => "Gemfile"),
+ mock(:type => nil, :path => "Gemfile.lock")])
@validator.gemfile?.should == false
end
end
end
@@ -31,32 +33,28 @@
end
end
context "when Gemfile.lock doesn't exist" do
it "should return false" do
- Grit::Repo.stub_chain(:new, :status) \
- .and_return([mock(:path => "Gemfile")])
+ Grit::Repo.stub_chain(:new, :status, :files,
+ :map => [mock(:type => nil, :path => "Gemfile"),
+ mock(:type => 'D' , :path => "Gemfile.lock")])
@validator.gemfile_lock?.should == false
end
end
end
describe "#config_ru?" do
- before do
- Grit::Repo.stub_chain(:new, :status) \
- .and_return([mock(:path => "config.ru")])
- end
-
context "when config.ru exists" do
it "should return true" do
@validator.config_ru?.should == true
end
end
context "when config.ru doesn't exist" do
it "should return false" do
- Grit::Repo.stub_chain(:new, :status).and_return([])
+ Grit::Repo.stub_chain(:new, :status, :files, :map => [])
@validator.config_ru?.should == false
end
end
end
@@ -71,8 +69,22 @@
@validator.gem?("thin").should be_true
end
it "should return false if gem is missing" do
@validator.gem?("rake").should be_false
+ end
+
+ context "when gemfile doesn't exist" do
+ it "should return false" do
+ @validator.stub(:gemfile? => false)
+ @validator.gem?("thin").should be_false
+ end
+ end
+
+ context "when gemfile.lock doesn't exist" do
+ it "should return false" do
+ @validator.stub(:gemfile_lock? => false)
+ @validator.gem?("thin").should be_false
+ end
end
end
end