Sha256: f92c37825af75d1b636ba4811f31f1b98ad945072e05ddc3d12d3f0a3e4d9053

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

describe Symbiont::Generators do
  let(:watir_browser)    { mock_browser_for_watir }
  let(:watir_definition) { DefinitionTest.new(watir_browser) }

  context "a definition using watir-webdriver" do
    context "providing a url" do
      it "should navigate to the page when viewed" do
        watir_browser.should_receive(:goto)
        watir_definition.view
      end

      it "should navigate to the page when started" do
        watir_browser.should_receive(:goto)
        watir_definition.start
      end
    end
  end

  context "automatically looking for an object" do
    it "should specify and verify an expected object" do
      watir_definition.should_receive(:name_object).and_return(watir_browser)
      watir_browser.should_receive(:when_actionable).with(5).and_return(watir_browser)
      watir_definition.has_object?
    end

    it "should raise an error if an expected object is not verified" do
      class QuickDefinition
        include Symbiont
        look_for :fakeLink
      end
      expect { QuickDefinition.new(watir_browser).has_object? }.to raise_error
      expect { QuickDefinition.new(watir_browser).should_not have_object }.to raise_error
    end
  end

  context "providing a page title to be verified" do
    it "should specify and verify the page title" do
      watir_browser.should_receive(:title).and_return("Symbiote")
      watir_definition.should have_title
    end

    it "should raise an error if the page title is not verified" do
      watir_browser.should_receive(:title).twice.and_return("Incorrect Title")
      expect { watir_definition.has_title? }.to raise_error
    end

    it "should validate the title if provided a regular expression" do
      class QuickDefinition
        include Symbiont
        title_is (/\w+/)
      end
      watir_browser.should_receive(:title).and_return("Symbiote")
      QuickDefinition.new(watir_browser).should have_title
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symbiont-0.2.1 spec/symbiont/generators_spec.rb
symbiont-0.2.0 spec/symbiont/generators_spec.rb