Sha256: 49b6d2d1c1bb09dbda4bb8043b38efe45babaa2d64426bda8c15e731fd707574

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

Contents

shared_examples "an accessible token" do
  describe :accessible? do
    it "is accessible if token is not expired" do
      subject.stub :expired? => false
      should be_accessible
    end

    it "is not accessible if token is expired" do
      subject.stub :expired? => true
      should_not be_accessible
    end
  end
end

shared_examples "a revocable token" do
  describe :accessible? do
    before { subject.save! }

    it "is accessible if token is not revoked" do
      subject.should be_accessible
    end

    it "is not accessible if token is revoked" do
      subject.revoke
      subject.should_not be_accessible
    end
  end
end

shared_examples "an unique token" do
  describe :token do
    it "is unique" do
      tokens = []
      3.times do
        token = FactoryGirl.create(factory_name).token
        tokens.should_not include(token)
      end
    end

    it "is generated before validation" do
      expect { subject.valid? }.to change { subject.token }.from(nil)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doorkeeper-0.4.2 spec/support/shared/models_shared_examples.rb
doorkeeper-0.4.1 spec/support/shared/models_shared_examples.rb
doorkeeper-0.4.0 spec/support/shared/models_shared_examples.rb
doorkeeper-0.3.4 spec/support/shared/models_shared_examples.rb
doorkeeper-0.3.3 spec/support/shared/models_shared_examples.rb
doorkeeper-0.3.2 spec/support/shared/models_shared_examples.rb