Sha256: 454ddcb66607f8fb3c63e761de358d0e5123da38d177a6758ab12085292c1f0a

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
massive-0.3.0 spec/models/massive/process_serializer_spec.rb
massive-0.2.0 spec/models/massive/process_serializer_spec.rb
massive-0.1.1 spec/models/massive/process_serializer_spec.rb
massive-0.1.0 spec/models/massive/process_serializer_spec.rb