Sha256: b97ec87203963d09daa4e6dc9204b9fe1d8506f2ff699c1fba8427219e87536b

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require "spec_helper"

describe Massive::ProcessSerializer do
  let(:process) { Massive::Process.new }
  subject(:serialized) { described_class.new(process).as_json(root: false) }

  it "serializes process id as string" do
    serialized[:id].should eq(process.id.to_s)
  end

  [:created_at, :updated_at].each do |field|
    it "serializes the #{field}" do
      process[field] = 1.minute.ago
      serialized[field].should eq(process[field])
    end
  end

  it "serializes the processed percentage" do
    process.stub(:processed_percentage).and_return(12)
    serialized[:processed_percentage].should eq(process.processed_percentage)
  end

  context "when it is completed" do
    before { process.stub(:completed?).and_return(true) }

    it "serializes completed" do
      serialized[:completed].should be_true
    end
  end

  context "when it is not completed" do
    before { process.stub(:completed?).and_return(false) }

    it "serializes completed" do
      serialized[:completed].should be_false
    end
  end

  context "when it does not respond to file" do
    it "does not serializes file" do
      serialized[:file].should be_blank
    end
  end

  context "when it responds to file" do
    let(:process) { Massive::FileProcess.new }

    it "serializes file" do
      serialized[:file].should be_present
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
massive-0.4.0 spec/models/massive/process_serializer_spec.rb