Skip to content

Commit

Permalink
add test for first query
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlindsey committed Nov 17, 2020
1 parent 6ff2233 commit 1400793
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/graphql/queries/show_event_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'Events' do

it "queries and returns all events" do
e = create(:event, name: 'FirstEvent')
e2 = create(:event, name: 'AnotherEvent')

query_string = <<-GRAPHQL
query
{
events {
id
duration
name
}
}
GRAPHQL

result = WebsiteOneBackendApiSchema.execute(query_string)["data"]["events"]

names = result.collect {|x| x["name"]}

assert names.detect { |e| e == 'FirstEvent' }
assert names.detect { |e| e == 'AnotherEvent' }
end
end

0 comments on commit 1400793

Please sign in to comment.