Sha256: d280f21709a15b39ea9162dbc9d6ddfceec747ed1e74667abe533adcc73f68ab

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
#Opal::RSpec::Runner.autorun
class Thing < ActiveRecord::Base
end

describe "ActiveRecord" do
  before(:each) { React::IsomorphicHelpers.load_context }
  let(:instance) { Thing.new({attr1: 1, attr2: 2, id: 123}) }
  after(:each) { React::API.clear_component_class_cache }

  # uncomment if you are having trouble with tests failing.  One non-async test must pass for things to work

  # describe "a passing dummy test" do
  #   it "passes" do
  #     expect(true).to be(true)
  #   end
  # end

  describe "Instance Methods" do

    it "will have the attributes loaded" do
      expect(instance.attr1).to eq(1)
    end

    it "will not have a primary key if loaded from a hash" do
      expect(instance.id).to be(nil)
    end

    it "reports being changed if new" do
      expect(instance.changed?).to be_truthy
    end

    it "reports not being changed if loaded from db" do
      expect(Thing.find(123).changed?).to be_falsy
    end

    it "reports being changed, if I do change it" do
      Thing.find(1234).my_attribute = "new"
      expect(Thing.find(1234).changed?).to be_truthy
    end

    it "does not think things are destroyed" do
      expect(instance).not_to be_destroyed
    end

    it "can destroy things" do
      instance.destroy
      expect(instance).to be_destroyed
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyper-mesh-0.6.0 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.5.4 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.5.3 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.5.2 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.5.1 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.5.0 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb
hyper-mesh-0.4.0 reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb