can not use method in tunrip

68 views
Skip to first unread message

hai nguyen ngoc

unread,
Jul 27, 2014, 11:48:38 PM7/27/14
to ruby-...@googlegroups.com
- my steps here:

step "I press :button" do |button|
  patiently do
    click_button(button)
  end
end

- my patiently method here:

module ToleranceForSeleniumSyncIssues
  RETRY_ERRORS = %w[
    Capybara::ElementNotFound
    Spec::Expectations::ExpectationNotMetError
    RSpec::Expectations::ExpectationNotMetError
    Minitest::Assertion
    Capybara::Poltergeist::ClickFailed
    Capybara::ExpectationNotMet
    Selenium::WebDriver::Error::StaleElementReferenceError
    Selenium::WebDriver::Error::NoAlertPresentError
    Selenium::WebDriver::Error::ElementNotVisibleError
    Selenium::WebDriver::Error::NoSuchFrameError
    Selenium::WebDriver::Error::NoAlertPresentError
  ]

  # This is similiar but not entirely the same as Capybara::Node::Base#wait_until or Capybara::Session#wait_until
  def patiently(seconds=Capybara.default_wait_time, &block)
    old_wait_time = Capybara.default_wait_time
    # dont make nested wait_untils use up all the alloted time
    Capybara.default_wait_time = 0 # for we are a jealous gem
    if page.driver.wait?
      start_time = Time.now
      begin
        block.call
      rescue Exception => e
        raise e unless RETRY_ERRORS.include?(e.class.name)
        raise e if (Time.now - start_time) >= seconds
        sleep(0.05)
        raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Time.now == start_time
        retry
      end
    else
      block.call
    end
  ensure
    Capybara.default_wait_time = old_wait_time
  end
  
  RSpec.configure { |c| c.include ToleranceForSeleniumSyncIssues }
end

- when I run my steps, it throws an error that is " No such step: 'patiently' " 

Wataru MIYAGUNI

unread,
Jul 30, 2014, 4:17:33 AM7/30/14
to ruby-...@googlegroups.com
Hi

Please tell me following information:

1. Version of Turnip and RSpec
2. Content of step that is calling "step `I press :button`"
    - e.g. `When I press "OK"`
3. Command to run
    - e.g. `rspec spec/features/foobar.feature`
4. Are you load the .rb file that contains the module and step?
    - see https://github.com/jnicklas/turnip#where-to-place-steps


2014年7月28日月曜日 12時48分38秒 UTC+9 hai nguyen ngoc:

hai nguyen ngoc

unread,
Jul 30, 2014, 9:32:43 PM7/30/14
to ruby-...@googlegroups.com
Hi

1. turnip (1.2.1) , rspec (3.0.0)

2.  And I press "登録する"
    Then I want to see "更新しました。"

3. rspec spec/features/<name-of-feature>

4. This is my configuration in module: 
   module ToleranceForSeleniumSyncIssues
      ...
      RSpec.configure { |c| c.include ToleranceForSeleniumSyncIssues }
   end

Wataru MIYAGUNI

unread,
Jul 31, 2014, 1:03:38 AM7/31/14
to ruby-...@googlegroups.com
Hmm...

Please try this code https://github.com/gongo/turnip_demo_1 .
It has become what has been modeled on the code that you showed.
Expected result was written in README.

How about that?

hai nguyen ngoc

unread,
Jul 31, 2014, 12:09:23 PM7/31/14
to ruby-...@googlegroups.com
wowwwww, IT WORKS SO WELL! 
thanks so much <3
Reply all
Reply to author
Forward
0 new messages