Created
March 3, 2016 00:57
-
-
Save dohoonk/4600a318ecd99a51bd48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rspec.feature "Campaigns", type: :feature do | |
| describe "Campaigns Listing" do | |
| it "displays a text 'Recent Campaigns'" do | |
| #this simulates users typing the 'campaign_path' in the address bar | |
| #to actually visit the page | |
| visit campaigns_path | |
| # we have acess to an object 'page' that contains the rendered HTML page | |
| # we can use it with RSpec Matchers to perform tests | |
| expect(page).to have text "Recent Campaigns" | |
| end | |
| -Command code | |
| rspec spec/features/campaigns_spec.rb | |
| -campaigns/index.html.erb | |
| We have to make sure that it has a text of Recent Campaigns | |
| it "displays a h2 header with text 'All Campaigns'" do | |
| visit campaigns_path | |
| expect(page).to have_selector "h2", text: "all Campaigns" | |
| end | |
| -index.html.erb | |
| add <h2>All Campaigns<h2> | |
| it "has a page title of 'Welcome to Fund.sy'" do | |
| visit campaigns_path | |
| expect(page).to have_title "welcome to Fund.sy" | |
| end | |
| -application.html.erb | |
| change the title to <title>Welcome to Fund.sy</title> | |
| it "displays a campaign's name" do | |
| campagin = FactoryGirl.create(:campagin) | |
| visit campaigns_path | |
| expect(page).to have_text campaign.name | |
| end | |
| -index.html.erb | |
| add <%= link_to c.name, c %> | |
| this is case sesitive so if you want to have case insensitive we must use regex | |
| changing the expect to this regex with i at the end will make the search case insensitive | |
| expect(page).to have_text /#{campaign.name}/i | |
| --------------------------------------------------------------------- | |
| first thing in capabora is to visit the path | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment