Commit de6a8702 authored by Will Pragnell's avatar Will Pragnell

Improved Markdown Acknowledgements unit testing

parent 14821f68
......@@ -2,35 +2,38 @@ require File.expand_path("../../../../spec_helper", __FILE__)
describe Pod::Generator::Markdown do
before do
@podfile = Pod::Podfile.new do
platform :ios
xcodeproj "dummy"
end
@target_definition = @podfile.target_definitions[:default]
@sandbox = temporary_sandbox
@pods = [Pod::LocalPod.new(fixture_spec("banana-lib/BananaLib.podspec"), @sandbox, Pod::Platform.ios)]
copy_fixture_to_pod("banana-lib", @pods[0])
@target_definition = mock
@pods = [mock]
@pods[0].expects(:license_text).returns("LICENSE_TEXT").at_least_once
@pods[0].expects(:name).returns("POD_NAME").at_least_once
@markdown = Pod::Generator::Markdown.new(@target_definition, @pods)
end
it "returns a correctly formatted title string" do
@pods[0].unstub(:license_text)
@pods[0].unstub(:name)
@markdown.title_from_string("A Title").should.equal "A Title\n-------\n"
end
it "returns a correctly formatted license string for each pod" do
@markdown.string_for_pod(@pods[0]).should.equal "BananaLib\n---------\nPermission is hereby granted ...\n"
@markdown.string_for_pod(@pods[0]).should.equal "POD_NAME\n--------\nLICENSE_TEXT\n"
end
it "returns a correctly formatted markdown string for the target" do
@markdown.licenses.should.equal "Acknowledgements\n----------------\nThis application makes use of the following third party libraries:\nBananaLib\n---------\nPermission is hereby granted ...\nGenerated by CocoaPods - http://cocoapods.org\n"
@markdown.stubs(:header_title).returns("HEADER_TITLE")
@markdown.stubs(:header_text).returns("HEADER_TEXT")
@markdown.stubs(:footnote_title).returns("") # Test that extra \n isn't added for empty strings
@markdown.stubs(:footnote_text).returns("FOOTNOTE_TEXT")
@markdown.licenses.should.equal "HEADER_TITLE\n------------\nHEADER_TEXT\nPOD_NAME\n--------\nLICENSE_TEXT\nFOOTNOTE_TEXT\n"
end
# TODO Test the we call File.new with the corret arguments
it "writes a markdown file to disk" do
path = @sandbox.root + "#{@target_definition.label}-Acknowledgements.markdown"
File.any_instance.expects(:write)
File.any_instance.expects(:close)
path = @sandbox.root + "Pods-Acknowledgements.markdown"
mockFile = mock
mockFile.expects(:write).with(equals(@markdown.licenses))
mockFile.expects(:close)
File.expects(:new).with(equals(path), equals("w")).returns(mockFile)
@markdown.save_as(path)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment