Class: Betterspecs::RSpec

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL
Defined in:
lib/betterspecs/rspec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options) ⇒ RSpec

Returns a new instance of RSpec.



9
10
11
12
# File 'lib/betterspecs/rspec.rb', line 9

def initialize(path,options)
  @path = File.join "betterspecs", path.to_s
  @objects = options.keys
end

Instance Attribute Details

#objectsObject

Returns the value of attribute objects.



7
8
9
# File 'lib/betterspecs/rspec.rb', line 7

def objects
  @objects
end

Instance Method Details

#dump(path, objects) ⇒ Object



20
21
22
23
24
# File 'lib/betterspecs/rspec.rb', line 20

def dump(path, objects)
  File.open(fullpath("#{path}.json"),"w") do |f|
    f.write(objects.to_json)
  end
end

#fullpath(path) ⇒ Object



14
15
16
17
18
# File 'lib/betterspecs/rspec.rb', line 14

def fullpath(path)
  path = File.join [@path, path].compact
  FileUtils.mkdir_p File.dirname(path)
  path
end

#screenshot(path) ⇒ Object



26
27
28
# File 'lib/betterspecs/rspec.rb', line 26

def screenshot(path)
  page.driver.save_screenshot fullpath("#{path}.jpg")
end