reading_group_steps.rb
2.1 KB
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
require 'kalibro_gatekeeper_client/errors'
Given(/^I am at the All Reading Groups page$/) do
visit reading_groups_path
end
Given(/^I am at the New Reading Group page$/) do
visit new_reading_group_path
end
Given(/^I have a reading group named "(.*?)"$/) do |name|
@reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name})
end
Given(/^I have a sample reading within the sample reading group$/) do
@reading = FactoryGirl.create(:reading, {group_id: @reading_group.id, id: nil})
end
Given(/^I own a sample reading group$/) do
@reading_group = FactoryGirl.create(:reading_group, {id: nil})
FactoryGirl.create(:reading_group_ownership, {user_id: @user.id, reading_group_id: @reading_group.id})
end
Given(/^I have a sample reading group$/) do
@reading_group = FactoryGirl.create(:reading_group, {id: nil})
end
Given(/^I visit the Sample Reading Group page$/) do
visit reading_group_path(@reading_group.id)
end
Given(/^I am at the sample reading group edit page$/) do
visit edit_reading_group_path(@reading_group.id)
end
Given(/^I own a reading group named "(.*?)"$/) do |name|
@reading_group = FactoryGirl.create(:reading_group, {id: nil, name: name})
FactoryGirl.create(:reading_group_ownership, {user_id: @user.id, reading_group_id: @reading_group.id})
end
When(/^I visit the sample reading group edit page$/) do
visit edit_reading_group_path(@reading_group.id)
end
Then(/^The field "(.*?)" should be filled with the sample reading group "(.*?)"$/) do |field, value|
expect(page.find_field(field).value).to eq(@reading_group.send(value))
end
Then(/^I should be in the Sample Reading Group page$/) do
expect(page).to have_content(@reading_group.name)
expect(page).to have_content(@reading_group.description)
end
Then(/^I should see the information of the sample reading$/) do
expect(page).to have_content(@reading.label)
expect(page).to have_content(@reading.grade)
pager = page.body
color = @reading.color.downcase
var = (pager =~ /#{color}/)
expect(var).to_not be_nil
end
Then(/^I should be in the Edit Reading Group page$/) do
visit edit_reading_group_path(@reading_group.id)
end