Sha256: 92d7823096bb5845824ba6656ae94faf73a79eaa1dc05b71e8418923619a2a7a

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require_relative "spec_helper"
require "lignite/ev3_tool"

require "fileutils"

describe Lignite::Ev3Tool do
  around(:each) do |example|
    ENV["LIGNITE_REPLAY"] = replay
    example.call
    subject.close
    ENV["LIGNITE_REPLAY"] = nil
  end

  before(:each) { Lignite::Message.reset_msgid }

  describe "#raw_ls" do
    let(:replay) { "#{datadir}/ev3tool_list_files.yml" }

    it "communicates and returns the right thing" do
      expected = [
        "everstorm.rbf",
        "sneeze.rsf",
        "hey.rsf",
        "right.rsf",
        "ok0.rsf",
        "ok1.rsf",
        "left.rsf"
      ]

      expect(subject.raw_ls("everstorm")).to eq(expected)
    end
  end

  describe "#start" do
    let(:replay) { "#{datadir}/ev3tool_start.yml" }

    it "communicates the right thing" do
      expect { subject.start("everstorm") }.not_to raise_error
    end
  end

  describe "#stop" do
    let(:replay) { "#{datadir}/ev3tool_stop.yml" }

    it "communicates the right thing" do
      expect { subject.stop }.not_to raise_error
    end
  end

  describe "#download" do
    let(:replay) { "#{datadir}/ev3tool_download.yml" }

    it "communicates the right thing" do
      expected_file_contents = File.read("#{datadir}/everstorm.rbf", mode: "rb")
      f = double("File")
      expect(File).to receive(:open).with("everstorm.rbf", "w").and_yield(f)
      allow(File).to receive(:open).and_call_original
      expect(f).to receive(:write).with(expected_file_contents)

      expect { subject.download("../prjs/everstorm/everstorm.rbf") }.not_to raise_error
    end
  end

  describe "#upload" do
    let(:replay) { "#{datadir}/ev3tool_upload.yml" }

    it "communicates the right thing" do
      expect { subject.upload("#{datadir}/HelloWorld.rbf") }.not_to raise_error
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lignite-0.5.0 spec/ev3_tool_spec.rb
lignite-0.4.0 spec/ev3_tool_spec.rb