1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
require "rails_helper"
feature "Gyms", type: :feature do
let(:user_session) { create(:active_session, location: create(:calgary)) }
before :each do
page.set_rack_session(user_id: user_session.id)
end
feature "viewing gyms" do
subject { GymsPage.new }
let!(:calgary_gym) do
create(:gym, name: "sait", location: create(:calgary))
end
let!(:edmonton_gym) do
create(:gym, name: "nait", location: create(:edmonton))
end
it "loads all the gyms" do
user_session.location.update_attributes(latitude: 0.0, longitude: 0.0)
subject.visit_page
expect(subject).to be_on_page
expect(subject).to have_content(calgary_gym.name)
expect(subject).to have_content(edmonton_gym.name)
end
describe "search" do
let!(:other_calgary_gym) do
create(:gym, name: "world health", location: create(:calgary))
end
it "returns gyms that match the search criteria", js: true do
subject.visit_page
subject.search("sait")
expect(subject).to be_on_page
expect(subject).to have_content(calgary_gym.name)
expect(subject).to have_no_content(other_calgary_gym.name)
end
end
end
feature "adding a gym" do
subject { NewGymPage.new }
it "saves a new gym" do
VCR.use_cassette("geo-location-sait") do
subject.visit_page
subject.change(
name: "SAIT",
address: "1301 16 Ave NW",
city: "Calgary",
region: "AB",
country: "Canada",
postal_code: "T2M 0L4",
)
expect(Gym.count).to eql(1)
gym = Gym.last
expect(gym.name).to eql("SAIT")
expect(gym.location).to be_present
expect(gym.location.address).to eql("1301 16 Ave NW")
expect(gym.location.city).to eql("Calgary")
expect(gym.location.region).to eql("AB")
expect(gym.location.country).to eql("CA")
expect(gym.location.postal_code).to eql("T2M 0L4")
end
end
end
end
|