SHARE
TWEET

Untitled

a guest Jan 19th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Feature: Patents Administration
  2.  
  3.   Scenario: Patents index
  4.     Given I am on the admin patents page
  5.     Then I should see "Patents"
  6.     And the title should be "Wavetronix - Patents"
  7.    
  8. Given /^I am on the (.*?) page$/ do |text|
  9.   visit eval("#{text.downcase.gsub(/s/, '_')}_path(locale: 'en')")
  10. end
  11.  
  12. Then /^I should see "(.*?)"$/ do |text|
  13.   page.must_have_selector('h1', text: text)
  14. end
  15.  
  16. Then /^the title should be "(.*?)"$/ do |text|
  17.   page.must_have_selector('title', text: text)
  18. end
  19.    
  20. module Admin
  21.   class PatentsController < BaseController
  22.     before_filter :find_patent
  23.  
  24.     def index
  25.  
  26.     end
  27.  
  28.   private
  29.  
  30.     def find_patent
  31.       @patent = Patent.find(params[:id]) if params[:id]
  32.     end
  33.   end
  34. end
  35.    
  36. module Admin
  37.   class BaseController < ApplicationController
  38.  
  39.     filter_access_to :index
  40.  
  41.     def index
  42.     end
  43.  
  44.   end
  45. end
  46.    
  47. def has_selector?(*args)
  48.   assert_selector(*args)
  49. rescue Capybara::ExpectationNotMet
  50.   return false
  51. end
  52.  
  53. def assert_selector(*args)
  54.  synchronize do
  55.    result = all(*args)
  56.    result.matches_count? or raise Capybara::ExpectationNotMet, result.failure_message
  57.  end
  58.  return true
  59. end
  60.    
  61. def path_to(page_name)
  62.     case page_name
  63.     when /the home page/
  64.       root_path
  65.     else
  66.       begin
  67.         page_name =~ /the (.*) page/
  68.         path_components = $1.split(/s+/)
  69.         self.send(path_components.push('path').join('_').to_sym)
  70.       rescue Object => e
  71.         raise "Can't find mapping from "#{page_name}" to a path.n" +
  72.           "Now, go and add a mapping in #{__FILE__}"
  73.       end
  74.     end
  75.   end
  76.    
  77. Given /^(?:|I )am on (.+)$/ do |page_name|
  78.   visit path_to(page_name)
  79. end
  80.    
  81. Given I am on the home page
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top