Merge branch 'master' of github.com:jekyll/jekyll
* 'master' of github.com:jekyll/jekyll: Update history to reflect merge of #3552 [ci skip] Use rspec-mock instead of rr
This commit is contained in:
		
						commit
						3a3b528014
					
				
							
								
								
									
										2
									
								
								Gemfile
								
								
								
								
							
							
						
						
									
										2
									
								
								Gemfile
								
								
								
								
							|  | @ -13,7 +13,6 @@ gem 'rake', '~> 10.1' | ||||||
| gem 'rdoc', '~> 3.11' | gem 'rdoc', '~> 3.11' | ||||||
| gem 'redgreen', '~> 1.2' | gem 'redgreen', '~> 1.2' | ||||||
| gem 'shoulda', '~> 3.5' | gem 'shoulda', '~> 3.5' | ||||||
| gem 'rr', '~> 1.1' |  | ||||||
| gem 'cucumber', '1.3.18' | gem 'cucumber', '1.3.18' | ||||||
| gem 'maruku', '~> 0.7.0' | gem 'maruku', '~> 0.7.0' | ||||||
| gem 'rdiscount', '~> 2.0' | gem 'rdiscount', '~> 2.0' | ||||||
|  | @ -28,6 +27,7 @@ gem 'minitest' | ||||||
| gem 'minitest-reporters' | gem 'minitest-reporters' | ||||||
| gem 'minitest-profile' | gem 'minitest-profile' | ||||||
| gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2") | gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2") | ||||||
|  | gem 'rspec-mocks' | ||||||
| 
 | 
 | ||||||
| if ENV['BENCHMARK'] | if ENV['BENCHMARK'] | ||||||
|   gem 'rbtrace' |   gem 'rbtrace' | ||||||
|  |  | ||||||
|  | @ -96,6 +96,7 @@ | ||||||
|   * Minor fixes to `url.rb` to follow GitHub style guide (#3544) |   * Minor fixes to `url.rb` to follow GitHub style guide (#3544) | ||||||
|   * Minor changes to resolve deprecation warnings (#3547) |   * Minor changes to resolve deprecation warnings (#3547) | ||||||
|   * Convert remaining textile test documents to markdown (#3528) |   * Convert remaining textile test documents to markdown (#3528) | ||||||
|  |   * Migrate the tests to use rspec-mocks (#3552) | ||||||
| 
 | 
 | ||||||
| ### Site Enhancements | ### Site Enhancements | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,5 @@ | ||||||
| require 'fileutils' | require 'fileutils' | ||||||
| require 'posix-spawn' | require 'posix-spawn' | ||||||
| require 'rr' |  | ||||||
| require 'minitest/assertions' | require 'minitest/assertions' | ||||||
| require 'time' | require 'time' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ require 'ostruct' | ||||||
| require 'minitest/autorun' | require 'minitest/autorun' | ||||||
| require 'minitest/reporters' | require 'minitest/reporters' | ||||||
| require 'minitest/profile' | require 'minitest/profile' | ||||||
|  | require 'rspec/mocks' | ||||||
| 
 | 
 | ||||||
| require 'jekyll' | require 'jekyll' | ||||||
| 
 | 
 | ||||||
|  | @ -19,7 +20,6 @@ require 'kramdown' | ||||||
| require 'redcarpet' | require 'redcarpet' | ||||||
| 
 | 
 | ||||||
| require 'shoulda' | require 'shoulda' | ||||||
| require 'rr' |  | ||||||
| 
 | 
 | ||||||
| include Jekyll | include Jekyll | ||||||
| 
 | 
 | ||||||
|  | @ -30,6 +30,20 @@ STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:') | ||||||
| Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)] | Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)] | ||||||
| 
 | 
 | ||||||
| class JekyllUnitTest < Minitest::Test | class JekyllUnitTest < Minitest::Test | ||||||
|  |   include ::RSpec::Mocks::ExampleMethods | ||||||
|  | 
 | ||||||
|  |   def before_setup | ||||||
|  |     ::RSpec::Mocks.setup | ||||||
|  |     super | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|  |   def after_teardown | ||||||
|  |     super | ||||||
|  |     ::RSpec::Mocks.verify | ||||||
|  |   ensure | ||||||
|  |     ::RSpec::Mocks.teardown | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   def fixture_site(overrides = {}) |   def fixture_site(overrides = {}) | ||||||
|     Jekyll::Site.new(site_configuration(overrides)) |     Jekyll::Site.new(site_configuration(overrides)) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ class TestCommand < JekyllUnitTest | ||||||
|   context "when calling .add_build_options" do |   context "when calling .add_build_options" do | ||||||
|     should "add common options" do |     should "add common options" do | ||||||
|       cmd = Object.new |       cmd = Object.new | ||||||
|       mock(cmd).option.with_any_args.at_least(1) |       expect(cmd).to receive(:option).at_least(:once) | ||||||
|       Command.add_build_options(cmd) |       Command.add_build_options(cmd) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -12,7 +12,7 @@ class TestCommand < JekyllUnitTest | ||||||
|     context "when fatal error occurs" do |     context "when fatal error occurs" do | ||||||
|       should "exit with non-zero error code" do |       should "exit with non-zero error code" do | ||||||
|         site = Object.new |         site = Object.new | ||||||
|         stub(site).process { raise Jekyll::Errors::FatalException } |         def site.process; raise Jekyll::Errors::FatalException; end | ||||||
|         error = assert_raises(SystemExit) { Command.process_site(site) } |         error = assert_raises(SystemExit) { Command.process_site(site) } | ||||||
|         refute_equal 0, error.status |         refute_equal 0, error.status | ||||||
|       end |       end | ||||||
|  |  | ||||||
|  | @ -42,12 +42,12 @@ class TestConfiguration < JekyllUnitTest | ||||||
|       assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) |       assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) | ||||||
|     end |     end | ||||||
|     should "return .yaml if it exists but .yml does not" do |     should "return .yaml if it exists but .yml does not" do | ||||||
|       mock(File).exist?(source_dir("_config.yml")) { false } |       allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(false) | ||||||
|       mock(File).exist?(source_dir("_config.yaml")) { true } |       allow(File).to receive(:exist?).with(source_dir("_config.yaml")).and_return(true) | ||||||
|       assert_equal [source_dir("_config.yaml")], @config.config_files(@no_override) |       assert_equal [source_dir("_config.yaml")], @config.config_files(@no_override) | ||||||
|     end |     end | ||||||
|     should "return .yml if both .yml and .yaml exist" do |     should "return .yml if both .yml and .yaml exist" do | ||||||
|       mock(File).exist?(source_dir("_config.yml")) { true } |       allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(true) | ||||||
|       assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) |       assert_equal [source_dir("_config.yml")], @config.config_files(@no_override) | ||||||
|     end |     end | ||||||
|     should "return the config if given one config file" do |     should "return the config if given one config file" do | ||||||
|  | @ -115,27 +115,27 @@ class TestConfiguration < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "fire warning with no _config.yml" do |     should "fire warning with no _config.yml" do | ||||||
|       mock(SafeYAML).load_file(@path) { raise SystemCallError, "No such file or directory - #{@path}" } |       allow(SafeYAML).to receive(:load_file).with(@path) { raise SystemCallError, "No such file or directory - #{@path}" } | ||||||
|       mock($stderr).puts("Configuration file: none".yellow) |       allow($stderr).to receive(:puts).with("Configuration file: none".yellow) | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load configuration as hash" do |     should "load configuration as hash" do | ||||||
|       mock(SafeYAML).load_file(@path) { Hash.new } |       allow(SafeYAML).to receive(:load_file).with(@path).and_return(Hash.new) | ||||||
|       mock($stdout).puts("Configuration file: #{@path}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@path}") | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "fire warning with bad config" do |     should "fire warning with bad config" do | ||||||
|       mock(SafeYAML).load_file(@path) { Array.new } |       allow(SafeYAML).to receive(:load_file).with(@path).and_return(Array.new) | ||||||
|       mock($stderr).puts(("WARNING: ".rjust(20) + "Error reading configuration. Using defaults (and options).").yellow) |       allow($stderr).to receive(:puts).and_return(("WARNING: ".rjust(20) + "Error reading configuration. Using defaults (and options).").yellow) | ||||||
|       mock($stderr).puts("Configuration file: (INVALID) #{@path}".yellow) |       allow($stderr).to receive(:puts).and_return("Configuration file: (INVALID) #{@path}".yellow) | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "fire warning when user-specified config file isn't there" do |     should "fire warning when user-specified config file isn't there" do | ||||||
|       mock(SafeYAML).load_file(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" } |       allow(SafeYAML).to receive(:load_file).with(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" } | ||||||
|       mock($stderr).puts(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red) |       allow($stderr).to receive(:puts).with(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red) | ||||||
|       assert_raises LoadError do |       assert_raises LoadError do | ||||||
|         Jekyll.configuration({'config' => [@user_config]}) |         Jekyll.configuration({'config' => [@user_config]}) | ||||||
|       end |       end | ||||||
|  | @ -157,20 +157,20 @@ class TestConfiguration < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load default config if no config_file is set" do |     should "load default config if no config_file is set" do | ||||||
|       mock(SafeYAML).load_file(@paths[:default]) { Hash.new } |       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:default]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({}) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load different config if specified" do |     should "load different config if specified" do | ||||||
|       mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } |       allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"}) | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] }) |       assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] }) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load default config if path passed is empty" do |     should "load default config if path passed is empty" do | ||||||
|       mock(SafeYAML).load_file(@paths[:default]) { Hash.new } |       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({}) | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:default]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({ "config" => @paths[:empty] }) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({ "config" => @paths[:empty] }) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -183,20 +183,20 @@ class TestConfiguration < JekyllUnitTest | ||||||
|     should "load multiple config files" do |     should "load multiple config files" do | ||||||
|       External.require_with_graceful_fail('toml') |       External.require_with_graceful_fail('toml') | ||||||
| 
 | 
 | ||||||
|       mock(SafeYAML).load_file(@paths[:default]) { Hash.new } |       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return(Hash.new) | ||||||
|       mock(SafeYAML).load_file(@paths[:other]) { Hash.new } |       allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return(Hash.new) | ||||||
|       mock(TOML).load_file(@paths[:toml]) { Hash.new } |       allow(TOML).to receive(:load_file).with(@paths[:toml]).and_return(Hash.new) | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:default]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:toml]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:toml]}") | ||||||
|       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({ "config" => [@paths[:default], @paths[:other], @paths[:toml]] }) |       assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({ "config" => [@paths[:default], @paths[:other], @paths[:toml]] }) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "load multiple config files and last config should win" do |     should "load multiple config files and last config should win" do | ||||||
|       mock(SafeYAML).load_file(@paths[:default]) { {"baseurl" => "http://example.dev"} } |       allow(SafeYAML).to receive(:load_file).with(@paths[:default]).and_return({"baseurl" => "http://example.dev"}) | ||||||
|       mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } |       allow(SafeYAML).to receive(:load_file).with(@paths[:other]).and_return({"baseurl" => "http://wahoo.dev"}) | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:default]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:default]}") | ||||||
|       mock($stdout).puts("Configuration file: #{@paths[:other]}") |       allow($stdout).to receive(:puts).with("Configuration file: #{@paths[:other]}") | ||||||
|       assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) |       assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -48,13 +48,13 @@ class TestEntryFilter < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     should "filter symlink entries when safe mode enabled" do |     should "filter symlink entries when safe mode enabled" do | ||||||
|       site = Site.new(site_configuration('safe' => true)) |       site = Site.new(site_configuration('safe' => true)) | ||||||
|       stub(File).symlink?('symlink.js') {true} |       allow(File).to receive(:symlink?).with('symlink.js').and_return(true) | ||||||
|       files = %w[symlink.js] |       files = %w[symlink.js] | ||||||
|       assert_equal [], site.filter_entries(files) |       assert_equal [], site.filter_entries(files) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "not filter symlink entries when safe mode disabled" do |     should "not filter symlink entries when safe mode disabled" do | ||||||
|       stub(File).symlink?('symlink.js') {true} |       allow(File).to receive(:symlink?).with('symlink.js').and_return(true) | ||||||
|       files = %w[symlink.js] |       files = %w[symlink.js] | ||||||
|       assert_equal files, @site.filter_entries(files) |       assert_equal files, @site.filter_entries(files) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -4,11 +4,9 @@ class TestGeneratedSite < JekyllUnitTest | ||||||
|   context "generated sites" do |   context "generated sites" do | ||||||
|     setup do |     setup do | ||||||
|       clear_dest |       clear_dest | ||||||
|       stub(Jekyll).configuration do |       config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       @site = Site.new(Jekyll.configuration) |       @site = fixture_site config | ||||||
|       @site.process |       @site.process | ||||||
|       @index = File.read(dest_dir('index.html')) |       @index = File.read(dest_dir('index.html')) | ||||||
|     end |     end | ||||||
|  | @ -59,11 +57,8 @@ OUTPUT | ||||||
|   context "generating limited posts" do |   context "generating limited posts" do | ||||||
|     setup do |     setup do | ||||||
|       clear_dest |       clear_dest | ||||||
|       stub(Jekyll).configuration do |       config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 5}) | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 5}) |       @site = fixture_site config | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       @site = Site.new(Jekyll.configuration) |  | ||||||
|       @site.process |       @site.process | ||||||
|       @index = File.read(dest_dir('index.html')) |       @index = File.read(dest_dir('index.html')) | ||||||
|     end |     end | ||||||
|  | @ -75,21 +70,17 @@ OUTPUT | ||||||
|     should "ensure limit posts is 0 or more" do |     should "ensure limit posts is 0 or more" do | ||||||
|       assert_raises ArgumentError do |       assert_raises ArgumentError do | ||||||
|         clear_dest |         clear_dest | ||||||
|         stub(Jekyll).configuration do |         config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => -1}) | ||||||
|           Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => -1}) |  | ||||||
|         end |  | ||||||
| 
 | 
 | ||||||
|         @site = Site.new(Jekyll.configuration) |         @site = fixture_site config | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "acceptable limit post is 0" do |     should "acceptable limit post is 0" do | ||||||
|       clear_dest |       clear_dest | ||||||
|       stub(Jekyll).configuration do |       config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0}) | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0}) |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       assert Site.new(Jekyll.configuration), "Couldn't create a site with the given limit_posts." |       assert Site.new(config), "Couldn't create a site with the given limit_posts." | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -3,10 +3,8 @@ require 'helper' | ||||||
| class TestLayoutReader < JekyllUnitTest | class TestLayoutReader < JekyllUnitTest | ||||||
|   context "reading layouts" do |   context "reading layouts" do | ||||||
|     setup do |     setup do | ||||||
|       stub(Jekyll).configuration do |       config = Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir}) |       @site = fixture_site config | ||||||
|       end |  | ||||||
|       @site = Site.new(Jekyll.configuration) |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "read layouts" do |     should "read layouts" do | ||||||
|  | @ -22,8 +20,8 @@ class TestLayoutReader < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|     context "when a _layouts directory exists in CWD" do |     context "when a _layouts directory exists in CWD" do | ||||||
|       setup do |       setup do | ||||||
|         stub(File).directory? { true } |         allow(File).to receive(:directory?).and_return(true) | ||||||
|         stub(Dir).pwd { source_dir("blah") } |         allow(Dir).to receive(:pwd).and_return(source_dir("blah")) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       should "know to use the layout directory relative to CWD" do |       should "know to use the layout directory relative to CWD" do | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ class TestLogAdapter < JekyllUnitTest | ||||||
|     should "call #debug on writer return true" do |     should "call #debug on writer return true" do | ||||||
|       writer = LoggerDouble.new |       writer = LoggerDouble.new | ||||||
|       logger = Jekyll::LogAdapter.new(writer) |       logger = Jekyll::LogAdapter.new(writer) | ||||||
|       stub(writer).debug('topic '.rjust(20) + 'log message') { true } |       allow(writer).to receive(:debug).with('topic '.rjust(20) + 'log message').and_return(true) | ||||||
|       assert logger.debug('topic', 'log message') |       assert logger.debug('topic', 'log message') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -31,7 +31,7 @@ class TestLogAdapter < JekyllUnitTest | ||||||
|     should "call #info on writer return true" do |     should "call #info on writer return true" do | ||||||
|       writer = LoggerDouble.new |       writer = LoggerDouble.new | ||||||
|       logger = Jekyll::LogAdapter.new(writer) |       logger = Jekyll::LogAdapter.new(writer) | ||||||
|       stub(writer).info('topic '.rjust(20) + 'log message') { true } |       allow(writer).to receive(:info).with('topic '.rjust(20) + 'log message').and_return(true) | ||||||
|       assert logger.info('topic', 'log message') |       assert logger.info('topic', 'log message') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -40,7 +40,7 @@ class TestLogAdapter < JekyllUnitTest | ||||||
|     should "call #warn on writer return true" do |     should "call #warn on writer return true" do | ||||||
|       writer = LoggerDouble.new |       writer = LoggerDouble.new | ||||||
|       logger = Jekyll::LogAdapter.new(writer) |       logger = Jekyll::LogAdapter.new(writer) | ||||||
|       stub(writer).warn('topic '.rjust(20) + 'log message') { true } |       allow(writer).to receive(:warn).with('topic '.rjust(20) + 'log message').and_return(true) | ||||||
|       assert logger.warn('topic', 'log message') |       assert logger.warn('topic', 'log message') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -49,7 +49,7 @@ class TestLogAdapter < JekyllUnitTest | ||||||
|     should "call #error on writer return true" do |     should "call #error on writer return true" do | ||||||
|       writer = LoggerDouble.new |       writer = LoggerDouble.new | ||||||
|       logger = Jekyll::LogAdapter.new(writer) |       logger = Jekyll::LogAdapter.new(writer) | ||||||
|       stub(writer).error('topic '.rjust(20) + 'log message') { true } |       allow(writer).to receive(:error).with('topic '.rjust(20) + 'log message').and_return(true) | ||||||
|       assert logger.error('topic', 'log message') |       assert logger.error('topic', 'log message') | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -57,7 +57,7 @@ class TestLogAdapter < JekyllUnitTest | ||||||
|   context "#abort_with" do |   context "#abort_with" do | ||||||
|     should "call #error and abort" do |     should "call #error and abort" do | ||||||
|       logger = Jekyll::LogAdapter.new(LoggerDouble.new) |       logger = Jekyll::LogAdapter.new(LoggerDouble.new) | ||||||
|       stub(logger).error('topic', 'log message') { true } |       allow(logger).to receive(:error).with('topic', 'log message').and_return(true) | ||||||
|       assert_raises(SystemExit) { logger.abort_with('topic', 'log message') } |       assert_raises(SystemExit) { logger.abort_with('topic', 'log message') } | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ class TestNewCommand < JekyllUnitTest | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       stubbed_date = '2013-01-01' |       stubbed_date = '2013-01-01' | ||||||
|       stub.instance_of(Time).strftime { stubbed_date } |       allow_any_instance_of(Time).to receive(:strftime) { stubbed_date } | ||||||
| 
 | 
 | ||||||
|       erb_template_files.each do |f| |       erb_template_files.each do |f| | ||||||
|         f.chomp! '.erb' |         f.chomp! '.erb' | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ class TestPathSanitization < JekyllUnitTest | ||||||
|     setup do |     setup do | ||||||
|       @source = "C:/Users/xmr/Desktop/mpc-hc.org" |       @source = "C:/Users/xmr/Desktop/mpc-hc.org" | ||||||
|       @dest   = "./_site/" |       @dest   = "./_site/" | ||||||
|       stub(Dir).pwd { "C:/Users/xmr/Desktop/mpc-hc.org" } |       allow(Dir).to receive(:pwd).and_return("C:/Users/xmr/Desktop/mpc-hc.org") | ||||||
|     end |     end | ||||||
|     should "strip drive name from path" do |     should "strip drive name from path" do | ||||||
|       assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest) |       assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest) | ||||||
|  |  | ||||||
|  | @ -3,11 +3,7 @@ require 'helper' | ||||||
| class TestRelatedPosts < JekyllUnitTest | class TestRelatedPosts < JekyllUnitTest | ||||||
|   context "building related posts without lsi" do |   context "building related posts without lsi" do | ||||||
|     setup do |     setup do | ||||||
|       stub(Jekyll).configuration do |       @site = fixture_site | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, |  | ||||||
|                                                'destination' => dest_dir}) |  | ||||||
|       end |  | ||||||
|       @site = Site.new(Jekyll.configuration) |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "use the most recent posts for related posts" do |     should "use the most recent posts for related posts" do | ||||||
|  | @ -24,23 +20,17 @@ class TestRelatedPosts < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   context "building related posts with lsi" do |   context "building related posts with lsi" do | ||||||
|     setup do |     setup do | ||||||
|       stub(Jekyll).configuration do |       allow_any_instance_of(Jekyll::RelatedPosts).to receive(:display) | ||||||
|         Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, |       @site = fixture_site({"lsi" => true}) | ||||||
|                                                'destination' => dest_dir, |  | ||||||
|                                                'lsi' => true}) |  | ||||||
|       end |  | ||||||
|       any_instance_of(Jekyll::RelatedPosts) { |i| stub(i).display } |  | ||||||
|       @site = Site.new(Jekyll.configuration) |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "use lsi for the related posts" do |     should "use lsi for the related posts" do | ||||||
|       @site.reset |       @site.reset | ||||||
|       @site.read |       @site.read | ||||||
|       require 'classifier-reborn' |       require 'classifier-reborn' | ||||||
|       any_instance_of(::ClassifierReborn::LSI) do |c| |       allow_any_instance_of(::ClassifierReborn::LSI).to receive(:find_related).and_return(@site.posts[-1..-9]) | ||||||
|         stub(c).find_related { @site.posts[-1..-9] } |       allow_any_instance_of(::ClassifierReborn::LSI).to receive(:build_index) | ||||||
|         stub(c).build_index | 
 | ||||||
|       end |  | ||||||
|       assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build |       assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -162,7 +162,8 @@ class TestSite < JekyllUnitTest | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     should "sort pages alphabetically" do |     should "sort pages alphabetically" do | ||||||
|       stub.proxy(Dir).entries { |entries| entries.reverse } |       method = Dir.method(:entries) | ||||||
|  |       allow(Dir).to receive(:entries) { |*args, &block| method.call(*args, &block).reverse } | ||||||
|       @site.process |       @site.process | ||||||
|       # files in symlinked directories may appear twice |       # files in symlinked directories may appear twice | ||||||
|       sorted_pages = %w( |       sorted_pages = %w( | ||||||
|  |  | ||||||
|  | @ -5,12 +5,7 @@ require 'helper' | ||||||
| class TestTags < JekyllUnitTest | class TestTags < JekyllUnitTest | ||||||
| 
 | 
 | ||||||
|   def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown) |   def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown) | ||||||
|     stub(Jekyll).configuration do |     site = fixture_site({"highlighter" => "rouge"}.merge(override)) | ||||||
|       site_configuration({ |  | ||||||
|         "highlighter" => "rouge" |  | ||||||
|       }.merge(override)) |  | ||||||
|     end |  | ||||||
|     site = Site.new(Jekyll.configuration) |  | ||||||
| 
 | 
 | ||||||
|     if override['read_posts'] |     if override['read_posts'] | ||||||
|       site.read_posts('') |       site.read_posts('') | ||||||
|  | @ -645,11 +640,7 @@ CONTENT | ||||||
| 
 | 
 | ||||||
|     context "include tag with variable and liquid filters" do |     context "include tag with variable and liquid filters" do | ||||||
|       setup do |       setup do | ||||||
|         stub(Jekyll).configuration do |         site = fixture_site({'pygments' => true}) | ||||||
|           site_configuration({'pygments' => true}) |  | ||||||
|         end |  | ||||||
| 
 |  | ||||||
|         site = Site.new(Jekyll.configuration) |  | ||||||
|         post = Post.new(site, source_dir, '', "2013-12-17-include-variable-filters.markdown") |         post = Post.new(site, source_dir, '', "2013-12-17-include-variable-filters.markdown") | ||||||
|         layouts = { "default" => Layout.new(site, source_dir('_layouts'), "simple.html")} |         layouts = { "default" => Layout.new(site, source_dir('_layouts'), "simple.html")} | ||||||
|         post.render(layouts, {"site" => {"posts" => []}}) |         post.render(layouts, {"site" => {"posts" => []}}) | ||||||
|  | @ -681,11 +672,7 @@ CONTENT | ||||||
| 
 | 
 | ||||||
|   context "relative include tag with variable and liquid filters" do |   context "relative include tag with variable and liquid filters" do | ||||||
|     setup do |     setup do | ||||||
|       stub(Jekyll).configuration do |       site = fixture_site('pygments' => true) | ||||||
|         site_configuration({'pygments' => true}) |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       site = Site.new(Jekyll.configuration) |  | ||||||
|       post = Post.new(site, source_dir, '', "2014-09-02-relative-includes.markdown") |       post = Post.new(site, source_dir, '', "2014-09-02-relative-includes.markdown") | ||||||
|       layouts = { "default" => Layout.new(site, source_dir('_layouts'), "simple.html")} |       layouts = { "default" => Layout.new(site, source_dir('_layouts'), "simple.html")} | ||||||
|       post.render(layouts, {"site" => {"posts" => []}}) |       post.render(layouts, {"site" => {"posts" => []}}) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue