Sha256: 7d28f6d5637a5cc328f5c34217ca12acd74c37007090fd6e0f94525e2828ec6f

Contents?: true

Size: 1003 Bytes

Versions: 5

Compression:

Stored size: 1003 Bytes

Contents

require "spec_helper"

describe XRay do

  before do
    ActiveSupport::Notifications.instance_eval do
      def self.instrument(*args, &block)
        @args = args
        yield
      end
    end
  end

  def active_support_args
    ActiveSupport::Notifications.instance_eval { @args }
  end

  describe ".method_missing" do
    it "runs whatevers" do
      XRay.whatevers "query/data" do
      end

      expect(active_support_args).to eq [
        "request.xraymachine", {group: :whatevers, query: "query/data", cache: false}
      ]
    end

    it "returns whatever the block yields" do
      result = XRay.whatevers("query/data") { "yielded result" }
      expect(result).to eq "yielded result"
    end

    it "sends a ray in and allows to mark it as cached" do
      XRay.whatevers "query/data" do |ray|
        ray.cached = true
      end

      expect(active_support_args).to eq [
        "request.xraymachine", {group: :whatevers, query: "query/data", cache: true}
      ]
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
x-ray-machine-1.0.4 spec/lib/x_ray_machine/x_ray_spec.rb
x-ray-machine-1.0.3 spec/lib/x_ray_machine/x_ray_spec.rb
x-ray-machine-1.0.2 spec/lib/x_ray_machine/x_ray_spec.rb
x-ray-machine-1.0.1 spec/lib/x_ray_machine/x_ray_spec.rb
x-ray-machine-1.0.0 spec/lib/x_ray_machine/x_ray_spec.rb