Sha256: 50d2db558509efd58cc0c12ff36d5d431f213e4fb84380af44236b072779b36c

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require "time"
require "pathname"
require "nikki"

include Nikki

Given(/^I have a journal file$/) do
  @nikki = Generator.new
  @file = @nikki.file
  FileUtils.touch(@file) unless @file.exist?
end

When(/^the journal file can't be found$/) do
  FileUtils.rm(@file) if File.exist?(@file)
end

Then(/^a file should be created$/) do
  FileUtils.touch(@file)
end

Then(/^(my journal entry) saved$/) do |arg|
  File.open(@file,"a") { |f| f.puts @nikki.text(arg) }
end

When(/^it's the first of the month$/) do
  @first = Date.new(2014,2,1)
end

Then(/^the name of the month as an H2 header should be appended$/) do
  File.open(@file, "a") { |file| file.puts "\n## #{@first.strftime("%B").strip}\n\n" }
end

Then(/^and my (entry) should be saved$/) do |arg|
  File.open(@file, "a") { |file| file.puts "#{@first.strftime("%e").strip}. #{arg}" }
end

When(/^it's not the first of the month$/) do
  @not_first = Date.new(2014,2,2)
end

Then(/^my (entry) should be appended along with the day of the month$/) do |arg|
  File.open(@file, "a") { |file| file.puts "#{@not_first.strftime("%e").strip}. #{arg}" }
end

When(/^the mtime of the journal isn't yesterday$/) do
    today = Date.today
    @file.mtime.to_date != Date.today-1
end

Then(/^the journal should open in my editor$/) do
    %x{open -a 'Sublime Text' #{@file}}
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nikki-0.2.0 features/step_definitions/new_entry.steps.rb
nikki-0.1.7 features/step_definitions/new_entry.steps.rb
nikki-0.1.6 features/step_definitions/new_entry.steps.rb
nikki-0.1.5 features/step_definitions/new_entry.steps.rb