Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Ch.11 - Issues in the pending scenario #92

Open
JunichiIto opened this issue Feb 25, 2014 · 2 comments
Open

Ch.11 - Issues in the pending scenario #92

JunichiIto opened this issue Feb 25, 2014 · 2 comments

Comments

@JunichiIto
Copy link

I tried the following pending scenario by myself and found some issues.

  context "as a guest" do
    scenario "reads a news release" do
      pending "You write this one!"
      visit root_path
      click_link "News"

      expect(page).to_not have_content
        "Today, BigCo's CFO announced record growth."
      expect(page).to_not have_content 'Add News Release'

      click_link "2013-08-01: Record profits for BigCo!"

      expect(page).to have_content
        "Today, BigCo's CFO announced record growth."
    end
  end

First, the following expectations do not work well because they are treated as four sentences.

      expect(page).to_not have_content
        "Today, BigCo's CFO announced record growth."

      expect(page).to have_content
        "Today, BigCo's CFO announced record growth."

The first one failed so I noticed the problem, but the second passed, so without false-positive test it is hard to notice that the test is imperfect.

Second, this scenario requires setting up for test data(news releases). I feel it should be indicated in the test code like this:

  context "as a guest" do
    background do
      # set up news release
    end
    scenario "reads a news release" do
      pending "You write this one!"
      # etc
    end
  end

Finally, I cannot understand the purpose of the following expectation for the guest context:

      expect(page).to_not have_content
        "Today, BigCo's CFO announced record growth."

This expectation does not rely on user or guest context.(Neither would display it.)

In conclusion, my ideal sample code would be like this:

  context "as a guest" do
    background do
      # set up news release
    end
    scenario "reads a news release" do
      pending "You write this one!"
      visit root_path
      click_link "News"

      expect(page).to_not have_content 'Add News Release'

      click_link "2013-08-01: Record profits for BigCo!"

      expect(page).to have_content "Today, BigCo's CFO announced record growth."
    end
  end

I would appreciate if you could take it into consideration.

@ruralocity
Copy link
Member

I'll look into this, but probably won't be able to get to it until after March 3.

@JunichiIto
Copy link
Author

No problem. This is not so urgent issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants