Sha256: e0d0ff956bd2a160f25a3e1e86161ecf9b745def33feb25dbc36946fc0a5f948

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require File.join(File.dirname(__FILE__), "spec_helper")
if RUBY_PLATFORM !~ /(win|w)32|java$/
describe "ActiveModel plugin" do
  specify "should be compliant to the ActiveModel spec" do
    s = ''
    IO.popen('-') do |f|
      if f
        s = f.read
      else
        begin
          require 'active_model'
        rescue LoadError
          puts "0 failures, 0 errors"
        else
          require 'test/unit'
          require "test/unit/ui/console/testrunner"
          class AMLintTest < Test::Unit::TestCase
            def setup
              @c = Class.new(Sequel::Model) do
                def delete; end
              end
              @c.plugin :active_model
              @m = @model = @c.new
              @o = @c.load({})
            end
            include ActiveModel::Lint::Tests

            def test_to_model
              assert_equal @m.to_model.object_id.should, @m.object_id
            end

            def test_new_record
              assert_equal true, @m.new_record?
              assert_equal false, @o.new_record?
            end

            def test_destroyed
              assert_equal false, @m.destroyed?
              assert_equal false, @o.destroyed?
              @m.destroy
              @o.destroy
              assert_equal true, @m.destroyed?
              assert_equal true, @o.destroyed?
            end
          end
          Test::Unit::UI::Console::TestRunner.run(AMLintTest)
        end
      end
    end
    s.should =~ /0 failures, 0 errors/
  end
end 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sequel-3.10.0 spec/extensions/active_model_spec.rb
sequel-3.9.0 spec/extensions/active_model_spec.rb