<commit_before>require 'spec_helper'

describe "Acfs" do
  let(:client) { MyClient.new(base_url: 'http://api.example.com') }

  before do
    stub_request(:get, "api.example.com/users").with(:body => '[{"id":1,"name":"Anon","age":12},{"id":2,"name":"John","age":26}]')
    stub_request(:get, "api.example.com/users/2").with(:body => '{"id":2,"name":"John","age":26}')
    stub_request(:get, "api.example.com/users/2/comments").with(:body => '[{"id":1,"text":"Comment #1"},{"id":2,"text":"Comment #2"}]')
  end

  it 'should load single resource' do
    pending "TODO: Implement high level feature"

    user = client.users.fetch 2

    client.run

    exepct(user.name).to be == 'John'
    expect(user.age).to be == 26
  end

  it 'should load single resource (block)' do
    pending "TODO: Implement high level feature"

    client.fetch do |cl|
      user = cl.users.fetch 2
    end

    exepct(user.name).to be == 'John'
    expect(user.age).to be == 26
  end

  it 'should load multiple resources' do
    pending "TODO: Implement high level feature"

    users = client.users.all

    client.run

    expect(users).to have(2).items
    expect(users[0].name).to be == 'Anon'
    expect(users[0].age).to be == 12
    expect(users[1].name).to be == 'John'
    expect(users[1].age).to be == 26
  end

  it 'should load associated resources' do
    pending "TODO: Implement high level feature"

    @user = client.user.fetch(1) do |user|
      @comments = user.comments.all
    end

    client.run

    exepct(@user.name).to be == 'John'
    expect(@user.age).to be == 26

    expect(@comments).to have(2).items
  end
end
<commit_msg>Switch to find and run syntax.<commit_after>require 'spec_helper'

describe "Acfs" do
  let(:client) { MyClient.new(base_url: 'http://api.example.com') }

  before do
    stub_request(:get, "api.example.com/users").with(:body => '[{"id":1,"name":"Anon","age":12},{"id":2,"name":"John","age":26}]')
    stub_request(:get, "api.example.com/users/2").with(:body => '{"id":2,"name":"John","age":26}')
    stub_request(:get, "api.example.com/users/2/comments").with(:body => '[{"id":1,"text":"Comment #1"},{"id":2,"text":"Comment #2"}]')
  end

  it 'should load single resource' do
    pending "TODO: Implement high level feature"

    user = client.users.find 2

    client.run

    exepct(user.name).to be == 'John'
    expect(user.age).to be == 26
  end

  it 'should load single resource (block)' do
    pending "TODO: Implement high level feature"

    client.run do |cl|
      user = cl.users.find 2
    end

    exepct(user.name).to be == 'John'
    expect(user.age).to be == 26
  end

  it 'should load multiple resources' do
    pending "TODO: Implement high level feature"

    users = client.users.all

    client.run

    expect(users).to have(2).items
    expect(users[0].name).to be == 'Anon'
    expect(users[0].age).to be == 12
    expect(users[1].name).to be == 'John'
    expect(users[1].age).to be == 26
  end

  it 'should load associated resources' do
    pending "TODO: Implement high level feature"

    @user = client.user.find(1) do |user|
      @comments = user.comments.all
    end

    client.run

    exepct(@user.name).to be == 'John'
    expect(@user.age).to be == 26

    expect(@comments).to have(2).items
  end
end

{'fraction_non_alphanumeric': 0.17968273337400853, 'fraction_numerical': 0.020744356314826115, 'mean_word_length': 3.343046357615894, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 9, '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': '5902378', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1125, 'n_words': 269}