module Aygabtu::RSpec::ExampleGroupModule

Attributes

aygabtu_path_to_visit[RW]

Public Class Methods

included(group) click to toggle source
# File lib/aygabtu/rspec.rb, line 67
def self.included(group)
  group.extend ExampleGroupMethods
end

Public Instance Methods

aygabtu_assert_not_redirected_away() click to toggle source
# File lib/aygabtu/rspec.rb, line 105
def aygabtu_assert_not_redirected_away # @TODO create custom rspec matcher to provide cleaner error messages
  uri = URI(current_url)
  uri.host = nil
  uri.scheme = nil
  expect(uri.to_s).to be == aygabtu_path_to_visit
end
aygabtu_assert_status_success() click to toggle source
# File lib/aygabtu/rspec.rb, line 101
def aygabtu_assert_status_success
  expect(page.status_code).to be 200
end
aygabtu_assertions() click to toggle source
# File lib/aygabtu/rspec.rb, line 112
def aygabtu_assertions
  raise "Hey aygabtu user, please implement this yourself by overriding the aygabtu_assertions method!"
end
aygabtu_example_for(path) click to toggle source
# File lib/aygabtu/rspec.rb, line 71
def aygabtu_example_for(path)
  visit path
  aygabtu_assertions
end
aygabtu_fetch_symbolic_pass_value(symbol) click to toggle source
# File lib/aygabtu/rspec.rb, line 96
def aygabtu_fetch_symbolic_pass_value(symbol)
  raise "Symbolic pass value #{symbol} given, but no such method defined" unless respond_to?(symbol)
  send(symbol)
end
aygabtu_pass_to_route(id, visiting_data) click to toggle source
# File lib/aygabtu/rspec.rb, line 78
def aygabtu_pass_to_route(id, visiting_data)
  route = self.class.aygabtu_handle.routes.find { |a_route| a_route.object_id == id }

  visiting_data = visiting_data.clone
  visiting_data.keys.each do |key|
    value = visiting_data[key]
    visiting_data[key] = aygabtu_fetch_symbolic_pass_value(value) if value.is_a?(Symbol)
  end

  missing_keys = route.really_required_keys - visiting_data.keys.map(&:to_s)

  if missing_keys.empty?
    route.format(visiting_data)
  else
    raise "Route is missing required key(s) #{missing_keys.map(&:inspect).join(', ')}"
  end
end