Sha256: f883b5ce220fc1e0e5c1275ab8fd77e78b0db1469ed243d7fb3558993c43b813

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

require_relative 'setup'
require 'rspec'
require 'blueprints_boy'
require_relative '../shared'

BlueprintsBoy.enable do |config|
  config.root = File.dirname(__FILE__)
end

describe ActiveRecord::Base do
  it "should create record in database" do
    build :apple
    apple.should be_a(ARFruit)
    apple.should be_persisted
    apple.species.should == 'apple'
  end

  it "should clean database before each test" do
    ARFruit.all.should == []
  end

  it "should use transactions for cleaning database" do
    ActiveRecord::Base.connection.open_transactions.should == 1
  end

  it "should allow building using :new strategy" do
    build_with :new, :apple
    apple.should be_a(ARFruit)
    apple.should be_new_record
    apple.species.should == 'apple'
  end

  it "should allow updating built blueprint" do
    build :apple
    build :apple => {species: 'orange'}
    apple.reload.species.should == 'orange'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blueprints_boy-1.0.0 integration/active_record/active_record_spec.rb