Module: Panda::Core::Testing::RSpecConfig
- Defined in:
- lib/panda/core/testing/rspec_config.rb
Class Method Summary collapse
- .configure(config) ⇒ Object
-
.setup_matchers ⇒ Object
Common matchers for Panda gems.
Class Method Details
.configure(config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/panda/core/testing/rspec_config.rb', line 7 def self.configure(config) # Add common RSpec configurations config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end config. = :apply_to_host_groups config.filter_run_when_matching :focus config.example_status_persistence_file_path = "spec/examples.txt" config.disable_monkey_patching! if config.files_to_run.one? config.default_formatter = "doc" end config.order = :random Kernel.srand config.seed # Database cleaner setup if defined?(DatabaseCleaner) config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.cleaning do example.run end end end # OmniAuth test mode if defined?(OmniAuth) config.before(:each) do OmniAuth.config.test_mode = true end config.after(:each) do OmniAuth.config.mock_auth.clear end end end |
.setup_matchers ⇒ Object
Common matchers for Panda gems
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/panda/core/testing/rspec_config.rb', line 56 def self.setup_matchers RSpec::Matchers.define :have_breadcrumb do |expected| match do |page| page.has_css?(".breadcrumb", text: expected) end end RSpec::Matchers.define :have_flash_message do |type, | match do |page| page.has_css?(".flash-message.flash-#{type}", text: ) end end end |