Module: Simulacrum::Methods

Defined in:
lib/simulacrum/methods.rb

Overview

Rspec utility methods for defining components, browser environments

Instance Method Summary collapse

Instance Method Details

#component(name) {|options| ... } ⇒ Object

Yields:

  • (options)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/simulacrum/methods.rb', line 7

def component(name, &block)
  options = OpenStruct.new
  yield options
  component = Simulacrum::Component.new(name, options)
  Simulacrum.components[name] = component

  subject do
    component
  end

  let(:component) do
    component
  end
end

#use_window_size(dimensions) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/simulacrum/methods.rb', line 22

def use_window_size(dimensions)
  subject do
    component.set_window_size(dimensions)
  end

  after(:each) do
    subject.reset_window_size
  end
end