<commit_before>require 'spec_helper'

describe Push::Consumer do
  before(:each) do
    @consumer = Push::Consumer.new
  end

  context "subscription" do
    before(:each) do
      Push.config.backend.publish 'hi dude', '/exchange'
    end

    it "should consume message" do
      lambda{
        @consumer.subscribe('/exchange') do |m|
          m.should eql('hi dude')
        end
      }.should change(Push.config.backend.channels['/exchange'], :count).by(-1)
    end

    it "should set channel" do
      @consumer.subscribe('/exchange').channel.should eql('/exchange')
    end

    it "should set consumer" do
      @consumer.subscribe('/exchange').consumer.should be_instance_of(Push::Consumer)
    end

    it "should set backend" do
      @consumer.subscribe('/exchange').backend.should be_instance_of(Push::Backend::Test)
    end
  end

  it "should have a consumer id" do<commit_msg>use test backend for Consumer class specs<commit_after>require 'spec_helper'

describe Push::Consumer do
  before(:each) do
    Push.config.backend = :test
    @consumer = Push::Consumer.new
  end

  context "subscription" do
    before(:each) do
      Push.config.backend.publish 'hi dude', '/exchange'
    end

    it "should consume message" do
      lambda{
        @consumer.subscribe('/exchange') do |m|
          m.should eql('hi dude')
        end
      }.should change(Push.config.backend.channels['/exchange'], :count).by(-1)
    end

    it "should set channel" do
      @consumer.subscribe('/exchange').channel.should eql('/exchange')
    end

    it "should set consumer" do
      @consumer.subscribe('/exchange').consumer.should be_instance_of(Push::Consumer)
    end

    it "should set backend" do
      @consumer.subscribe('/exchange').backend.should be_instance_of(Push::Backend::Test)
    end
  end

  it "should have a consumer id" do
{'fraction_non_alphanumeric': 0.12554112554112554, 'fraction_numerical': 0.0010822510822510823, 'mean_word_length': 3.0548245614035086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2338236', 'n_tokens_mistral': 576, 'n_tokens_neox': 528, 'n_words': 145}