Sha256: 24f377ea8be38674806c74b4141ceb975d4e45ade5bea6768aa83885ede9da4e

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

# Bx Recommender Service Adaptor Test
# To inject your bX token into the testing environment, use
#     export BX_TOKEN=yourtoken
# but this isn't really necessary or useful, since this test
# will just use VCR anyway
require 'test_helper'
class BxTest < ActiveSupport::TestCase
  extend TestWithCassette
  fixtures :requests, :referents, :referent_values

  def setup
    bx_token = ENV['BX_TOKEN'] || 'BX_TOKEN'
    config = { 
      "service_id" => "Bx", 
      "priority" => "1",
      "token" => bx_token
    }
    @bx_service_adaptor = Bx.new(config)
  end

  # This test has recorded a Bx request via VCR
  # It has recommendations
  # Ignore ctx_time in the URL for VCR matching purposes
  test_with_cassette("article that has recommendations", :bx, :match_requests_on => [:method, :uri_without_ctx_tim]) do
    # Get the relevant request fixture
    coffeemakers_request = requests(:coffeemakers)
    @bx_service_adaptor.handle(coffeemakers_request)

    # Refresh with the latest from the DB after handling the service.
    coffeemakers_request.dispatched_services.reset
    coffeemakers_request.service_responses.reset

    # Get the returned 'similar' service responses
    similars = coffeemakers_request.get_service_type('similar')

    # There should be 5 'similar' service responses
    assert_equal(5, similars.length, "Ack. Similar responses have gone awry!")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
umlaut-4.0.0.beta3 ./test/unit/bx_test.rb
umlaut-4.0.0.beta2 ./test/unit/bx_test.rb
umlaut-4.0.0.beta1 ./test/unit/bx_test.rb
umlaut-3.3.1 ./test/unit/bx_test.rb
umlaut-3.3.0 ./test/unit/bx_test.rb
umlaut-3.2.0 ./test/unit/bx_test.rb
umlaut-3.1.1 ./test/unit/bx_test.rb