Module: Capybara::SpecHelper

### Home Classes Methods

### In Files

- lib/capybara/spec/spec_helper.rb

### Methods

- ::configure
- ::filter
- ::reset!
- ::run_specs
- ::spec
- #extract_results
- #quietly
- #silence_stream

### Included Modules

- Capybara::SpecHelper
- Capybara::RSpecMatchers

### Files

- another_test_file.txt
- test_file.txt

### Class/Module Index

Quicksearch

- Capybara
- Capybara::Ambiguous
- Capybara::CapybaraError
- Capybara::DSL
- Capybara::Driver
- Capybara::Driver::Base
- Capybara::Driver::Node
- Capybara::DriverNotFoundError
- Capybara::ElementNotFound
- Capybara::ExpectationNotMet
- Capybara::Features
- Capybara::FileNotFound
- Capybara::FrozenInTime
- Capybara::Helpers
- Capybara::InfiniteRedirectError
- Capybara::ModalNotFound
- Capybara::Node
- Capybara::Node::Actions
- Capybara::Node::Base
- Capybara::Node::Document
- Capybara::Node::DocumentMatchers
- Capybara::Node::Element
- Capybara::Node::Finders
- Capybara::Node::Matchers
- Capybara::Node::Simple
- Capybara::NotSupportedByDriverError
- Capybara::Queries
- Capybara::Queries::BaseQuery
- Capybara::Queries::TextQuery
- Capybara::Queries::TitleQuery
- Capybara::Query
- Capybara::RSpecMatchers
- Capybara::RSpecMatchers::BecomeClosed
- Capybara::RSpecMatchers::HaveSelector
- Capybara::RSpecMatchers::HaveText
- Capybara::RSpecMatchers::HaveTitle
- Capybara::RSpecMatchers::Matcher
- Capybara::RackTest
- Capybara::RackTest::Browser
- Capybara::RackTest::CSSHandlers
- Capybara::RackTest::Driver
- Capybara::RackTest::Form
- Capybara::RackTest::Form::NilUploadedFile
- Capybara::RackTest::Node
- Capybara::ReadOnlyElementError
- Capybara::Result
- Capybara::ScopeError
- Capybara::Selector
- Capybara::Selector::Filter
- Capybara::Selenium
- Capybara::Selenium::Driver
- Capybara::Selenium::Node
- Capybara::Server
- Capybara::Server::Middleware
- Capybara::Session
- Capybara::SpecHelper
- Capybara::UnselectNotAllowed
- Capybara::Window
- Capybara::WindowError
- TestApp
- TestApp::TestAppError
- Object

No matching classes.

# Capybara::SpecHelper

### Public Class Methods

configure(config) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 19
    def configure(config)
      config.filter_run_excluding :requires => method(:filter).to_proc
      config.before { Capybara::SpecHelper.reset! }
      config.after { Capybara::SpecHelper.reset! }
    end

filter(requires, metadata) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 38
    def filter(requires, metadata)
      if requires and metadata[:capybara_skip]
        requires.any? do |require|
          metadata[:capybara_skip].include?(require)
        end
      else
        false
      end
    end

reset!() click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 25
    def reset!
      Capybara.app = TestApp
      Capybara.app_host = nil
      Capybara.default_selector = :xpath
      Capybara.default_wait_time = 1
      Capybara.ignore_hidden_elements = true
      Capybara.exact = false
      Capybara.exact_options = false
      Capybara.raise_server_errors = true
      Capybara.visible_text_only = false
      Capybara.match = :smart
    end

run_specs(session, name, options={}) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 53
    def run_specs(session, name, options={})
      specs = @specs
      RSpec.describe Capybara::Session, name, options do
        include Capybara::SpecHelper
        include Capybara::RSpecMatchers
        before do
          @session = session
        end
        after do
          @session.reset_session!
        end
        specs.each do |spec_name, spec_options, block|
          describe spec_name, spec_options do
            class_eval(&block)
          end
        end
      end
    end

spec(name, options={}, &block) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 48
    def spec(name, options={}, &block)
      @specs ||= []
      @specs << [name, options, block]
    end

### Public Instance Methods

extract_results(session) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 90
    def extract_results(session)
      YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
    end

quietly() click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 82
    def quietly
      silence_stream(STDOUT) do
        silence_stream(STDERR) do
          yield
        end
      end
    end

silence_stream(stream) click to toggle source

    # File lib/capybara/spec/spec_helper.rb, line 73
    def silence_stream(stream)
      old_stream = stream.dup
      stream.reopen(RbConfig::CONFIG['host_os'] =~ /rmswin|mingw/ ? 'NUL:' : '/dev/null')
      stream.sync = true
      yield
    ensure
      stream.reopen(old_stream)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.