Module: Spinach::FeatureSteps::Capybara

Defined in:
lib/spinach/capybara.rb

Overview

Spinach's capybara module makes Capybara DSL available in all features.

Examples:

require 'spinach/capybara'
class CapybaraFeature < Spinach::FeatureSteps
  Given "I go to the home page" do
    visit '/'
  end
end

Defined Under Namespace

Classes: CapybaraDslDelegator

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(m, *args)



43
44
45
# File 'lib/spinach/capybara.rb', line 43

def method_missing(m, *args)
  instance.send m, *args
end

Instance Method Details

- (Object) instance



39
40
41
# File 'lib/spinach/capybara.rb', line 39

def instance
  @instance ||= CapybaraDslDelegator.new
end

- (Object) null_device



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/spinach/capybara.rb', line 47

def null_device
  return @null_device if defined?(@null_device)

  if RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
    @null_device = "NUL"
  else
    @null_device = "/dev/null"
  end

  @null_device
end

- (Object) visit(*args)



29
30
31
32
33
34
35
36
37
# File 'lib/spinach/capybara.rb', line 29

def visit(*args)
  stream = STDOUT
  old_stream = stream.dup
  stream.reopen(null_device)
  stream.sync = true
  instance.visit *args
ensure
  stream.reopen(old_stream)
end