Sha256: b42e051270a2ab4c89d9830c6c3c914d3d32cd2b053af8d3e31abf43f37f385f

Contents?: true

Size: 1.64 KB

Versions: 34

Compression:

Stored size: 1.64 KB

Contents

describe 'Gratan::Client#export' do
  context 'when user does not exist' do
    subject { client }

    it do
      expect(subject.export.strip).to eq ''
    end
  end

  context 'when user exists' do
    let(:grantfile) {
      <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "test.*" do
    grant "SELECT"
  end
end

user "scott", "localhost" do
  on "*.*" do
    grant "USAGE"
  end

  on "test.*" do
    grant "SELECT"
  end
end
      RUBY
    }

    subject { client }

    before do
      apply(subject) do
        grantfile
      end
    end

    it do
      expect(subject.export.strip).to eq grantfile.strip
    end
  end

  context 'when ignore user exists' do
    let(:grantfile) {
      <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "test.*" do
    grant "SELECT"
  end
end

user "bob", "localhost" do
  on "*.*" do
    grant "USAGE"
  end

  on "test.*" do
    grant "SELECT"
  end
end
      RUBY
    }

    subject { client(ignore_user: /\Abob\z/) }

    before do
      apply(subject) do
        grantfile
      end
    end

    it do
      expect(subject.export.strip).to eq <<-RUBY.strip
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "test.*" do
    grant "SELECT"
  end
end
      RUBY
    end
  end

  context 'when with option exists' do
    let(:grantfile) {
      <<-RUBY
user "scott", "%" do
  on "*.*", :with=>"GRANT OPTION" do
    grant "USAGE"
  end
end
      RUBY
    }

    subject { client(ignore_user: /\Abob\z/) }

    before do
      apply(subject) do
        grantfile
      end
    end

    it do
      expect(subject.export.strip).to eq grantfile.strip
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
gratan-0.2.3 spec/export/export_spec.rb
gratan-0.2.2 spec/export/export_spec.rb
gratan-0.2.1 spec/export/export_spec.rb
gratan-0.2.0 spec/export/export_spec.rb
gratan-0.1.9 spec/export/export_spec.rb
gratan-0.1.8 spec/export/export_spec.rb
gratan-0.1.7 spec/export/export_spec.rb
gratan-0.1.6 spec/export/export_spec.rb
gratan-0.1.5 spec/export/export_spec.rb
gratan-0.1.4 spec/export/export_spec.rb
gratan-0.1.3 spec/export/export_spec.rb
gratan-0.1.2 spec/export/export_spec.rb
gratan-0.1.1 spec/export/export_spec.rb
gratan-0.1.0 spec/export/export_spec.rb