Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Feature: Patents Administration
- Scenario: Patents index
- Given I am on the admin patents page
- Then I should see "Patents"
- And the title should be "Wavetronix - Patents"
- Given /^I am on the (.*?) page$/ do |text|
- visit eval("#{text.downcase.gsub(/s/, '_')}_path(locale: 'en')")
- end
- Then /^I should see "(.*?)"$/ do |text|
- page.must_have_selector('h1', text: text)
- end
- Then /^the title should be "(.*?)"$/ do |text|
- page.must_have_selector('title', text: text)
- end
- module Admin
- class PatentsController < BaseController
- before_filter :find_patent
- def index
- end
- private
- def find_patent
- @patent = Patent.find(params[:id]) if params[:id]
- end
- end
- end
- module Admin
- class BaseController < ApplicationController
- filter_access_to :index
- def index
- end
- end
- end
- def has_selector?(*args)
- assert_selector(*args)
- rescue Capybara::ExpectationNotMet
- return false
- end
- def assert_selector(*args)
- synchronize do
- result = all(*args)
- result.matches_count? or raise Capybara::ExpectationNotMet, result.failure_message
- end
- return true
- end
- def path_to(page_name)
- case page_name
- when /the home page/
- root_path
- else
- begin
- page_name =~ /the (.*) page/
- path_components = $1.split(/s+/)
- self.send(path_components.push('path').join('_').to_sym)
- rescue Object => e
- raise "Can't find mapping from "#{page_name}" to a path.n" +
- "Now, go and add a mapping in #{__FILE__}"
- end
- end
- end
- Given /^(?:|I )am on (.+)$/ do |page_name|
- visit path_to(page_name)
- end
- Given I am on the home page
Add Comment
Please, Sign In to add comment