Sha256: b28560f77eae6eaf3497872992ce2ca6b04d702070a600302555df79c174ecd6

Contents?: true

Size: 1.84 KB

Versions: 27

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
require 'scorpion/rails'

describe Scorpion::Rails::ActiveRecord::Relation, type: :model do
  include Scorpion::Rspec::Helper

  let( :criteria ) { Todo.with_scorpion( scorpion ) }

  it "shares scorpion with fetched records" do
    Todo.create! name: "Be awesome"

    expect( criteria.first.scorpion ).to eq scorpion
  end

  it "shares scorpion with chained relations" do
    expect( criteria.where( name: "" ).scorpion ).to be scorpion
  end

  it "shares scorpion with new records" do
    expect( criteria.new.scorpion ).to be scorpion
    expect( criteria.build.scorpion ).to be scorpion
  end

  it "shares scorpion with new records builder block" do
    criteria.new do |todo|
      expect( todo.scorpion ).to be scorpion
    end
  end

  it "shares scorpion with created records" do
    expect( criteria.create.scorpion ).to be scorpion
  end

  it "shares scorpion with created records builder block" do
    criteria.create do |todo|
      expect( todo.scorpion ).to be scorpion
    end
  end

  it "shares scorpion with created! records" do
    expect( criteria.create!.scorpion ).to be scorpion
  end

  it "shares scorpion with created! records builder block" do
    criteria.create! do |todo|
      expect( todo.scorpion ).to be scorpion
    end
  end

  context "find methods" do
    let!( :todo ){ Todo.create! name: "Bill" }

    it "shares scorpion with found records" do
      expect( criteria.find( todo.id ).scorpion ).to be scorpion
    end

    it "shares scorpion with find_by records" do
      expect( criteria.find_by( name: "Bill" ).scorpion ).to be scorpion
    end

    it "shares scorpion with first record" do
      expect( criteria.first.scorpion ).to be scorpion
    end

    it "shares scorpion with enumerated records" do
      criteria.each do |todo|
        expect( todo.scorpion ).to be scorpion
      end
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
scorpion-ioc-0.6.2 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.6.1 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.6.0 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.23 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.22 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.21 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.20 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.19 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.18 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.17 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.16 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.15 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.14 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.13 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.12 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.11 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.10 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.9 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.8 spec/lib/scorpion/rails/active_record/relation_spec.rb
scorpion-ioc-0.5.7 spec/lib/scorpion/rails/active_record/relation_spec.rb