Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Given When Then steps
Co-authored-by: Bashir Towdiee <towdiee.bashir@gmail.com>
Co-authored-by: Brenton Annan <brentonannan@brentonannan.com>
Co-authored-by: Caitlin Palmer-Bright <caitlin.palmer-bright@tworedkites.com>
Co-authored-by: Cameo Langford <hello@cameocodes.com>
Co-authored-by: Dana Scheider <dana.scheider@gmail.com>
Co-authored-by: Eathan Langford <eathanlangford@gmail.com>
Co-authored-by: Emily Coats <ec@emilycoats.net>
Co-authored-by: Emma Park <emma.park@envato.com>
Co-authored-by: Erin Belot <erinbelot@gmail.com>
Co-authored-by: Geoffrey Donaldson <geoffreyd@gmail.com>
Co-authored-by: Isikyus <isikyus@users.noreply.github.com>
Co-authored-by: James Martelletti <james@martelletti.com.au>
Co-authored-by: Jess Brown <noiselessdwindle@gmail.com>
Co-authored-by: Jon Leighton <j@jonathanleighton.com>
Co-authored-by: Keith Pitty <keith@keithpitty.com>
Co-authored-by: Kirsten Comandich <kcomandich@gmail.com>
Co-authored-by: Laurence Dibah <laurencedibah@gmail.com>
Co-authored-by: Matt Patterson <matt.patterson94@gmail.com>
Co-authored-by: Michael Morris <mtcmorris@gmail.com>
Co-authored-by: Nadia Vu <winter.nga@gmail.com>
Co-authored-by: Nick Wolf <git@nickwolf.com.au>
Co-authored-by: Paul Douglas <pdouglas@ssi.org.au>
Co-authored-by: Rob Jacoby <robert.jacoby@cultureamp.com>
Co-authored-by: Selena Small <selenawiththetattoo@gmail.com>
Co-authored-by: Sonya Corcoran <sonyacorcoran@gmail.com>
Co-authored-by: Tim Lucas <t@toolmantim.com>
Co-authored-by: Chris Aitchison <cmaitchison@gmail.com>
  • Loading branch information
1 parent 74154c0 commit 479aa0d
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -58,6 +58,9 @@ group :test do
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
gem 'rspec-rails'

gem 'rspec-example_steps'
gem 'rspec-wait'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Expand Up @@ -142,8 +142,14 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
regexp_parser (1.3.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-example_steps (3.0.2)
rspec-core (>= 3.0.0)
rspec-expectations (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
Expand All @@ -159,6 +165,8 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sass (3.7.2)
Expand Down Expand Up @@ -222,7 +230,9 @@ DEPENDENCIES
pg
puma (~> 3.11)
rails (~> 5.2.1)
rspec-example_steps
rspec-rails
rspec-wait
sass-rails (~> 5.0)
selenium-webdriver
spring
Expand Down
27 changes: 27 additions & 0 deletions client/commit
@@ -0,0 +1,27 @@
Co-authored-by: Bashir Towdiee <towdiee.bashir@gmail.com>
Co-authored-by: Brenton Annan <brentonannan@brentonannan.com>
Co-authored-by: Caitlin Palmer-Bright <caitlin.palmer-bright@tworedkites.com>
Co-authored-by: Cameo Langford <hello@cameocodes.com>
Co-authored-by: Dana Scheider <dana.scheider@gmail.com>
Co-authored-by: Eathan Langford <eathanlangford@gmail.com>
Co-authored-by: Emily Coats <ec@emilycoats.net>
Co-authored-by: Emma Park <emma.park@envato.com>
Co-authored-by: Erin Belot <erinbelot@gmail.com>
Co-authored-by: Geoffrey Donaldson <geoffreyd@gmail.com>
Co-authored-by: Isikyus <isikyus@users.noreply.github.com>
Co-authored-by: James Martelletti <james@martelletti.com.au>
Co-authored-by: Jess Brown <noiselessdwindle@gmail.com>
Co-authored-by: Jon Leighton <j@jonathanleighton.com>
Co-authored-by: Keith Pitty <keith@keithpitty.com>
Co-authored-by: Kirsten Comandich <kcomandich@gmail.com>
Co-authored-by: Laurence Dibah <laurencedibah@gmail.com>
Co-authored-by: Matt Patterson <matt.patterson94@gmail.com>
Co-authored-by: Michael Morris <mtcmorris@gmail.com>
Co-authored-by: Nadia Vu <winter.nga@gmail.com>
Co-authored-by: Nick Wolf <git@nickwolf.com.au>
Co-authored-by: Paul Douglas <pdouglas@ssi.org.au>
Co-authored-by: Rob Jacoby <robert.jacoby@cultureamp.com>
Co-authored-by: Selena Small <selenawiththetattoo@gmail.com>
Co-authored-by: Sonya Corcoran <sonyacorcoran@gmail.com>
Co-authored-by: Tim Lucas <t@toolmantim.com>
Co-authored-by: Chris Aitchison <cmaitchison@gmail.com>
36 changes: 20 additions & 16 deletions spec/features/games_spec.rb
@@ -1,23 +1,27 @@
require 'rails_helper'

RSpec.feature "Games", type: :feature, js: true do
scenario 'Visiting the game' do
visit '/'
expect(page).to have_content 'Welcome to the Game'
scenario 'Playing the game' do
When 'a user starts the game' do
visit '/'
expect(page).to have_content 'Welcome to the Game'
page.find('[data-start-button]').click
end

page.find('[data-start-button]').click
expect(page).to have_content 'This is round 1'
expect(page).to have_selector('img')
expect(page).to have_selector('textarea')
page.find("textarea").fill_in(with: "Michael")
expect(page).to_not have_content "CORRECT"
expect(page).to_not have_content "NEXT"
page.find("textarea").fill_in(with: "Matt")
expect(page).to have_content "CORRECT"
expect(page).to have_content('NEXT')
page.find("[data-test-next]").click
expect(page).to have_content 'This is round 2'
expect(page.find("textarea").value).to eq ""
Then 'the game commences' do
expect(page).to have_content 'This is round 1'
expect(page).to have_selector('img')
expect(page).to have_selector('textarea')
page.find("textarea").fill_in(with: "Michael")
expect(page).to_not have_content "CORRECT"
expect(page).to_not have_content "NEXT"
page.find("textarea").fill_in(with: "Matt")
expect(page).to have_content "CORRECT"
expect(page).to have_content('NEXT')
page.find("[data-test-next]").click
expect(page).to have_content 'This is round 2'
expect(page.find("textarea").value).to eq ""
end
end

context 'Guess name given data for Keith' do
Expand Down
7 changes: 7 additions & 0 deletions spec/rails_helper.rb
Expand Up @@ -7,6 +7,10 @@
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

Dir['spec/support/**/*.rb'].each do |file|
require Rails.root.join(file).to_s
end

# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
Expand Down Expand Up @@ -62,4 +66,7 @@
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")

# include PageFragments in features
config.include PageFragments, type: :feature
end
23 changes: 23 additions & 0 deletions spec/support/features/page_fragments.rb
@@ -0,0 +1,23 @@
module PageFragments
Page = Struct.new :rspec_example do
alias_method :browser, :rspec_example # Capybara DSL + rspec example context
end

def classify(string)
string.to_s.split('_').map(&:capitalize).join
end

def focus_on(*args)
require File.join(
__dir__,
'page_fragments',
args.map(&:to_s)
)
mod = args.inject(PageFragments) do |klass, sub_klass|
klass.const_get(classify(sub_klass))
end
page = Page.new(self).extend(mod)
yield page if block_given?
page
end
end
7 changes: 7 additions & 0 deletions spec/support/features/page_fragments/welcome.rb
@@ -0,0 +1,7 @@
module PageFragments
module Welcome
def start_game
browser.find('[data-start-button]').click
end
end
end

0 comments on commit 479aa0d

Please sign in to comment.