Commit 2fd4e490f5be992532249a85d1a8ac4cc42f0d65

Authored by Heitor
Committed by Diego Camarinha
1 parent ca3d4187

Added reading group listing acceptance tests

Signed off by: Pedro Scocco <pedroscocco@gmail.com>
features/reading_group/listing.feature 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +Feature: Reading Group
  2 + In Order to be see the reading groups
  3 + As a regular user
  4 + I should be able to see the public and my own reading groups
  5 +
  6 + Scenario: Not logged in and no Reading Groups
  7 + Given I am at the homepage
  8 + When I click the Reading Group link
  9 + Then I should see "Reading Groups"
  10 + And I should see "Name"
  11 + And I should see "Description"
  12 + And I should see "You must be logged in to Create Reading Group"
  13 +
  14 + @kalibro_configuration_restart @javascript
  15 + Scenario: Logged in, should list Reading Groups
  16 + Given I am a regular user
  17 + And I am signed in
  18 + And I own a sample reading group
  19 + When I am at the All Reading Groups page
  20 + Then the sample reading group should be there
  21 + And I should not see "You must be logged in to Create Reading Group"
  22 +
  23 + @kalibro_configuration_restart
  24 + Scenario: Should show only the public or owned reading groups
  25 + Given I am a regular user
  26 + And I am signed in
  27 + And I own a sample reading group
  28 + And there is a public reading group created
  29 + And there is a private reading group created
  30 + When I am at the All Reading Groups page
  31 + Then the sample reading group should be there
  32 + And the public reading group should be there
  33 + And the private reading group should not be there
... ...
features/step_definitions/reading_group_steps.rb
... ... @@ -14,7 +14,7 @@ end
14 14  
15 15 Given(/^I own a sample reading group$/) do
16 16 @reading_group = FactoryGirl.create(:reading_group)
17   - FactoryGirl.create(:reading_group_attributes, {user_id: @user.id, reading_group_id: @reading_group.id})
  17 + FactoryGirl.create(:reading_group_attributes, user_id: @user.id, reading_group_id: @reading_group.id)
18 18 end
19 19  
20 20 Given(/^I have a sample reading group$/) do
... ... @@ -63,3 +63,29 @@ end
63 63 Then(/^the Sample Reading Group should not be there$/) do
64 64 expect { ReadingGroup.find(@reading_group.id) }.to raise_error
65 65 end
  66 +
  67 +Then(/^the sample reading group should be there$/) do
  68 + expect(page).to have_content(@reading_group.name)
  69 + expect(page).to have_content(@reading_group.description)
  70 +end
  71 +
  72 +Given(/^there is a public reading group created$/) do
  73 + @public_rg = FactoryGirl.create(:public_reading_group)
  74 + FactoryGirl.create(:reading_group_attributes, reading_group_id: @public_rg.id)
  75 +end
  76 +
  77 +Given(/^there is a private reading group created$/) do
  78 + @private_rg = FactoryGirl.create(:another_reading_group)
  79 + FactoryGirl.create(:reading_group_attributes, :private, reading_group_id: @private_rg.id, user: FactoryGirl.create(:another_user))
  80 +end
  81 +
  82 +Then(/^the public reading group should be there$/) do
  83 + expect(page).to have_content(@public_rg.name)
  84 + expect(page).to have_content(@public_rg.description)
  85 +end
  86 +
  87 +Then(/^the private reading group should not be there$/) do
  88 + expect(page).to have_no_content(@private_rg.name)
  89 + expect(page).to have_no_content(@private_rg.description)
  90 +end
  91 +
... ...
spec/factories/reading_groups.rb
... ... @@ -11,5 +11,10 @@ FactoryGirl.define do
11 11 name "My Reading Group"
12 12 description "The best one"
13 13 end
  14 +
  15 + factory :public_reading_group do
  16 + name "Public Reading Group"
  17 + description "Public"
  18 + end
14 19 end
15 20 end
... ...