<commit_before>require File.expand_path(File.dirname(__FILE__) + "/spec_helper")

describe Rsel::SeleniumTest do
  before(:all) do
    @st = Rsel::SeleniumTest.new('http://localhost:8070/')
    @st.open_browser
  end

  after(:all) do
    @st.close_browser
  end

  context "initialization" do
    before(:each) do
      @st.visit("/")
    end

    it "sets correct default configuration" do
      @st.url.should == "http://localhost:8070/"
      @st.browser.host.should == "localhost"
      @st.browser.port.should == 4444
    end
  end


  context "navigation" do
    before(:each) do
      @st.visit("/").should be_true
    end

    describe "#visit" do
      context "passes when" do
        it "page exists" do
          @st.visit("/about").should be_true
        end
      end

      # FIXME: Selenium server 2.3.0 and 2.4.0 no longer fail
      # when a 404 or 500 error is raised
      #context "fails when" do
        #it "page gets a 404 error" do
          #@st.visit("/404").should be_false
        #end
        #it "page gets a 500 error" do
          #@st.visit("/500").should be_false
        #end
      #end
    end

    context "reload the current page" do
      # TODO
    end

    describe "#click_back" do
      it "passes and loads the correct URL" do
        @st.visit("/about")
        @st.visit("/")
        @st.click_back.should be_true
        @st.see_title("About this site").should be_true
      end

      #it "fails when there is no previous page in the history" do
        # TODO: No obvious way to test this, since everything is running in the
        # same session
      #end
    end
  end # navigation


  context "visibility" do
    before(:each) do
      @st.visit("/").should be_true
    end

    describe "#see" do
      context "passes when" do
        it "text is present" do
          @st.see("Welcome").should be_true
          @st.see("This is a Sinatra webapp").should be_true
        end
      end

      context "fails when" do
        it "text is absent" do
          @st.see("Nonexistent").should be_false
          @st.see("Some bogus text").should be_false
        end
      end

      it "is case-sensitive" do
        @st.see("Sinatra webapp").should be_true
        @st.see("sinatra Webapp").should be_false
      end
    end

    describe "#do_not_see" do
      context "passes when" do
        it "text is absent" do
          @st.do_not_see("Nonexistent").should be_true
          @st.do_not_see("Some bogus text").should be_true
        end
      end

      context "fails when" do
        it "fails when text is present" do
          @st.do_not_see("Welcome").should be_false
          @st.do_not_see("This is a Sinatra webapp").should be_false
        end
      end<commit_msg>Rephrase spec name<commit_after>require File.expand_path(File.dirname(__FILE__) + "/spec_helper")

describe Rsel::SeleniumTest do
  before(:all) do
    @st = Rsel::SeleniumTest.new('http://localhost:8070/')
    @st.open_browser
  end

  after(:all) do
    @st.close_browser
  end

  context "initialization" do
    before(:each) do
      @st.visit("/")
    end

    it "sets correct default configuration" do
      @st.url.should == "http://localhost:8070/"
      @st.browser.host.should == "localhost"
      @st.browser.port.should == 4444
    end
  end


  context "navigation" do
    before(:each) do
      @st.visit("/").should be_true
    end

    describe "#visit" do
      context "passes when" do
        it "page exists" do
          @st.visit("/about").should be_true
        end
      end

      # FIXME: Selenium server 2.3.0 and 2.4.0 no longer fail
      # when a 404 or 500 error is raised
      #context "fails when" do
        #it "page gets a 404 error" do
          #@st.visit("/404").should be_false
        #end
        #it "page gets a 500 error" do
          #@st.visit("/500").should be_false
        #end
      #end
    end

    context "reload the current page" do
      # TODO
    end

    describe "#click_back" do
      it "passes and loads the correct URL" do
        @st.visit("/about")
        @st.visit("/")
        @st.click_back.should be_true
        @st.see_title("About this site").should be_true
      end

      #it "fails when there is no previous page in the history" do
        # TODO: No obvious way to test this, since everything is running in the
        # same session
      #end
    end
  end # navigation


  context "visibility" do
    before(:each) do
      @st.visit("/").should be_true
    end

    describe "#see" do
      context "passes when" do
        it "text is present" do
          @st.see("Welcome").should be_true
          @st.see("This is a Sinatra webapp").should be_true
        end
      end

      context "fails when" do
        it "text is absent" do
          @st.see("Nonexistent").should be_false
          @st.see("Some bogus text").should be_false
        end
      end

      it "is case-sensitive" do
        @st.see("Sinatra webapp").should be_true
        @st.see("sinatra Webapp").should be_false
      end
    end

    describe "#do_not_see" do
      context "passes when" do
        it "text is absent" do
          @st.do_not_see("Nonexistent").should be_true
          @st.do_not_see("Some bogus text").should be_true
        end
      end

      context "fails when" do
        it "text is present" do
          @st.do_not_see("Welcome").should be_false
          @st.do_not_see("This is a Sinatra webapp").should be_false
        end
      end
{'fraction_non_alphanumeric': 0.1071689831748354, 'fraction_numerical': 0.013167520117044623, 'mean_word_length': 2.0165471594043023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2197983', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1688, 'n_words': 523}