Sha256: 74b2a4c63787b2d957e191e7b012fa079582d64a9c20a63b82ee77cde4fc8810

Contents?: true

Size: 1.92 KB

Versions: 34

Compression:

Stored size: 1.92 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?,
        'show-committees': :show_committees?,
        'show-government-roles': :show_government_roles?,
        'show-opposition-roles': :show_opposition_roles?,
        'show-activity-links': :show_activity_links?,
        'show-lords-ineligibility-banner': :show_lords_ineligibility_banner?
    }

    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

34 entries across 34 versions & 1 rubygems

Version Path
pugin-1.10.10 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.9 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.8 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.7 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.6 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.5 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.4 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.3 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.2 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.1 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.10.0 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.7 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.6 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.5 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.4 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.3 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.2 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.1 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.9.0 spec/lib/pugin/feature/bandiera_spec.rb
pugin-1.8.9 spec/lib/pugin/feature/bandiera_spec.rb