Sha256: ef54708d56a76337ab62f182b024f15bb8fc816ffa9b635bc8ccc4b4437018ca

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Seam::Effort do
  before do
    Seam::Persistence.destroy
  end

  let(:flow) do
    f = Seam::Flow.new
    f.step1
    f.step2
    f
  end

  describe "updating an effort" do
    it "should not create another document in the collection" do
      first_effort = flow.start
      Seam::Persistence.all.count.must_equal 1
      first_effort.save
      Seam::Persistence.all.count.must_equal 1

      second_effort = flow.start
      Seam::Persistence.all.count.must_equal 2
      second_effort.save
      Seam::Persistence.all.count.must_equal 2
    end

    it "should update the information" do
      first_effort = flow.start
      second_effort = flow.start

      first_effort.next_step = 'i_changed_the_first_one'
      first_effort.save
      first_effort.to_hash.contrast_with! Seam::Effort.find(first_effort.id).to_hash, [:id, :created_at]
      second_effort.to_hash.contrast_with! Seam::Effort.find(second_effort.id).to_hash, [:id, :created_at]

      second_effort.next_step = 'i_changed_the_second_one'
      second_effort.save
      first_effort.to_hash.contrast_with! Seam::Effort.find(first_effort.id).to_hash, [:id, :created_at]
      second_effort.to_hash.contrast_with! Seam::Effort.find(second_effort.id).to_hash, [:id, :created_at]
    end
  end

  describe "to effort" do

    it "should find the effort by id" do
      flow.start
      effort = flow.start
      flow.start

      result = SeamEffort.all[1].to_effort

      result.is_a?(Seam::Effort).must_equal true
      result.id.must_equal effort.id
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seam-active_record-1.1.0 test_app/spec/seam/effort_spec.rb