Sha256: 170c7f699b370d9e42ed4b6b03c03b54acc346e28c3a5d212640466408ff8246

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require "spec_helper"

describe Massive::StepSerializer do
  let(:step) { Massive::Step.new }
  subject(:serialized) { described_class.new(step).as_json(root: false) }

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

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

  it "serializes the last_error" do
    step.last_error = "Some error"
    serialized[:last_error].should eq(step.last_error)
  end

  it "serializes notifier_id" do
    serialized[:notifier_id].should eq(step.notifier_id)
  end

  [ :retries, :memory_consumption, :total_count ].each do |field|
    it "serializes the #{field}" do
      step[field] = 100
      serialized[field].should eq(step[field])
    end
  end

  [ :processed, :processed_percentage, :processing_time, :elapsed_time ].each do |field|
    it "serializes the #{field}" do
      step.stub(field).and_return(100)
      serialized[field].should eq(step.send(field))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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