Module: Aygabtu::RSpec::ExampleGroupModule
- Defined in:
- lib/aygabtu/rspec.rb
Instance Attribute Summary collapse
-
#aygabtu_path_to_visit ⇒ Object
Returns the value of attribute aygabtu_path_to_visit.
Class Method Summary collapse
Instance Method Summary collapse
- #aygabtu_assert_not_redirected_away ⇒ Object
- #aygabtu_assert_status_success ⇒ Object
- #aygabtu_assertions ⇒ Object
- #aygabtu_example_for(path) ⇒ Object
- #aygabtu_fetch_symbolic_pass_value(symbol) ⇒ Object
- #aygabtu_pass_to_route(id, visiting_data) ⇒ Object
Instance Attribute Details
#aygabtu_path_to_visit ⇒ Object
Returns the value of attribute aygabtu_path_to_visit.
76 77 78 |
# File 'lib/aygabtu/rspec.rb', line 76 def aygabtu_path_to_visit @aygabtu_path_to_visit end |
Class Method Details
.included(group) ⇒ Object
67 68 69 |
# File 'lib/aygabtu/rspec.rb', line 67 def self.included(group) group.extend ExampleGroupMethods end |
Instance Method Details
#aygabtu_assert_not_redirected_away ⇒ Object
105 106 107 108 109 110 |
# 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 ⇒ Object
101 102 103 |
# File 'lib/aygabtu/rspec.rb', line 101 def aygabtu_assert_status_success expect(page.status_code).to be 200 end |
#aygabtu_assertions ⇒ Object
112 113 114 |
# 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) ⇒ Object
71 72 73 74 |
# File 'lib/aygabtu/rspec.rb', line 71 def aygabtu_example_for(path) visit path aygabtu_assertions end |
#aygabtu_fetch_symbolic_pass_value(symbol) ⇒ Object
96 97 98 99 |
# 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) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# 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 |