Skip to content

Instantly share code, notes, and snippets.

@dmitriy-kiriyenko
Created February 23, 2012 13:37

Revisions

  1. dmitriy-kiriyenko renamed this gist Feb 23, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. dmitriy-kiriyenko created this gist Feb 23, 2012.
    15 changes: 15 additions & 0 deletions active_model_lint
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # put the file into spec/support
    shared_examples_for "ActiveModel" do
    include ActiveModel::Lint::Tests

    # to_s is to support ruby-1.9
    ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
    example m.gsub('_',' ') do
    send m
    end
    end

    def model
    subject
    end
    end
    10 changes: 10 additions & 0 deletions example_spec.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # implicit subject
    describe MyLooksLikeModelClass do
    it_behaves_like "ActiveModel"
    end

    # explicit subject
    describe "my looks like model class" do
    subject { MyLooksLikeModelClass.new }
    it_behaves_like "ActiveModel"
    end