Sha256: 32f9d374326fba97b6d3e9d1dd1741ed73227c8baa7875fd587d6c6579d66bcb

Contents?: true

Size: 816 Bytes

Versions: 34

Compression:

Stored size: 816 Bytes

Contents

require 'rails_helper'

module PandaPal
  RSpec.describe ApiCall, type: :model do
    let!(:subject) { ApiCall.create!(logic: '"#{p[:foo]}_bar"') }
    let!(:jwt) { subject.jwt_token }

    describe ".from_jwt" do
      it "finds an ApiCall from a JWT" do
        expect(ApiCall.from_jwt(jwt)).to eq subject
      end

      it "fails if the JWT is invalid" do
        expect{ ApiCall.from_jwt("really.bad.jwt") }.to raise_error(JWT::DecodeError)
      end
    end

    describe "#call" do
      it "calls the function with parameters" do
        expect(subject.call(foo: 'FOO')).to eq 'FOO_bar'
      end
    end

    describe "#call_url" do
      it "generates a URL with the expected placholders" do
        expect(subject.call_url).to eq "/panda_pal/call_logic?foo=TODO&token=#{jwt}"
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
panda_pal-5.11.0 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.10.1 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.10.0 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.8.beta1 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.7 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.6 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.5 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.4 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.3 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.1 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.9.0 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.5 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.4 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.3 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.2 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.1 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.8.0 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.6.12 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.7.0.beta2 spec/models/panda_pal/api_call_spec.rb
panda_pal-5.7.0.beta1 spec/models/panda_pal/api_call_spec.rb