Sha256: 21abfbd34a0001adc454d6fd3c9d16f65c8c931236dcf4d6d0e40f2a8a645da3

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require_relative '../../make_db'
require 'wlog/db_registry'
require 'wlog/domain/log_entry'
require 'wlog/domain/issue'

require 'turntables/turntable'
require 'wlog/commands/replace_pattern'

include Wlog

describe ReplacePattern do
  db_name = './default'
  before(:all) do
    make_testing_db(db_name)
    @db = DbRegistry.new(db_name)
    @issue = Issue.new(@db)
    @log_entry = LogEntry.new(@db)
    @previous_description = "This is my log_entry"

    @issue.description = "This is my issue"
    @issue.insert
    @log_entry.issue_id = @issue.id
    @log_entry.description = @previous_description
    @log_entry.insert
  end

  after(:all) do
    FileUtils.rm db_name
  end

  # I know, tests should not really look for implementation details, but things
  # in our case *should* really inherit the command interface.
  it "should inherit from commandable" do
    command = ReplacePattern.new(@db, @log_entry.id, "asd", "ASD")
    expect(command.is_a? Commandable).to eq(true)
  end

  it "should replace a string in LogEntry on command execution" do
    addition = " my addition"
    command = ReplacePattern.new(@db, @log_entry.id, 'log_entry', 'wlog_entry')
    command.execute
    new_le = LogEntry.find(@db, @log_entry.id)
    expect(new_le.description).to eq('This is my wlog_entry')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wlog-1.1.1 spec/domain/commands/replace_pattern_spec.rb
wlog-1.0.5 spec/domain/commands/replace_pattern_spec.rb