Sha256: ca24b9e22597e843e1ce0dfd7063b7a409cdbee0066d9f329457485663c4278d

Contents?: true

Size: 998 Bytes

Versions: 2

Compression:

Stored size: 998 Bytes

Contents

# coding: utf-8

require 'time'
require 'nokogiri'

module ExampleGroupHelper
  module RetterShortcuts
    def command
      @command ||= Retter::Command.new
    end

    def wip_file
      Retter.entries.wip_file
    end
  end

  module HTML
    def nokogiri(html)
      Nokogiri::HTML(html)
    end

    def texts_of(html, selector)
      nokogiri(html).search(selector).map {|el|
        el.text.strip
      }
    end
  end

  module Stream
    def capture(stream)
      begin
        stream = stream.to_s
        eval "$#{stream} = StringIO.new"
        yield
        result = eval("$#{stream}").string
      ensure
        eval("$#{stream} = #{stream.upcase}")
      end

      result
    end
  end

  module StubTime
    def stub_time(time_str)
      date = Date.parse(time_str)
      time = Time.parse(time_str)

      Date.stub!(:today).and_return(date)
      Time.stub!(:now).and_return(time)
    end
  end

  include RetterShortcuts
  include HTML
  include Stream
  include StubTime
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
retter-0.2.2 spec/support/example_group_helper.rb
retter-0.2.1 spec/support/example_group_helper.rb