Sha256: 89d840eff51c79d17fd57ff7eac5d07165b18fab76ed1e0a47fe164219d1ec1f

Contents?: true

Size: 996 Bytes

Versions: 3

Compression:

Stored size: 996 Bytes

Contents

module FlipFab
  describe FeaturesByName do
    let(:feature)  { Feature.new :example_feature }
    let(:features) { { example_feature: feature } }
    subject{ described_class.new features }

    describe '#[]' do

      context 'when the feature exists' do

        it 'returns the feature' do
          expect(subject[:example_feature]).to eq(feature)
        end
      end

      context 'when the feature does not exist' do

        it 'raises' do
          expect{ subject[:no_feature] }.to raise_error 'no feature has been defined with the name: no_feature'
        end
      end
    end

    describe '#with_context' do
      let(:context) { double(:context) }

      it 'returns contextual features by name' do
        expect(subject.with_context context).to be_a described_class
        expect((subject.with_context context)[:example_feature]).to be_a ContextualFeature
        expect((subject.with_context context)[:example_feature].feature).to eq(feature)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flip_fab-1.0.1 spec/lib/flip_fab/features_by_name_spec.rb
flip_fab-1.0.0 spec/lib/flip_fab/features_by_name_spec.rb
flip_fab-0.0.1 spec/lib/flip_fab/features_by_name_spec.rb