Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9272167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:48:21+00:00 2026-06-18T15:48:21+00:00

I write functional tests, and I need to do tests that were being would

  • 0

I write functional tests, and I need to do tests that were being would depend on the passage of previous tests. Let’s say I have a button that opens a window in which there is a functional. That is, in order to check this functionality, I need to first check the correct operation of the button (ie, open window or not functional). So, I need to do so that would be if the test failed on a button click, the tests did not run to check the functional window. Writing tests separately – for me is not an option. I would like to see something like this:

describe "some tests" do
  open_result = nil

  it "should check work button" do
    click_to_button()
    open_result = window_opened?
    open_result.should == true
  end

  if open_result

    describe "Check some functional" do

      it "should check first functional"

      it "should check second functional"

    end

  end

end

I know that this method does not work for rspec. It’s just a simple description of what I want to see. Is it achievable using rspec? If not, are there other ways (gems, etc.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:48:22+00:00Added an answer on June 18, 2026 at 3:48 pm

    RSpec is designed as a unit tests framework, so it may be a little difficult to get perfect functional-test behavior from it. In RSpec’s philosophy tests must be independent. It is especially important when you use autotest: in this case the order of execution is truly unpredictable. Sad but true.

    Still, of course you can save some state between test using global ($a) or instance (@a, not sure here) variables. Anyway you need to move if into it block so that it will be executed in time. You may use pending keyword to interrupt a test without failing it in case if pre-condition is not met.

    BUT

    I’m sure that the best solution is to avoid golden hammer antipattern, and not to write functional tests in unit-test framework. You want not to test some separate functions. You do want to test scenarios. So I suggest trying some scenario-testing suite.

    Behold, Cucumber! Usage is simle:

    1. Define parametrized scenario steps in Ruby, and expectations in RSpec-style
    2. Write scenarios in natural language (yes, not only English, but even Russian or whatever — the power of Regexps is on your side)

    In your case, you will have in features/step_definitions/gui_steps.rb something like

    Given /I pushed a button "(.*)"/ do |name|
        @buttons.find(name).click() # This line is pseudo-code, you know
    end
    

    and something similar for checking window opening, etc (see examples). Then you can combine defined steps in any way, for example your two scenarios might look like

    Scenario: Feature 1
        Given I pushed a button "go"
        And I focus on opened window
        When I trigger "feature 1"
        Then I should se "result 1" in text area
    
    Scenario: Feature 2
        Given I pushed a button "go"
        And I focus on opened window
        When I trigger "feature 2"
        Then I should se "result 2" in text area
    

    In both cases, if some step of scenario fails (like I focus on opened window — if it is not opened), the consequent steps are not executed — just as you want. As a bonus you get an extremely detailed output of what happened and on what step (see pics on the site).

    The good news is that you don’t always need to define all the step yourself. For example, when you test a web app, you can use webrat steps for typical things like When I go to url/a/b/c and Then I should see text “foo” on the page. I don’t know which GUI testing framework you use, but probably there are already steps for it, so I suggest you to google on Cucumber %framework name%. Even if not, writing these steps once will not be more difficult than trying to make Cucumber from RSpec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to write functional tests for a charging form which gets
I would like to write to functional test for one of my rails 3
I have multiple functional tests written as NUnit test which are independent from each
I need to write a function that takes in two constraints and returns a
I am trying to write some front end Javascript tests that can test drag
I need to write a function that splits records into separate files based on
I need to write a validation to make sure that new records created in
I have a piece of code that tests for the existence of a variable,
You want to write unittest -cases for a function like that: def test_me(a): for
I'm trying to write for and while loops in Python — functional programming style.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.