Sha256: 2eae947f6fff601b3f224370c13618c569e0cf4083040f4af76488b67f586e2f

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'pugin/feature/bandiera'

describe 'The bandiera client feature set' do

    method_hash = {
        'show-dissolution': :dissolution?,
        'show-register': :register_to_vote?,
        'show-election': :election?,
        'show-post-election': :post_election?,
        'show-list-images': :show_list_images?
    }

    method_hash.each do |flag_name, method_name|
        context flag_name do
            context 'when the feature exists in Bandiera' do
                before :each do
                    Pugin::Feature::Bandiera.instance_variable_set(:@features, {"#{flag_name}" => true})
                end

                it "returns the value of #{flag_name} in the Bandiera database if it exists" do
                    expect(Pugin::Feature::Bandiera.send(method_name)).to equal(true)
                end
            end
            context 'when the feature does not exist in Bandiera' do
                before :each do
                    Pugin::Feature::Bandiera.instance_variable_set(:@features, {})
                end

                it "returns false because the feature value is nil"  do
                    expect(Pugin::Feature::Bandiera.send(method_name)).to equal(false)
                end
            end
        end
    end

    context 'when trying to reset the @features instance variable' do

        before :each do
            Pugin::Feature::Bandiera.instance_variable_set(:@features, {'show-register' => true})
        end

        it 'resets the @features instance variable back to nil' do
            Pugin::Feature::Bandiera.reset
            expect(@features).to equal(nil)
        end
    end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pugin-1.2.5 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.2.4 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.2.3 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.2.2 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.2.1 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.2.0 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.1.2 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.0.1.pre spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.0.1 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.0.0.pre spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.9.0 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.9 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.8 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.7 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.7.pre spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.6 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.6.pre spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.5 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.4 spec/lib/pugin/feature/bandiera_spec.rb
pugin-0.8.3 spec/lib/pugin/feature/bandiera_spec.rb