Sha256: f7c1ae585fbfbbd7121dead7eee7a589d730f731c92489ad2708fe1f9e1461f9

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require 'rspec'
require "spec_helper"
require 'fixie'
require 'fixie/config'

RSpec.describe Fixie::Sql::Orgs, "Organizations access" do
  let (:test_org) { "ponyville"}

  context "Basic access to orgs" do
    let (:orgs) { Fixie::Sql::Orgs.new }
    it "We find more than one org" do
      expect(orgs.inner.count).to be > 0
    end

    it "We can list orgs" do
      # array matcher requires a splat. (I didn't know this )
      expect(orgs.list).to include( * %w(acme ponyville wonderbolts) )
    end
    it "We can list orgs with a limit" do
      # array matcher requires a splat. (I didn't know this )
      expect(orgs.list(1)).to eq(:too_many_results)
    end

    it "We can find an org" do
      expect(orgs[test_org].name).to eq(test_org)
    end

  end

  context "Search accessors work correctly" do
    let (:orgs) { Fixie::Sql::Orgs.new }
    let (:the_org) { orgs[test_org] }

    it "We can find an org by name" do
      expect(orgs.by_name(test_org).all.count).to eq(1)
      expect(orgs.by_name(test_org).all.first.name).to eq(the_org.name)
    end

    # TODO: Automatically extract this from the filter by field
    %w(name, id, full_name, authz_id).each do |accessor|
      it "We can access an org by #{accessor}" do
        expect(orgs.by_name(test_org).all.count).to eq(1)
        expect(orgs.by_name(test_org).all.first.name).to eq(the_org.name)
      end
    end

  end




end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chef_fixie-0.3.0 spec/chef_fixie/org_spec.rb~
chef_fixie-0.2.1 spec/chef_fixie/org_spec.rb~
chef_fixie-0.2.0 spec/chef_fixie/org_spec.rb~
chef_fixie-0.1.0 spec/chef_fixie/org_spec.rb~