Skip to content

Instantly share code, notes, and snippets.

def creating_a_user
@user = Factory.build @user
fill_in "user[email]", :with => @user.email
click_button "Create"
end
on_following_link_to new_user_path do
where :creating_a_user do
specify { page.should have_content(@user.email) }
end
with_existing :user do
on_visiting edit_user_path do
it {should let_me_edit_the_user}
end
end
context "when a user exists" do
before { @user = Factory :user }
context "when I visit the page for editing that user" do
before { visit "/users/#{@user.id}/edit" }
it {should let_me_edit_the_user}
end
end
Scenario: Search by topic
Given a topic exists
And some courses exist covering that topic
And other courses exist that do not cover the topic
When I search for that topic
Then I should see the courses that cover the topic
And I should not see the courses that do not cover the topic
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 2 courses A001, B205 that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| Course code |
| A001 |
| B205 |
with_existing :article do
on_visiting edit_article_path do
it { lets_me_edit_the(:article) }
it { shows_failure_on_invalid_update_of(:article) }
end
where it_is_unpublished do
on_visiting articles_path do
specify { page.should_not have_content(@article.name) }
end
def self.role_perms(role_name)
if role_name == :anybody
"return true"
else
"user.acts_as_if? '#{role_name}'"
end
end
def self.access_func(method_name, info)