Sha256: 37e737f89c0b79c25d90b45f9bd9bfb3e6e1efcc919e01c083356eb3510cd8a0

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

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

    attr_accessor :context
    def initialize(context)
      self.context = context
    end

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

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

    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

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

    def spec_dir
      "features/screens"
    end

    private
    def server
      @_server ||= Frank::Cucumber::Gateway.new( context.base_server_url )
    end

    def resolution
      @resolution ||= JSON.parse(server.send_get('resolution'))
    end

    def width
      resolution['width']
    end

    def height
      resolution['height']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
motion-juxtapose-0.3.2 lib/juxtapose/strategy/frank_strategy.rb
motion-juxtapose-0.3.1 lib/juxtapose/strategy/frank_strategy.rb
motion-juxtapose-0.3.0 lib/juxtapose/strategy/frank_strategy.rb
motion-juxtapose-0.2.0 lib/juxtapose/strategy/frank_strategy.rb
motion-juxtapose-0.1.1 lib/juxtapose/strategy/frank_strategy.rb
motion-juxtapose-0.1.0 lib/juxtapose/strategy/frank_strategy.rb