Sha256: dff4913f47bee1d027acd3b8ee73d20ba9f08a7771d99bdc21bba17a30b0222a
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require 'construct' require 'fileutils' Given(/^I have a camera called "([^"]*)"$/) do |arg1| @config = Construct.new @config.cameras = [{name: "Reception", url: "http://thecamera.org"}] dir="#{ENV['HOME']}/.electric_eye" FileUtils.rm_r(dir) if Dir.exist?(dir) Dir.mkdir(dir) File.open("#{dir}/config.yml","w"){ |f| f.write @config.to_yaml } end Then(/^we should have a directory called "([^"]*)"$/) do |dir| config_dir = File.expand_path(dir) # Expand ~ to ENV["HOME"] expect(Dir.exist?(config_dir)).to equal(true) end Then(/^we should have a file called "([^"]*)"$/) do |dir| config_file = File.expand_path(dir) # Expand ~ to ENV["HOME"] expect(File.exist?(config_file)).to equal(true) end Then(/^within the file "([^"]*)" we should have the camera "([^"]*)"$/) do |file, camera| config_file = File.expand_path(file) # Expand ~ to ENV["HOME"] @config = Construct.load File.read(config_file) expect(@config.cameras.length).to equal(1) expect(@config.cameras.first[:name] == camera).to equal(true) end Then(/^within the file "([^"]*)" we should have the duration "([^"]*)"$/) do |file, duration| config_file = File.expand_path(file) # Expand ~ to ENV["HOME"] @config = Construct.load File.read(config_file) expect(@config.duration == duration.to_i).to equal(true) end Then(/^within the file "([^"]*)" we should have the path "([^"]*)"$/) do |file, path| config_file = File.expand_path(file) # Expand ~ to ENV["HOME"] @config = Construct.load File.read(config_file) expect(@config.path == path).to equal(true) end Then(/^within the file "([^"]*)" we should no cameras$/) do |file| config_file = File.expand_path(file) # Expand ~ to ENV["HOME"] @config = Construct.load File.read(config_file) expect(@config.cameras.length).to equal(0) end
Version data entries
4 entries across 4 versions & 1 rubygems