Sha256: bbf7c1b73e116b5afeb28e667122a87041610bc700f81c73be0709683ebeead6

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe ActiveGit::ActiveRecord do

  before :each do
    @file_helper = FileHelper.new
    ActiveGit.configuration.working_path = @file_helper.create_temp_folder
  end

  after :each do
    @file_helper.remove_temp_folders
  end

  it 'Registered models' do
    ActiveGit.models.should include Language
  end

  it 'Create' do
    language = Language.create! name: 'Spanish'

    File.exist?(language.git_file).should be_true

    json = JSON.parse(@file_helper.read_file(language.git_file))

    json['id'].should eq language.id
    json['name'].should eq language.name
  end

  it 'Update' do
    language = Language.create! name: 'Spanish'

    json = JSON.parse(@file_helper.read_file(language.git_file))
    json['name'].should eq 'Spanish'

    language.update_attributes name: 'English'

    json = JSON.parse(@file_helper.read_file(language.git_file))
    json['name'].should eq 'English'
  end

  it 'Destroy' do
    language = Language.create! name: 'Spanish'

    File.exist?(language.git_file).should be_true

    language.destroy

    File.exist?(language.git_file).should be_false
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_git-0.0.3 spec/active_record_extension_spec.rb
active_git-0.0.2 spec/active_record_extension_spec.rb
active_git-0.0.1 spec/active_record_extension_spec.rb