lib/rspec/roda.rb in rspec-roda-0.1.1 vs lib/rspec/roda.rb in rspec-roda-0.2.0

- old
+ new

@@ -1,22 +1,25 @@ # frozen_string_literal: true + require 'rspec/roda/version' require 'rspec' require 'rspec/its' require 'rack/test' require 'inflecto' +require 'rspec/mocks/standalone' +require 'rspec/matchers' module RSpec # Module containing different contexts for Roda. module Roda # Module containing helpers for specifying Roda apps. module App include Rack::Test::Methods # @return [Class(Roda)] def roda_class - described_class + respond_to?(:_roda_class) ? _roda_class : described_class end # Rack-, and Rack::Test-compliant Roda app # @return [#call] def app @@ -35,13 +38,16 @@ end # @param [Symbol] plugin # @param [Proc] block def roda(plugin = metadata[:name], &block) - let(:roda_class) do + let(:_roda_class) do route_block = self.route_block self.class.const_set(:TestApp, Class.new(::Roda) do + include ::RSpec::Matchers + include ::RSpec::Mocks::ExampleMethods + plugin plugin instance_exec(&block) if block route { |r| instance_exec(r, &route_block) } if route_block end) end @@ -76,6 +82,11 @@ RSpec.shared_context 'Roda plugin', roda: :plugin do extend RSpec::Roda::Plugin::ClassInterface include_context 'Roda app' let(:route_block) { proc { |r| } } + let(:plugin) { described_class } + + it { expect(plugin).to be_a Module } end + +RSpec::Mocks::Syntax.enable_should