Commit e34da2e
Changed files (4)
app
views
gyms
features
step_definitions
app/views/gyms/index.html.erb
@@ -9,8 +9,8 @@
<% @gyms.each do |gym| %>
<tr>
<td><%= gym.name %></td>
- <td><%= gym.location.address %>, <%= gym.location.city %>, <%= gym.location.region %>, <%= gym.location.country %></td>
- <td><%= link_to t('.view_map'), gym.location.url %></td>
+ <td><%= gym.location.try(:address) %>, <%= gym.location.try(:city) %>, <%= gym.location.try(:region) %>, <%= gym.location.try(:country) %></td>
+ <td><%= link_to t('.view_map'), gym.location.try(:url) %></td>
</tr>
<% end %>
</table>
features/step_definitions/authentication_steps.rb
@@ -0,0 +1,6 @@
+Given /^the user is logged in$/ do
+ user = FactoryGirl.create(:user, password: 'password')
+ login_page = LoginPage.new
+ login_page.visit_page
+ login_page.login_with(user.username, 'password')
+end
features/step_definitions/gym_steps.rb
@@ -0,0 +1,22 @@
+When /^the user is on the gyms page$/ do
+ @subject = GymsPage.new
+ @subject.visit_page
+end
+
+And /^There are (\d) gyms$/ do |n|
+ @gyms = n.to_i.times.map do
+ FactoryGirl.create(:gym)
+ end
+end
+
+Then /^it lists all gyms$/ do
+ puts page.html
+ @gyms.each do |gym|
+ expect(@subject).to have_content(gym.name)
+ end
+end
+
+When /^I choose a city$/ do
+ pending
+end
+
features/finding_a_gym.feature
@@ -3,8 +3,9 @@ Feature: Finding a gym
So that I can get a good work out.
Scenario: Find a gym
- Given the user is on the gyms page
- When I look at the page
+ Given the user is logged in
+ And There are 2 gyms
+ When the user is on the gyms page
Then it lists all gyms
Scenario: Find a gym in a city