diff --git a/features/reading_group/listing.feature b/features/reading_group/listing.feature new file mode 100644 index 0000000..7b774e1 --- /dev/null +++ b/features/reading_group/listing.feature @@ -0,0 +1,33 @@ +Feature: Reading Group + In Order to be see the reading groups + As a regular user + I should be able to see the public and my own reading groups + + Scenario: Not logged in and no Reading Groups + Given I am at the homepage + When I click the Reading Group link + Then I should see "Reading Groups" + And I should see "Name" + And I should see "Description" + And I should see "You must be logged in to Create Reading Group" + + @kalibro_configuration_restart @javascript + Scenario: Logged in, should list Reading Groups + Given I am a regular user + And I am signed in + And I own a sample reading group + When I am at the All Reading Groups page + Then the sample reading group should be there + And I should not see "You must be logged in to Create Reading Group" + + @kalibro_configuration_restart + Scenario: Should show only the public or owned reading groups + Given I am a regular user + And I am signed in + And I own a sample reading group + And there is a public reading group created + And there is a private reading group created + When I am at the All Reading Groups page + Then the sample reading group should be there + And the public reading group should be there + And the private reading group should not be there diff --git a/features/step_definitions/reading_group_steps.rb b/features/step_definitions/reading_group_steps.rb index 5c3a39b..5914b4e 100644 --- a/features/step_definitions/reading_group_steps.rb +++ b/features/step_definitions/reading_group_steps.rb @@ -14,7 +14,7 @@ end Given(/^I own a sample reading group$/) do @reading_group = FactoryGirl.create(:reading_group) - FactoryGirl.create(:reading_group_attributes, {user_id: @user.id, reading_group_id: @reading_group.id}) + FactoryGirl.create(:reading_group_attributes, user_id: @user.id, reading_group_id: @reading_group.id) end Given(/^I have a sample reading group$/) do @@ -63,3 +63,29 @@ end Then(/^the Sample Reading Group should not be there$/) do expect { ReadingGroup.find(@reading_group.id) }.to raise_error end + +Then(/^the sample reading group should be there$/) do + expect(page).to have_content(@reading_group.name) + expect(page).to have_content(@reading_group.description) +end + +Given(/^there is a public reading group created$/) do + @public_rg = FactoryGirl.create(:public_reading_group) + FactoryGirl.create(:reading_group_attributes, reading_group_id: @public_rg.id) +end + +Given(/^there is a private reading group created$/) do + @private_rg = FactoryGirl.create(:another_reading_group) + FactoryGirl.create(:reading_group_attributes, :private, reading_group_id: @private_rg.id, user: FactoryGirl.create(:another_user)) +end + +Then(/^the public reading group should be there$/) do + expect(page).to have_content(@public_rg.name) + expect(page).to have_content(@public_rg.description) +end + +Then(/^the private reading group should not be there$/) do + expect(page).to have_no_content(@private_rg.name) + expect(page).to have_no_content(@private_rg.description) +end + diff --git a/spec/factories/reading_groups.rb b/spec/factories/reading_groups.rb index a00ace8..a48e828 100644 --- a/spec/factories/reading_groups.rb +++ b/spec/factories/reading_groups.rb @@ -11,5 +11,10 @@ FactoryGirl.define do name "My Reading Group" description "The best one" end + + factory :public_reading_group do + name "Public Reading Group" + description "Public" + end end end -- libgit2 0.21.2