diff --git a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb index dc25c9d24f..a25b7055f6 100644 --- a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb +++ b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb @@ -94,10 +94,6 @@ def streams_of(event_id) @stream_entries.streams_of(event_id).map { |name| Stream.new(name) } end - def search_streams(stream_name) - @stream_entries.search_streams(stream_name) - end - private def validate_event_ids(event_ids) diff --git a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb index fb507206b0..df662482e8 100644 --- a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb +++ b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb @@ -46,16 +46,6 @@ def position_in_stream(event_id, stream) def event_in_stream?(event_id, stream) stream_entries.by_stream(stream).by_event_id(event_id).exist? end - - def search_streams(stream_name) - stream_entries - .where { stream.like("#{stream_name}%") } - .distinct - .limit(10) - .order(:stream) - .pluck(:stream) - .map { |name| Stream.new(name) } - end end end end diff --git a/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb b/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb index e7732d1d53..2bb0571a7e 100644 --- a/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb +++ b/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb @@ -172,14 +172,6 @@ def streams_of(event_id) @db[:event_store_events_in_streams].where(event_id: event_id).map { |h| Stream.new(h[:stream]) } end - def search_streams(stream_name) - @db[:event_store_events_in_streams] - .where(::Sequel.like(:stream, "#{stream_name}%")) - .select(:stream) - .limit(10) - .map { |h| Stream.new(h[:stream]) } - end - private def optimize_timestamp(valid_at, created_at) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb index c7e4712e7c..931e095d5b 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb @@ -47,10 +47,6 @@ def count(specification) @repo_reader.count(specification) end - def search_streams(stream_name) - @repo_reader.search_streams(stream_name) - end - def update_messages(records) hashes = records.map { |record| upsert_hash(record, record.serialize(serializer)) } for_update = records.map(&:event_id) @@ -85,10 +81,6 @@ def event_in_stream?(event_id, stream) @repo_reader.event_in_stream?(event_id, stream) end - def inspect - "#{self.class} with #{::ActiveRecord::Base.connection.adapter_name} db adapter" - end - private attr_reader :serializer diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index b6158b6171..0a1d4eae52 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -57,14 +57,6 @@ def event_in_stream?(event_id, stream) @stream_klass.where(event_id: event_id, stream: stream.name).exists? end - def search_streams(stream) - @stream_klass - .where("stream LIKE ?", "#{stream}%") - .limit(10) - .pluck("distinct stream") - .map { |name| Stream.new(name) } - end - private attr_reader :serializer diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 1e87c14917..dfd8bc9466 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -183,65 +183,6 @@ module ActiveRecord expect(event_record.valid_at).to eq(t2) end - specify "finds streams that match the search phrase" do - repository.append_to_stream( - [SRecord.new(event_id: e1 = SecureRandom.uuid)], - s1 = Stream.new("Dummy$#{e1}"), - ExpectedVersion.any - ) - repository.append_to_stream( - [SRecord.new(event_id: e2 = SecureRandom.uuid)], - s2 = Stream.new("Dummy$#{e2}"), - ExpectedVersion.any - ) - repository.append_to_stream( - [SRecord.new(event_id: e3 = SecureRandom.uuid)], - s3 = Stream.new("Dummy$#{e3}"), - ExpectedVersion.any - ) - - expect(repository.search_streams("Du")).to contain_exactly(s3, s2, s1) - expect(repository.search_streams("Dummy")).to contain_exactly(s3, s2, s1) - end - - specify "limits searched streams to 10" do - 11.times do |index| - repository.append_to_stream( - [SRecord.new(event_id: e1 = SecureRandom.uuid)], - Stream.new("Dummy$#{e1}"), - ExpectedVersion.any - ) - end - - expect(repository.search_streams("Du").size).to eq 10 - end - - specify "finds no streams when search phrase doesn't match anything" do - repository.append_to_stream( - [SRecord.new(event_id: e1 = SecureRandom.uuid)], - Stream.new("Dummy$#{e1}"), - ExpectedVersion.any - ) - repository.append_to_stream( - [SRecord.new(event_id: e2 = SecureRandom.uuid)], - Stream.new("Dummy$#{e2}"), - ExpectedVersion.any - ) - repository.append_to_stream( - [SRecord.new(event_id: e3 = SecureRandom.uuid)], - Stream.new("Dummy$#{e3}"), - ExpectedVersion.any - ) - - expect(repository.search_streams("Da")).to eq([]) - expect(repository.search_streams("da")).to eq([]) - expect(repository.search_streams("dam")).to eq([]) - expect(repository.search_streams("damm")).to eq([]) - expect(repository.search_streams("dammy")).to eq([]) - expect(repository.search_streams("Dammy")).to eq([]) - end - - specify "with batches and bi-temporal queries use offset + limit" do repository.append_to_stream( [ @@ -378,12 +319,6 @@ module ActiveRecord }x end - describe "#inspect" do - specify "returns string representation" do - expect(repository.inspect).to eq("RubyEventStore::ActiveRecord::EventRepository with #{::ActiveRecord::Base.connection.adapter_name} db adapter") - end - end - private def with_precision(time) diff --git a/ruby_event_store-browser/elm/src/Api.elm b/ruby_event_store-browser/elm/src/Api.elm index 5588e6cde4..b1b597a0fb 100644 --- a/ruby_event_store-browser/elm/src/Api.elm +++ b/ruby_event_store-browser/elm/src/Api.elm @@ -1,9 +1,9 @@ -module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), SearchStream, Stats, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStats, getStream, searchStreamsDecoder) +module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getStream) import Flags exposing (Flags) import Http import Iso8601 -import Json.Decode exposing (Decoder, field, int, list, maybe, string, succeed, value) +import Json.Decode exposing (Decoder, field, list, maybe, string, succeed, value) import Json.Decode.Pipeline exposing (optional, optionalAt, required, requiredAt) import Json.Encode exposing (encode) import Maybe.Extra @@ -38,15 +38,6 @@ type alias Event = } -type alias SearchStream = - { streamId : String - } - - -type alias Stats = - { eventsInTotal : Int - } - type alias PaginatedList a = { pagination : Pagination.Specification @@ -94,15 +85,6 @@ streamUrl flags streamId = buildUrl (Url.toString flags.apiUrl ++ "/streams") streamId -searchStreamsUrl : Flags -> String -> String -searchStreamsUrl flags query = - buildUrl (Url.toString flags.apiUrl ++ "/search_streams") query - - -getStatsUrl : Flags -> String -getStatsUrl flags = - Url.toString flags.apiUrl ++ "/stats" - getEvent : (Result Http.Error Event -> msg) -> Flags -> String -> Cmd msg getEvent msgBuilder flags eventId = @@ -120,21 +102,6 @@ getStream msgBuilder flags streamId = } -getSearchStreams : (Result Http.Error (List SearchStream) -> msg) -> Flags -> String -> Cmd msg -getSearchStreams msgBuilder flags query = - Http.get - { url = searchStreamsUrl flags query - , expect = Http.expectJson msgBuilder searchStreamsDecoder - } - - -getStats : (Result Http.Error Stats -> msg) -> Flags -> Cmd msg -getStats msgBuilder flags = - Http.get - { url = getStatsUrl flags - , expect = Http.expectJson msgBuilder statsDecoder - } - eventDecoder : Decoder Event eventDecoder = @@ -190,29 +157,6 @@ eventsDecoder pagination = |> required "links" linksDecoder -searchStreamDecoder : Decoder SearchStream -searchStreamDecoder = - succeed SearchStream - |> required "id" string - - -searchStreamsDecoder : Decoder (List SearchStream) -searchStreamsDecoder = - list searchStreamDecoder - |> field "data" - - -statsDecoder : Decoder Stats -statsDecoder = - statsDecoder_ - |> field "meta" - - -statsDecoder_ : Decoder Stats -statsDecoder_ = - succeed Stats - |> required "events_in_total" int - linksDecoder : Decoder PaginationLinks linksDecoder = diff --git a/ruby_event_store-browser/elm/src/Flags.elm b/ruby_event_store-browser/elm/src/Flags.elm index 372acbe756..d24891ab10 100644 --- a/ruby_event_store-browser/elm/src/Flags.elm +++ b/ruby_event_store-browser/elm/src/Flags.elm @@ -7,7 +7,6 @@ type alias RawFlags = { rootUrl : String , apiUrl : String , resVersion : String - , repositoryAdapter : String , platform : String } @@ -16,11 +15,10 @@ type alias Flags = { rootUrl : Url.Url , apiUrl : Url.Url , resVersion : String - , repositoryAdapter : String , platform : String } buildFlags : RawFlags -> Maybe Flags -buildFlags { rootUrl, apiUrl, resVersion, repositoryAdapter, platform } = - Maybe.map5 Flags (Url.fromString rootUrl) (Url.fromString apiUrl) (Just resVersion) (Just repositoryAdapter) (Just platform) +buildFlags { rootUrl, apiUrl, resVersion, platform } = + Maybe.map4 Flags (Url.fromString rootUrl) (Url.fromString apiUrl) (Just resVersion) (Just platform) diff --git a/ruby_event_store-browser/elm/src/Layout.elm b/ruby_event_store-browser/elm/src/Layout.elm index 543f7c8ce4..56dec4d5af 100644 --- a/ruby_event_store-browser/elm/src/Layout.elm +++ b/ruby_event_store-browser/elm/src/Layout.elm @@ -1,6 +1,5 @@ port module Layout exposing (Model, Msg, buildModel, subscriptions, update, view, viewIncorrectConfig, viewNotFound) -import Api exposing (SearchStream, getSearchStreams) import Browser exposing (Document) import Browser.Navigation import BrowserTime @@ -23,27 +22,14 @@ import WrappedModel exposing (..) type Msg = TimeZoneSelected String | SearchMsg Search.Msg - | ToggleBookmarksMenu | ToggleDialog - | SearchedStreamsFetched (Result Http.Error (List SearchStream)) | OnSelect Search.Stream - | OnQueryChanged Search.Stream | RequestSearch | RequestSearchClose - | ToggleBookmark String type alias Model = { search : Search.Model Msg - , displayBookmarksMenu : Bool - , bookmarks : List Bookmark - } - - -type alias Bookmark = - { label : String - , link : String - , itemType : String } @@ -59,9 +45,6 @@ port requestSearchClose : (() -> msg) -> Sub msg port closeSearch : String -> Cmd msg -port toggleBookmark : String -> Cmd msg - - subscriptions : Sub Msg subscriptions = Sub.batch @@ -73,12 +56,7 @@ subscriptions = buildModel : Model buildModel = { search = - Search.init OnSelect OnQueryChanged - , displayBookmarksMenu = False - , bookmarks = - [ { itemType = "Stream", label = "Bookmark 1", link = "/" } - , { itemType = "Stream", label = "Bookmark 2", link = "/" } - ] + Search.init OnSelect } @@ -87,11 +65,6 @@ goToStream { key, flags } stream = Browser.Navigation.pushUrl key (Route.streamUrl flags.rootUrl stream) -searchStreams : WrappedModel Model -> String -> Cmd Msg -searchStreams { flags } stream = - getSearchStreams SearchedStreamsFetched flags stream - - update : Msg -> WrappedModel Model -> ( WrappedModel Model, Cmd Msg ) update msg model = case msg of @@ -100,7 +73,7 @@ update msg model = ( newSearch, cmd ) = Search.update searchMsg model.internal.search in - ( { model | internal = Model newSearch model.internal.displayBookmarksMenu model.internal.bookmarks }, cmd ) + ( { model | internal = Model newSearch }, cmd ) OnSelect streamName -> ( model @@ -110,9 +83,6 @@ update msg model = ] ) - OnQueryChanged streamName -> - ( model, searchStreams model streamName ) - TimeZoneSelected zoneName -> let defaultTimeZone = @@ -156,38 +126,9 @@ update msg model = RequestSearchClose -> ( model, closeSearch searchModalId ) - ToggleBookmarksMenu -> - ( { model | internal = Model model.internal.search (not model.internal.displayBookmarksMenu) model.internal.bookmarks }, Cmd.none ) - ToggleDialog -> ( model, toggleDialog searchModalId ) - SearchedStreamsFetched (Ok streams) -> - let - streams_ = - List.map .streamId streams - - searchModel = - model.internal.search - - newModel = - { searchModel | streams = streams_ } - in - ( { model | internal = Model newModel model.internal.displayBookmarksMenu model.internal.bookmarks }, Cmd.none ) - - SearchedStreamsFetched (Err _) -> - let - searchModel = - model.internal.search - - newModel = - { searchModel | streams = [] } - in - ( { model | internal = Model newModel model.internal.displayBookmarksMenu model.internal.bookmarks }, Cmd.none ) - - ToggleBookmark id -> - ( model, toggleBookmark id ) - view : (Msg -> a) -> WrappedModel Model -> Html a -> Html a view layoutMsgBuilder model pageView = @@ -231,7 +172,7 @@ browserNavigation model = ] , div [ class "flex items-center gap-2" ] - [ fakeSearchInput model.flags.platform, bookmarksMenu model ] + [ fakeSearchInput model.flags.platform ] ] @@ -258,8 +199,6 @@ browserFooter { flags, time } = , link "Documentation" "https://railseventstore.org/docs/install/" , spacer , link "Support" "https://railseventstore.org/support/" - , spacer - , link "Debug" (Route.debugUrl flags.rootUrl) ] , div [ class "text-gray-500 text-sm flex item-center gap-2" ] @@ -279,48 +218,6 @@ timeZoneSelect time = (availableTimeZones time.detected |> List.map mkOption) -visibleBookmarksMenu : Bool -> String -visibleBookmarksMenu displayBookmarksMenu = - if displayBookmarksMenu then - "block" - - else - "hidden" - - -bookmarkToHtml : Bookmark -> Html Msg -bookmarkToHtml bookmark = - li [ class "flex hover:bg-gray-50 group pr-2" ] - [ a [ href bookmark.link, class "whitespace-nowrap py-2 block pl-4 pr-3" ] - [ text bookmark.label ] - , button [ title "Remove bookmark", class "group-hover:visible invisible text-gray-300 hover:text-gray-800", onClick (ToggleBookmark bookmark.link) ] - [ FeatherIcons.trash2 - |> FeatherIcons.withClass "size-4" - |> FeatherIcons.toHtml [] - ] - ] - - -bookmarksMenu : WrappedModel Model -> Html Msg -bookmarksMenu model = - div [ class "relative" ] - [ button - [ onClick ToggleBookmarksMenu - , class "text-red-100 outline-none text-sm flex gap-2 items-center bg-red-800 hover:bg-red-900 h-9 px-3 rounded" - ] - [ FeatherIcons.bookmark - |> FeatherIcons.withClass "size-4" - |> FeatherIcons.toHtml [] - ] - , div [ class ("absolute translate-y-4 right-0 top-full bg-white shadow rounded-sm" ++ " " ++ visibleBookmarksMenu model.internal.displayBookmarksMenu) ] - [ model.internal.bookmarks - |> List.map bookmarkToHtml - |> ul [ class "text-gray-800 text-sm" ] - , button [ onClick (ToggleBookmark "hi") ] [ text "Add bookmark here" ] - ] - ] - - fakeSearchInput : String -> Html Msg fakeSearchInput platform = button diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index c610bf064a..d18aa4cab6 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -8,7 +8,6 @@ import Flags exposing (Flags, RawFlags, buildFlags) import Html exposing (..) import Layout import LinkedTimezones exposing (mapLinkedTimeZone) -import Page.Debug import Page.ShowEvent import Page.ShowStream import Route @@ -50,14 +49,12 @@ type Msg | GotShowEventMsg Page.ShowEvent.Msg | GotShowStreamMsg Page.ShowStream.Msg | ReceiveTimeZone (Result String Time.ZoneName) - | GotDebugMsg Page.Debug.Msg type Page = NotFound | ShowEvent Page.ShowEvent.Model | ShowStream Page.ShowStream.Model - | Debug Page.Debug.Model subscriptions : Model -> Sub Msg @@ -131,15 +128,6 @@ update msg model = , Cmd.map GotShowEventMsg subCmd ) - ( GotDebugMsg gotDebugMsg, Debug debugModel ) -> - let - ( subModel, subCmd ) = - Page.Debug.update gotDebugMsg debugModel - in - ( { model | page = Debug subModel } - , Cmd.map GotDebugMsg subCmd - ) - ( GotLayoutMsg layoutMsg, _ ) -> case model.flags of Nothing -> @@ -224,16 +212,6 @@ navigate model location = Nothing -> ( { model | page = NotFound }, Cmd.none ) - Just Route.Debug -> - let - page = - Page.Debug.init flags - - cmd = - Page.Debug.initCmd flags - in - ( { model | page = Debug page }, Cmd.map GotDebugMsg cmd ) - Nothing -> ( { model | page = NotFound }, Cmd.none ) @@ -286,12 +264,5 @@ viewPage page selectedTime = in ( Just title, Html.map GotShowEventMsg content ) - Debug pageModel -> - let - content = - Page.Debug.view pageModel - in - ( Just "Debug", content ) - NotFound -> ( Nothing, Layout.viewNotFound ) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm deleted file mode 100644 index 63d9c47489..0000000000 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ /dev/null @@ -1,45 +0,0 @@ -module Page.Debug exposing (..) - -import Api exposing (Stats, getStats) -import Flags exposing (Flags) -import Html exposing (..) -import Http - - -type alias Model = - { resVersion : String, repositoryAdapter : String, eventsInTotal : String } - - -type Msg - = GotStats (Result Http.Error Stats) - - -init : Flags -> Model -init flags = - { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter, eventsInTotal = "" } - - -initCmd : Flags -> Cmd Msg -initCmd flags = - getStats GotStats flags - - -view : Model -> Html a -view model = - div [] - [ p [] [ text ("RubyEventStore version: " ++ model.resVersion) ] - , p [] [ text ("RubyEventStore adapter: " ++ model.repositoryAdapter) ] - , p [] [ text ("Events in total: " ++ model.eventsInTotal) ] - ] - - -update : Msg -> Model -> ( Model, Cmd Msg ) -update msg model = - case msg of - GotStats result -> - case result of - Ok stats -> - ( { model | eventsInTotal = String.fromInt stats.eventsInTotal }, Cmd.none ) - - Err _ -> - ( model, Cmd.none ) diff --git a/ruby_event_store-browser/elm/src/Route.elm b/ruby_event_store-browser/elm/src/Route.elm index 28a9085abb..e50aa6a95d 100644 --- a/ruby_event_store-browser/elm/src/Route.elm +++ b/ruby_event_store-browser/elm/src/Route.elm @@ -1,4 +1,4 @@ -module Route exposing (Route(..), buildUrl, debugUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl) +module Route exposing (Route(..), buildUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl) import Maybe.Extra import Pagination @@ -12,7 +12,6 @@ import Url.Parser.Query as Query type Route = BrowseEvents String Pagination.Specification | ShowEvent String - | Debug decodeLocation : Url.Url -> Url.Url -> Maybe Route @@ -26,7 +25,6 @@ routeParser = [ Url.Parser.map (BrowseEvents "all" Pagination.empty) Url.Parser.top , Url.Parser.map browseEvents (Url.Parser.s "streams" Url.Parser.string Query.string "page[position]" Query.string "page[direction]" Query.string "page[count]") , Url.Parser.map ShowEvent (Url.Parser.s "events" Url.Parser.string) - , Url.Parser.map Debug (Url.Parser.s "debug" Url.Parser.top) ] @@ -55,11 +53,6 @@ eventUrl baseUrl eventId = buildUrl baseUrl [ "events", Url.percentEncode eventId ] [] -debugUrl : Url.Url -> String -debugUrl baseUrl = - buildUrl baseUrl [ "debug" ] [] - - pathSegments : Url.Url -> List String pathSegments baseUrl = List.filter (\e -> e /= "") (String.split "/" baseUrl.path) diff --git a/ruby_event_store-browser/elm/src/Search.elm b/ruby_event_store-browser/elm/src/Search.elm index 69e1a9d8dd..091236e1cf 100644 --- a/ruby_event_store-browser/elm/src/Search.elm +++ b/ruby_event_store-browser/elm/src/Search.elm @@ -13,10 +13,8 @@ type alias Stream = type alias Model a = - { streams : List Stream - , searchedStream : Stream + { stream : Stream , onSelectMsg : Stream -> a - , onQueryMsg : Stream -> a } @@ -35,12 +33,10 @@ emptyStreams = [] -init : (Stream -> a) -> (Stream -> a) -> Model a -init onSelectMsg onQueryMsg = - { streams = emptyStreams - , searchedStream = emptyStreamName +init : (Stream -> a) -> Model a +init onSelectMsg = + { stream = emptyStreamName , onSelectMsg = onSelectMsg - , onQueryMsg = onQueryMsg } @@ -49,73 +45,28 @@ onSelectCmd onSelectMsg stream = Task.perform onSelectMsg (Task.succeed stream) -onQueryChangedCmd : (Stream -> a) -> Stream -> Cmd a -onQueryChangedCmd onQueryMsg stream = - Task.perform onQueryMsg (Task.succeed stream) - - -hasAtLeastThreeChars : Stream -> Bool -hasAtLeastThreeChars stream = - String.length stream >= 3 - - update : Msg -> Model a -> ( Model a, Cmd a ) update msg model = case msg of StreamChanged stream -> - if hasAtLeastThreeChars stream then - ( { model | searchedStream = stream } - , onQueryChangedCmd model.onQueryMsg stream - ) - - else - ( { model | searchedStream = stream }, Cmd.none ) + ( { model | stream = stream }, Cmd.none ) GoToStream stream -> - ( { model | searchedStream = emptyStreamName } + ( { model | stream = emptyStreamName } , onSelectCmd model.onSelectMsg stream ) -caseInsensitiveContains : Stream -> Stream -> Maybe Stream -caseInsensitiveContains needle haystack = - let - needleLower = - String.toLower needle - - haystackLower = - String.toLower haystack - in - if String.contains needleLower haystackLower then - Just haystack - - else - Nothing - - -filterStreams : Stream -> List Stream -> List Stream -filterStreams stream streams = - if String.isEmpty stream then - emptyStreams - - else - List.filterMap (caseInsensitiveContains stream) streams - - view : Model a -> Html Msg view model = - let - streams_ = - filterStreams model.searchedStream model.streams - in - form [ onSubmit (GoToStream model.searchedStream) ] + form [ onSubmit (GoToStream model.stream) ] [ div [ class "relative" ] [ FeatherIcons.search |> FeatherIcons.withClass "size-4 text-gray-400 absolute pointer-events-none top-3.5 left-2" |> FeatherIcons.toHtml [] , input [ class "rounded text-gray-800 cursor-pointer pl-8 pr-12 py-2 w-full appearance-none outline-none focus:ring-2 focus:ring-red-500 focus:ring-opacity-50" - , value model.searchedStream + , value model.stream , onInput StreamChanged , placeholder "Quick search…" , autofocus True @@ -125,36 +76,4 @@ view model = [ span [ class "text-gray-500 bg-gray-50 font-bold block p-1 border border-gray-300 rounded " ] [ text "ESC" ] ] ] - , viewStreamList streams_ - ] - - -streamsPresent : List Stream -> Bool -streamsPresent streams = - not <| List.isEmpty streams - - -viewStreamList : List Stream -> Html Msg -viewStreamList streams = - if streams |> streamsPresent then - div - [] - [ ul - [ class "mt-4 overflow-auto space-y-2 w-full" ] - (List.map viewStreamListItem streams) - ] - - else - text "" - - -viewStreamListItem : Stream -> Html Msg -viewStreamListItem stream = - li [] - [ a - [ class "p-3 block rounded hover:bg-red-200 w-full bg-gray-100 break-words text-xs font-bold font-mono" - , href ("/streams/" ++ stream) - , onClick (GoToStream stream) - ] - [ text stream ] ] diff --git a/ruby_event_store-browser/elm/tests/DecodersTest.elm b/ruby_event_store-browser/elm/tests/DecodersTest.elm index add018c5d7..a90afd1aa4 100644 --- a/ruby_event_store-browser/elm/tests/DecodersTest.elm +++ b/ruby_event_store-browser/elm/tests/DecodersTest.elm @@ -1,6 +1,6 @@ module DecodersTest exposing (suite) -import Api exposing (eventDecoder, eventsDecoder, searchStreamsDecoder) +import Api exposing (eventDecoder, eventsDecoder) import Expect import Json.Decode import Pagination @@ -143,35 +143,5 @@ suite = , validAt = Time.millisToPosix 1513813785273 } ) - , test "search decoder" <| - \_ -> - let - input = - """ - { - "data": [ - { - "id": "$by_tenant_id_133", - "type": "streams" - }, - { - "id": "$by_tenant_id_444", - "type": "streams" - } - ] - } - """ - - output = - Json.Decode.decodeString searchStreamsDecoder input - in - Expect.equal output - (Ok - [ { streamId = "$by_tenant_id_133" - } - , { streamId = "$by_tenant_id_444" - } - ] - ) ] ] diff --git a/ruby_event_store-browser/elm/tests/SearchTest.elm b/ruby_event_store-browser/elm/tests/SearchTest.elm deleted file mode 100644 index 19b53ddd74..0000000000 --- a/ruby_event_store-browser/elm/tests/SearchTest.elm +++ /dev/null @@ -1,38 +0,0 @@ -module SearchTest exposing (suite) - -import Expect -import Search exposing (filterStreams) -import Test exposing (..) - - -suite : Test -suite = - describe "Suite" - [ describe "filter streams" <| - [ test "filterStreams starting with" <| - \_ -> - Expect.equal - [ "DummyStream$78", "DummyStream$79" ] - (filterStreams "Dum" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams empty" <| - \_ -> - Expect.equal - [] - (filterStreams "" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams non matching" <| - \_ -> - Expect.equal - [] - (filterStreams "foo" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams ending with" <| - \_ -> - Expect.equal - [ "DummyStream$78" ] - (filterStreams "78" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams is case insensitive" <| - \_ -> - Expect.equal - [ "DummyStream$78", "DummyStream$79" ] - (filterStreams "stream" [ "DummyStream$78", "DummyStream$79" ]) - ] - ] diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser.rb b/ruby_event_store-browser/lib/ruby_event_store/browser.rb index 586eafe817..c82d1cefce 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser.rb @@ -13,8 +13,6 @@ module Browser require_relative "browser/json_api_stream" require_relative "browser/get_events_from_stream" require_relative "browser/get_stream" -require_relative "browser/search_streams" require_relative "browser/urls" require_relative "browser/gem_source" require_relative "browser/router" -require_relative "browser/get_stats" \ No newline at end of file diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index b8b2e08fe1..b503c42bd3 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -17,46 +17,47 @@ def self.for( related_streams_query: DEFAULT_RELATED_STREAMS_QUERY ) warn(<<~WARN) if environment - Passing :environment to RubyEventStore::Browser::App.for is deprecated. + Passing :environment to RubyEventStore::Browser::App.for is deprecated. - This option is no-op, has no effect and will be removed in next major release. - WARN + This option is no-op, has no effect and will be removed in next major release. + WARN warn(<<~WARN) if host - Passing :host to RubyEventStore::Browser::App.for is deprecated. + Passing :host to RubyEventStore::Browser::App.for is deprecated. - This option will be removed in next major release. - - Host and mount points are correctly recognized from Rack environment - and this option is redundant. - WARN + This option will be removed in next major release. + + Host and mount points are correctly recognized from Rack environment + and this option is redundant. + WARN warn(<<~WARN) if path - Passing :path to RubyEventStore::Browser::App.for is deprecated. + Passing :path to RubyEventStore::Browser::App.for is deprecated. - This option will be removed in next major release. + This option will be removed in next major release. - Host and mount points are correctly recognized from Rack environment - and this option is redundant. - WARN + Host and mount points are correctly recognized from Rack environment + and this option is redundant. + WARN Rack::Builder.new do use Rack::Static, - urls: %w[ - bootstrap.js - ruby_event_store_browser.css - ruby_event_store_browser.js - android-chrome-192x192.png - android-chrome-512x512.png - apple-touch-icon.png - favicon.ico - favicon-16x16.png - favicon-32x32.png - mstile-70x70.png - mstile-144x144.png - mstile-150x150.png - mstile-310x150.png - mstile-310x310.png - safari-pinned-tab.svg - ].map {|f| ["/#{f}", f] }.to_h, + urls: + %w[ + bootstrap.js + ruby_event_store_browser.css + ruby_event_store_browser.js + android-chrome-192x192.png + android-chrome-512x512.png + apple-touch-icon.png + favicon.ico + favicon-16x16.png + favicon-32x32.png + mstile-70x70.png + mstile-144x144.png + mstile-150x150.png + mstile-310x150.png + mstile-310x310.png + safari-pinned-tab.svg + ].map { |f| ["/#{f}", f] }.to_h, root: "#{__dir__}/../../../public" run App.new( event_store_locator: event_store_locator, @@ -68,7 +69,13 @@ def self.for( end end - def initialize(event_store_locator:, related_streams_query:, host:, root_path:, api_url:) + def initialize( + event_store_locator:, + related_streams_query:, + host:, + root_path:, + api_url: + ) @event_store_locator = event_store_locator @related_streams_query = related_streams_query @routing = Urls.from_configuration(host, root_path, api_url) @@ -77,7 +84,10 @@ def initialize(event_store_locator:, related_streams_query:, host:, root_path:, def call(env) router = Router.new(routing) router.add_route("GET", "/api/events/:event_id") do |params| - json GetEvent.new(event_store: event_store, event_id: params.fetch("event_id")) + json GetEvent.new( + event_store: event_store, + event_id: params.fetch("event_id") + ) end router.add_route("GET", "/api/streams/:stream_name") do |params, urls| json GetStream.new( @@ -86,7 +96,10 @@ def call(env) related_streams_query: related_streams_query ) end - router.add_route("GET", "/api/streams/:stream_name/relationships/events") do |params, urls| + router.add_route( + "GET", + "/api/streams/:stream_name/relationships/events" + ) do |params, urls| json GetEventsFromStream.new( event_store: event_store, routing: urls, @@ -94,18 +107,8 @@ def call(env) page: params["page"] ) end - router.add_route("GET", "/api/search_streams/:stream_name") do |params| - json SearchStreams.new( - event_store: event_store, - stream_name: params.fetch("stream_name"), - ) - end - router.add_route("GET", "/api/stats") do - json GetStats.new( - event_store: event_store - ) - end - %w[/ /events/:event_id /streams/:stream_name /debug].each do |starting_route| + + %w[/ /events/:event_id /streams/:stream_name].each do |starting_route| router.add_route("GET", starting_route) do |_, urls| erb bootstrap_html, browser_js_src: urls.browser_js_url, @@ -114,8 +117,7 @@ def call(env) initial_data: { rootUrl: urls.app_url, apiUrl: urls.api_url, - resVersion: res_version, - repositoryAdapter: repository_adapter + resVersion: res_version } end end @@ -160,20 +162,24 @@ def not_found end def json(body) - [200, { "content-type" => "application/vnd.api+json" }, [JSON.dump(body.to_h)]] + [ + 200, + { "content-type" => "application/vnd.api+json" }, + [JSON.dump(body.to_h)] + ] end def erb(template, **locals) - [200, { "content-type" => "text/html;charset=utf-8" }, [ERB.new(template).result_with_hash(locals)]] + [ + 200, + { "content-type" => "text/html;charset=utf-8" }, + [ERB.new(template).result_with_hash(locals)] + ] end def res_version RubyEventStore::VERSION end - - def repository_adapter - event_store.inspect_repository - end end end end diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb deleted file mode 100644 index 9048eda6f4..0000000000 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module RubyEventStore - module Browser - class GetStats - def initialize(event_store:) - @event_store = event_store - end - - def to_h - { - meta: { - events_in_total: events - } - } - end - - private - - def events - event_store.read.count - end - - attr_reader :event_store - end - end -end diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb deleted file mode 100644 index 84aa4562d8..0000000000 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module RubyEventStore - module Browser - class SearchStreams - def initialize(event_store:, stream_name:) - @event_store = event_store - @stream_name = stream_name - end - - def to_h - { - data: streams - } - end - - private - - def streams - event_store.search_streams(stream_name).map { |stream| { id: stream.name, type: "streams" } } - end - - attr_reader :event_store, :stream_name - end - end -end diff --git a/ruby_event_store-browser/public/bootstrap.js b/ruby_event_store-browser/public/bootstrap.js index 7669f23bea..7f339ed9ec 100644 --- a/ruby_event_store-browser/public/bootstrap.js +++ b/ruby_event_store-browser/public/bootstrap.js @@ -1,6 +1,8 @@ -const flags = JSON.parse(document.querySelector("meta[name='ruby-event-store-browser-settings']").getAttribute("content")); +const flags = JSON.parse( + document.querySelector("meta[name='ruby-event-store-browser-settings']").getAttribute("content") +); flags.platform = navigator.platform; -const app = Elm.Main.init({flags}); +const app = Elm.Main.init({ flags }); app.ports.copyToClipboard.subscribe(function (message) { navigator.clipboard.writeText(message); @@ -26,14 +28,3 @@ window.addEventListener("keydown", function (event) { event.preventDefault(); } }); - -app.ports.toggleBookmark.subscribe(function (id) { - const bookmarks = JSON.parse(localStorage.getItem("bookmarks")) || []; - if (bookmarks.indexOf(id) >= 0) { - bookmarks.splice(bookmarks.indexOf(id), 1); - } else { - bookmarks.push(id); - } - console.log(bookmarks); - localStorage.setItem("bookmarks", JSON.stringify(bookmarks)); -}); diff --git a/ruby_event_store-browser/spec/api/search_streams_spec.rb b/ruby_event_store-browser/spec/api/search_streams_spec.rb deleted file mode 100644 index d05c9f32b3..0000000000 --- a/ruby_event_store-browser/spec/api/search_streams_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require "spec_helper" - -module RubyEventStore - ::RSpec.describe Browser do - include Browser::IntegrationHelpers - - specify "finds desired streams" do - event_store.publish(DummyEvent.new, stream_name: "dummy-1") - event_store.publish(DummyEvent.new, stream_name: "dummy-2") - - api_client.get "/api/search_streams/dum" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"]).to match_array( - [ - { "id" => "dummy-2", "type" => "streams" }, - { "id" => "dummy-1", "type" => "streams" } - ] - ) - - api_client.get "/api/search_streams/dummy-" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"]).to match_array( - [{ "id" => "dummy-2", "type" => "streams" }, { "id" => "dummy-1", "type" => "streams" }] - ) - end - - specify "limits results to 10" do - 11.times do |index| - event_store.publish(DummyEvent.new, stream_name: "dummy-#{index}") - end - - api_client.get "/api/search_streams/dum" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"].size).to eq(10) - end - end -end diff --git a/ruby_event_store-browser/spec/api/stats_spec.rb b/ruby_event_store-browser/spec/api/stats_spec.rb deleted file mode 100644 index 881a228a5e..0000000000 --- a/ruby_event_store-browser/spec/api/stats_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -module RubyEventStore - ::RSpec.describe Browser do - include Browser::IntegrationHelpers - - specify "not existing" do - api_client.get "/api/stats" - expect(api_client.parsed_body["meta"]).to match({ - "events_in_total" => 0 - }) - end - end -end diff --git a/ruby_event_store-browser/spec/browser_settings_spec.rb b/ruby_event_store-browser/spec/browser_settings_spec.rb index 39eacad2d7..c929c89940 100644 --- a/ruby_event_store-browser/spec/browser_settings_spec.rb +++ b/ruby_event_store-browser/spec/browser_settings_spec.rb @@ -13,12 +13,6 @@ module RubyEventStore expect(parsed_meta_content(response.body)["resVersion"]).to eq(RubyEventStore::VERSION) end - specify "passes RES repository adapter specification" do - response = web_client.get "/res" - - expect(parsed_meta_content(response.body)["repositoryAdapter"]).to eq('RubyEventStore::InMemoryRepository') - end - specify "passes root_url" do response = web_client.get "/res" diff --git a/ruby_event_store-browser/spec/web_spec.rb b/ruby_event_store-browser/spec/web_spec.rb index 7cca4a5a7f..3acf98ac69 100644 --- a/ruby_event_store-browser/spec/web_spec.rb +++ b/ruby_event_store-browser/spec/web_spec.rb @@ -10,7 +10,6 @@ module RubyEventStore specify { expect(web_client.get("/").content_type).to eq("text/html;charset=utf-8") } specify { expect(web_client.post("/")).to be_not_found } specify { expect(web_client.get("/streams/all")).to be_ok } - specify { expect(web_client.get("/debug")).to be_ok } specify do event_store.append(event = DummyEvent.new) expect(web_client.get("/events/#{event.event_id}")).to be_ok diff --git a/ruby_event_store/lib/ruby_event_store/client.rb b/ruby_event_store/lib/ruby_event_store/client.rb index 2aa77f3ec1..0ed4217195 100644 --- a/ruby_event_store/lib/ruby_event_store/client.rb +++ b/ruby_event_store/lib/ruby_event_store/client.rb @@ -92,10 +92,6 @@ def streams_of(event_id) repository.streams_of(event_id) end - def search_streams(stream) - repository.search_streams(stream) - end - # Gets position of the event in given stream # # The position is always nonnegative. @@ -337,14 +333,6 @@ def inspect "#<#{self.class}:0x#{__id__.to_s(16)}>" end - def inspect_repository - if repository.public_method(:inspect).owner.equal?(Kernel) - repository.class.inspect - else - repository.inspect - end - end - EMPTY_HASH = {}.freeze private_constant :EMPTY_HASH diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index abb25aca8f..3549d23373 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -126,13 +126,6 @@ def streams_of(event_id) streams.select { |name,| has_event_in_stream?(event_id, name) }.map { |name,| Stream.new(name) } end - def search_streams(stream_name) - streams - .select { |name,| name.include?(stream_name) } - .take(10) - .map { |name,| Stream.new(name) } - end - def position_in_stream(event_id, stream) event_in_stream = streams[stream.name].find { |event_in_stream| event_in_stream.event_id.eql?(event_id) } raise EventNotFoundInStream if event_in_stream.nil? diff --git a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb index b0a635974b..a70311818c 100644 --- a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb @@ -61,14 +61,6 @@ def respond_to_missing?(method_name, _include_private) repository.respond_to?(method_name) end - def inspect - "Instrumented " + if repository.public_method(:inspect).owner.equal?(Kernel) - repository.class.inspect - else - repository.inspect - end - end - private attr_reader :repository, :instrumentation diff --git a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb index d91ea95d0f..faebee594f 100644 --- a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb +++ b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb @@ -1184,32 +1184,6 @@ def read_events_backward(repository, stream = nil, from: nil, to: nil, count: ni expect(repository.streams_of("d10c8fe9-2163-418d-ba47-88c9a1f9391b")).to eq [] end - specify do - event_1 = SRecord.new(event_id: "8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea") - event_2 = SRecord.new(event_id: "8cee1139-4f96-483a-a175-2b947283c3c7") - event_3 = SRecord.new(event_id: "d345f86d-b903-4d78-803f-38990c078d9e") - stream_a = Stream.new("Stream A") - stream_b = Stream.new("Stream B") - stream_c = Stream.new("Stream C") - repository.append_to_stream([event_1], stream_a, version_any) - repository.append_to_stream([event_2], stream_b, version_any) - repository.append_to_stream([event_3], stream_c, version_any) - - expect(repository.search_streams("Str")).to contain_exactly stream_c, stream_b, stream_a - expect(repository.search_streams("Stream A")).to contain_exactly stream_a - expect(repository.search_streams("Stream B")).to contain_exactly stream_b - expect(repository.search_streams("Stream C")).to contain_exactly stream_c - end - - specify do - 11.times do |index| - stream = Stream.new("Stream #{index}") - repository.append_to_stream([ SRecord.new(event_id: SecureRandom.uuid)], stream, version_any) - end - - expect(repository.search_streams("Stream").size).to eq 10 - end - specify do e1 = SRecord.new(event_id: "8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea") e2 = SRecord.new(event_id: "8cee1139-4f96-483a-a175-2b947283c3c7") diff --git a/ruby_event_store/spec/client_spec.rb b/ruby_event_store/spec/client_spec.rb index 5ce529ef9a..d9a4a88b8b 100644 --- a/ruby_event_store/spec/client_spec.rb +++ b/ruby_event_store/spec/client_spec.rb @@ -840,25 +840,6 @@ module RubyEventStore end end - specify "finds streams that are similar to searching criteria" do - event_1 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - event_2 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - event_3 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - stream_1 = Stream.new("stream-1") - stream_2 = Stream.new("stream-2") - stream_3 = Stream.new("stream-3") - - client.append(event_1, stream_name: stream_1.name) - client.append(event_2, stream_name: stream_2.name) - client.append(event_3, stream_name: stream_3.name) - - expect(client.search_streams("str")).to match_array [stream_3, stream_2, stream_1] - expect(client.search_streams("stream-1")).to match_array [stream_1] - expect(client.search_streams("stream-2")).to match_array [stream_2] - expect(client.search_streams("stream-3")).to match_array [stream_3] - expect(client.search_streams("stream-4")).to match_array [] - end - describe "#subscribers_for" do specify do handler = Subscribers::ValidHandler.new @@ -1001,21 +982,5 @@ def event_id expect(client.event_in_stream?(fact.event_id, GLOBAL_STREAM)).to eq(true) expect(client.event_in_stream?("924acfb8-755d-4fd5-b758-f92423b6560a", GLOBAL_STREAM)).to eq(false) end - - describe "#inspect_repository" do - specify "repository class name is returned unless inspect is overridden" do - expect(client.inspect_repository).to eq("RubyEventStore::InMemoryRepository") - end - - specify "repository custom inspection string returned if defined" do - class CustomRepository - def inspect - "CustomInspectionString" - end - end - client = Client.new(repository: CustomRepository.new) - expect(client.inspect_repository).to eq("CustomInspectionString") - end - end end end diff --git a/ruby_event_store/spec/instrumented_repository_spec.rb b/ruby_event_store/spec/instrumented_repository_spec.rb index 8096cf1995..3545d28b23 100644 --- a/ruby_event_store/spec/instrumented_repository_spec.rb +++ b/ruby_event_store/spec/instrumented_repository_spec.rb @@ -171,26 +171,6 @@ module RubyEventStore end end - describe "inspect" do - it "'Instrumented ' + repository class name is returned unless inspect is overridden" do - SomeRepository = Class.new - instrumented_repository = InstrumentedRepository.new(SomeRepository.new, ActiveSupport::Notifications) - expect(instrumented_repository.inspect).to eq("Instrumented RubyEventStore::SomeRepository") - end - - specify "'Instrumented ' + repository custom inspection string returned if defined" do - class CustomRepository - def inspect - "CustomInspectionString" - end - end - - instrumented_repository = InstrumentedRepository.new(CustomRepository.new, ActiveSupport::Notifications) - client = Client.new(repository: instrumented_repository) - expect(client.inspect_repository).to eq("Instrumented CustomInspectionString") - end - end - specify "method unknown by instrumentation but known by repository" do some_repository = double("Some repository", custom_method: 42) instrumented_repository = InstrumentedRepository.new(some_repository, ActiveSupport::Notifications) @@ -209,9 +189,9 @@ def inspect expect(instrumented_repository).not_to respond_to(:arbitrary_method_name) expect { instrumented_repository.arbitrary_method_name }.to raise_error( - NoMethodError, - /undefined method `arbitrary_method_name' for .+RubyEventStore::InstrumentedRepository/ - ) + NoMethodError, + /undefined method `arbitrary_method_name' for .+RubyEventStore::InstrumentedRepository/ + ) end def subscribe_to(name)