<commit_before>require 'spec_helper'

describe Slackr::Channel do
  before do
    connection = Slackr::Connection.new('team', 'fakeToken').init
    @subject   = Slackr::Channel.init(connection)

    @list_body = {
      :ok       => true,
      :channels => [
        {
          :id          => "C024BE91L",
          :name        => "fun",
          :created     => "1360782804",
          :creator     => "U024BE7LH",
          :is_archived => false,
          :is_member   => false,
          :num_members => 6,
          :topic       => {
            :value     => "Fun times",
            :creator   => "U024BE7LV",
            :last_set  => "1369677212"
          },
          :purpose => {
            :value    => "This channel is for fun",
            :creator  => "U024BE7LH",
            :last_set => "1360782804"
          }
        }
      ]
    }

    stub_request(:get, "https://team.slack.com/api/channels.list?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
      to_return(:status => 200, :body => @list_body.to_json, :headers => {})

    stub_request(:get, "https://team.slack.com/api/channels.foo?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
      to_return(:status => 404, :body => "", :headers => {})

    stub_request(:get, "https://team.slack.com/api/channels.list?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
      to_return(:status => 200, :body => @list_body.to_json, :headers => {})
  end

  describe "#list" do
    it "requests the channel list" do
      expect(@subject.list).to eq(JSON.parse(@list_body.to_json))
    end

    context "with a bad request" do
      it "should raise an error" do
        bad_url = "#{@subject.connection.base_url}/api/channel.foo?token=#{@subject.connection.token}"
        expect(@subject).to receive(:service_url).and_return(bad_url)
        expect {
          @subject.list
        }.to raise_error
      end
    end
  end
end
<commit_msg>Switch to betterspecs.org style<commit_after>require 'spec_helper'

describe Slackr::Channel do
  let(:connection) { Slackr::Connection.new('team', 'fakeToken').init }
  let(:list_body) do
    {
      :ok       => true,
      :channels => [
        {
          :id          => "C024BE91L",
          :name        => "fun",
          :created     => "1360782804",
          :creator     => "U024BE7LH",
          :is_archived => false,
          :is_member   => false,
          :num_members => 6,
          :topic       => {
            :value     => "Fun times",
            :creator   => "U024BE7LV",
            :last_set  => "1369677212"
          },
          :purpose => {
            :value    => "This channel is for fun",
            :creator  => "U024BE7LH",
            :last_set => "1360782804"
          }
        }
      ]
    }
  end
  subject { Slackr::Channel.init(connection) }
  before do
    stub_request(:get, "https://team.slack.com/api/channels.list?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
      to_return(:status => 200, :body => list_body.to_json, :headers => {})

    stub_request(:get, "https://team.slack.com/api/channels.foo?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
      to_return(:status => 404, :body => "", :headers => {})

    stub_request(:get, "https://team.slack.com/api/channels.list?token=fakeToken").
      with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
      to_return(:status => 200, :body => list_body.to_json, :headers => {})
  end

  describe "#list" do
    it "requests the channel list" do
      expect(subject.list).to eq(JSON.parse(list_body.to_json))
    end

    context "with a bad request" do
      it "should raise an error" do
        bad_url = "#{subject.connection.base_url}/api/channel.foo?token=#{subject.connection.token}"
        expect(subject).to receive(:service_url).and_return(bad_url)
        expect {
          subject.list
        }.to raise_error
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.18186035722570168, 'fraction_numerical': 0.032011134307585246, 'mean_word_length': 2.316923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 77, 'https://': 6, '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': '7121009', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1441, 'n_words': 239}