<commit_before>require "spec_helper"

describe "include_url matcher" do
  include RSpec::Sitemap::Matchers
  
  describe "#matches?" do

    shared_examples_for "a matcher that accepts a File or a String" do
      it "passes" do
        sitemap.should include_url('http://www.example.com')
      end

      it "fails" do
        expect {
          sitemap.should include_url('http://www.not-an-example.com')
        }.to raise_error { |error|
          error.message.should match("to include a URL to http://www.not-an-example.com")
        }
      end
    end

    it_should_behave_like "a matcher that accepts a File or a String" do
      let(:sitemap) { fixture('basic') }
    end

    it_should_behave_like "a matcher that accepts a File or a String" do
      let(:sitemap) { fixture('basic').read }
    end
    
    context "on any IO object that has a :read method" do
      let(:sitemap) { mock('sitemap') }
      before do
        sitemap.stub(:read).and_return(fixture('basic').read)
      end
    
      it "should accept any IO that has a :read method on it" do
        sitemap.should include_url('http://www.example.com')
      end
    end
  end

  describe "#priority" do

    context "when it is missing" do
      let(:sitemap) { fixture('basic') }
      it "fails" do
        expect {
          sitemap.should include_url('http://www.example.com').priority('0.5')
        }.to raise_error { |error|
          error.message.should match('to include a URL to http://www.example.com with a priority of 0.5 but the priority was not set')
        }
      end
    end

    context "when it is set" do
      let(:sitemap) { fixture('with_valid_priority') }
      it "passes" do
        sitemap.should include_url('http://www.example.com').priority('0.5')
      end

      it "fails" do
        expect {
          sitemap.should include_url('http://www.example.com').priority('0.8')
        }.to raise_error { |error|
          error.message.should match('to include a URL to http://www.example.com with a priority of 0.8 but it was set to 0.5')
        }
      end
    end


  end

end<commit_msg>Create more readable test output.<commit_after>require "spec_helper"

module RSpec::Sitemap::Matchers
  describe IncludeUrl do
    include RSpec::Sitemap::Matchers
  
    describe "#matches?" do

      shared_examples_for "a matcher that passes or fails" do
        it "passes" do
          sitemap.should include_url('http://www.example.com')
        end

        it "fails" do
          expect {
            sitemap.should include_url('http://www.not-an-example.com')
          }.to raise_error { |error|
            error.message.should match("to include a URL to http://www.not-an-example.com")
          }
        end
      end

      context "on a File" do
        it_should_behave_like "a matcher that passes or fails" do
          let(:sitemap) { fixture('basic') }
        end
      end
      
      context "on a String" do
        it_should_behave_like "a matcher that passes or fails" do
          let(:sitemap) { fixture('basic').read }
        end
      end

      context "on any IO object that has a :read method" do
        before do
          sitemap.stub(:read).and_return(fixture('basic').read)
        end
        
        it_should_behave_like "a matcher that passes or fails" do
          let(:sitemap) { mock('sitemap') }
        end
      end
    end

    describe "#priority" do
      context "when it is set" do
        let(:sitemap) { fixture('with_valid_priority') }
        it "passes" do
          sitemap.should include_url('http://www.example.com').priority('0.5')
        end

        it "fails" do
          expect {
            sitemap.should include_url('http://www.example.com').priority('0.8')
          }.to raise_error { |error|
            error.message.should match('to include a URL to http://www.example.com with a priority of 0.8 but it was set to 0.5')
          }
        end
      end

      context "when it is NOT set" do
        let(:sitemap) { fixture('basic') }
        it "fails" do
          expect {
            sitemap.should include_url('http://www.example.com').priority('0.5')
          }.to raise_error { |error|
            error.message.should match('to include a URL to http://www.example.com with a priority of 0.5 but the priority was not set')
          }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10943223443223443, 'fraction_numerical': 0.005494505494505495, 'mean_word_length': 2.0638148667601683, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 17, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4884562', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1324, 'n_words': 390}