summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2016-05-28 16:11:10 -0600
committermo khan <mo@mokhan.ca>2016-05-28 16:11:10 -0600
commit032defa413b4e775bbf2aab041a385c7d4f57f1d (patch)
tree8dccd9cb6c74a8f6b972d245554d0af9e308b771 /spec
parent890fc6b147cd92a2c336457cd044868abcad92e7 (diff)
convert search to a static gateway
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/gyms_controller_spec.rb4
-rw-r--r--spec/features/profiles_spec.rb14
-rw-r--r--spec/support/pages/edit_profile_page.rb12
3 files changed, 18 insertions, 12 deletions
diff --git a/spec/controllers/gyms_controller_spec.rb b/spec/controllers/gyms_controller_spec.rb
index 36eb144..261e09d 100644
--- a/spec/controllers/gyms_controller_spec.rb
+++ b/spec/controllers/gyms_controller_spec.rb
@@ -29,7 +29,9 @@ describe GymsController do
it "returns matches from yelp" do
gym = build(:gym)
- allow(Search).to receive(:yelp).and_return(Kaminari.paginate_array([gym]))
+ yelp = double
+ allow(Search).to receive(:yelp).and_return(yelp)
+ allow(yelp).to receive(:for).and_return(Kaminari.paginate_array([gym]))
get :index, q: "sait", source: "yelp"
expect(assigns(:gyms)).to match_array([gym])
diff --git a/spec/features/profiles_spec.rb b/spec/features/profiles_spec.rb
index 4fb4b50..fcc06d5 100644
--- a/spec/features/profiles_spec.rb
+++ b/spec/features/profiles_spec.rb
@@ -31,6 +31,7 @@ feature "Profiles", type: :feature do
it "allows me to edit my profile" do
subject.change(gender: :male, social_tolerance: :low)
+ subject.save_changes
expect(page).to have_content(user.username)
expect(page).to have_content(
@@ -42,17 +43,10 @@ feature "Profiles", type: :feature do
gym = build(:gym)
allow(Gym).to receive(:create_from_yelp!).and_return(gym)
- link_text = I18n.translate("profiles.edit.choose_home_gym")
- subject.click_link(link_text)
- within("#gym-search form") do
- fill_in "q", with: "sait"
- fill_in "city", with: "calgary"
- click_button("Search")
- end
- subject.wait_for_ajax
- subject.click_button("Mine")
- subject.wait_for_ajax
+ subject.click_link(I18n.t("profiles.edit.choose_home_gym"))
+ subject.choose_home_gym(city: "calgary", name: "sait")
subject.save_changes
+
expect(page).to have_content(gym.name)
end
end
diff --git a/spec/support/pages/edit_profile_page.rb b/spec/support/pages/edit_profile_page.rb
index a703be5..42b68e8 100644
--- a/spec/support/pages/edit_profile_page.rb
+++ b/spec/support/pages/edit_profile_page.rb
@@ -10,7 +10,17 @@ class EditProfilePage < PageModel
page.choose(gender.to_s.titleize)
page.choose(social_tolerance.to_s.titleize)
end
- save_changes
+ end
+
+ def choose_home_gym(city:, name:)
+ within("#gym-search form") do
+ fill_in "q", with: name
+ fill_in "city", with: city
+ click_button("Search")
+ end
+ wait_for_ajax
+ click_button("Mine")
+ wait_for_ajax
end
def save_changes