master
 1require "rails_helper"
 2
 3describe ImportGymsJob do
 4  subject { ImportGymsJob.new }
 5  let(:location) { build(:portland) }
 6
 7  it "imports all the gyms in the city" do
 8    allow(Gym).to receive(:import)
 9    subject.perform(location)
10    expect(Gym).to have_received(:import).with(location.city)
11  end
12
13  it "skips the import if no location is present" do
14    allow(Gym).to receive(:import)
15    subject.perform(nil)
16    expect(Gym).to_not have_received(:import)
17  end
18
19  it "skips the import of gyms in the city are already present" do
20    allow(Gym).to receive(:import)
21    create(:gym, location: location)
22
23    subject.perform(location)
24
25    expect(Gym).to_not have_received(:import)
26  end
27end