Class: Juxtapose::FrankStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/juxtapose/strategy/frank_strategy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ FrankStrategy

Returns a new instance of FrankStrategy.



8
9
10
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 8

def initialize(context)
  self.context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



7
8
9
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 7

def context
  @context
end

Class Method Details

.setupObject



3
4
5
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 3

def self.setup
  Cucumber::RbSupport::RbDsl.register_rb_hook('before', [], Proc.new {|scenario, block| @__scenario = scenario })
end

Instance Method Details

#current_spec_descriptionObject



16
17
18
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 16

def current_spec_description
  context.instance_variable_get('@__scenario').name
end

#device_nameObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 20

def device_name
  screen_type = ''
  name = [context.version]
  if context.version == 'iphone'
    name << 'retina' if width > 320
    name << '5' if height > 960
  else
    name << 'retina' if width > 768
  end

  name.join('-')
end

#save_current(filename) ⇒ Object



33
34
35
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 33

def save_current(filename)
  context.frankly_screenshot(filename, nil, false)
end

#spec_dirObject



37
38
39
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 37

def spec_dir
  "features/screens"
end

#versionObject



12
13
14
# File 'lib/juxtapose/strategy/frank_strategy.rb', line 12

def version
  @version ||= "ios_#{context.app_exec("ios_version").first}"
end