Skip to content
Browse files

Hello world cucumber test experiment (need to consider whether coupli…

…ng to the implementation of board.to_s is a good idea, though its kinda convenient for now)
  • Loading branch information...
1 parent 7441e0b commit 4b1fbf9c0636d341281945677ef666e36f72c964 @deanius committed
View
17 config/database.yml
@@ -2,21 +2,12 @@ development:
adapter: sqlite3
database: db/development.sqlite3
- # adapter: mysql
- # host: localhost
- # database: chessonrails_development
- # username: chessonrails
- # assword: ch3550nrails
-
test:
- # use either sqllite section or mysql
- # database: ":memory:" once worked (sigh..)
+ # database: ":memory:" may work ?
database: db/test.sqlite3
adapter: sqlite3
verbosity: quiet
- # adapter: mysql
- # host: localhost
- # database: chessonrails_test
- # username: chessonrails
- # password: ch3550nrails
+cucumber:
+ database: db/cucumber.sqlite3
+ adapter: sqlite3
View
0 config/environments/cucumber.rb
No changes.
View
1 db/schema.rb
@@ -47,7 +47,6 @@
create_table "moves", :force => true do |t|
t.integer "match_id"
- t.integer "player_id"
t.string "from_coord", :limit => 10
t.string "to_coord", :limit => 10
t.string "notation", :limit => 10
View
20 features/pawn_movement.feature
@@ -0,0 +1,20 @@
+Feature: Pawn movement
+ In order to comply with the rules of chess
+ As a pawn
+ I want to move correctly
+
+ Scenario: The opening move
+ Given a new chess board
+ When I move from d2 to d4
+ Then the board should look like
+"""
+r n b q k b n r
+p p p p p p p p
+
+
+ P
+
+P P P P P P P
+R N B Q K B N R
+"""
+
View
17 features/step_definitions/board_steps.rb
@@ -0,0 +1,17 @@
+Given /a new chess board/ do
+ @board = Chess.new_board
+end
+
+Given /a board like the following/ do |board|
+ pending
+end
+
+When /^I move from ([a-h]\d) to ([a-h]\d)$/ do |from_coord, to_coord|
+ @board.play_move! Move.new(:from_coord => from_coord, :to_coord => to_coord)
+end
+
+Then /^the board should look like$/ do |board|
+# @board.to_s.gsub(/\n\s+(?=\n)/, "\n").should == board
+# @board.to_s.gsub(/\n\ +(?=\n)/, "\n").should == board
+ @board.to_s.sub(/\n+$/,"").should == board
+end
View
56 features/support/env.rb
@@ -0,0 +1,56 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+ENV["RAILS_ENV"] ||= "cucumber"
+require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
+
+require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
+require 'cucumber/rails/world'
+require 'cucumber/rails/active_record'
+# require 'cucumber/web/tableish'
+
+#require 'webrat'
+#require 'webrat/core/matchers'
+
+#Webrat.configure do |config|
+# config.mode = :rails
+# config.open_error_files = false # Set to true if you want error pages to pop up in the browser
+#end
+
+
+# If you set this to false, any error raised from within your app will bubble
+# up to your step definition and out to cucumber unless you catch it somewhere
+# on the way. You can make Rails rescue errors and render error pages on a
+# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
+#
+# If you set this to true, Rails will rescue all errors and render error
+# pages, more or less in the same way your application would behave in the
+# default production environment. It's not recommended to do this for all
+# of your scenarios, as this makes it hard to discover errors in your application.
+ActionController::Base.allow_rescue = false
+
+# If you set this to true, each scenario will run in a database transaction.
+# You can still turn off transactions on a per-scenario basis, simply tagging
+# a feature or scenario with the @no-txn tag. If you are using Capybara,
+# tagging with @culerity or @javascript will also turn transactions off.
+#
+# If you set this to false, transactions will be off for all scenarios,
+# regardless of whether you use @no-txn or not.
+#
+# Beware that turning transactions off will leave data in your database
+# after each scenario, which can lead to hard-to-debug failures in
+# subsequent scenarios. If you do this, we recommend you create a Before
+# block that will explicitly put your database in a known state.
+Cucumber::Rails::World.use_transactional_fixtures = true
+# How to clean your database when transactions are turned off. See
+# http://github.com/bmabey/database_cleaner for more info.
+if defined?(ActiveRecord::Base)
+ begin
+ require 'database_cleaner'
+ DatabaseCleaner.strategy = :truncation
+ rescue LoadError => ignore_if_database_cleaner_not_present
+ end
+end
View
53 lib/tasks/cucumber.rake
@@ -0,0 +1,53 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+
+unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
+
+vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
+
+begin
+ require 'cucumber/rake/task'
+
+ namespace :cucumber do
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'default'
+ end
+
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'wip'
+ end
+
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'rerun'
+ end
+
+ desc 'Run all features'
+ task :all => [:ok, :wip]
+ end
+ desc 'Alias for cucumber:ok'
+ task :cucumber => 'cucumber:ok'
+
+ task :default => :cucumber
+
+ task :features => :cucumber do
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
+ end
+rescue LoadError
+ desc 'cucumber rake task not available (cucumber not installed)'
+ task :cucumber do
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ end
+end
+
+end
View
10 script/cucumber
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+if vendored_cucumber_bin
+ load File.expand_path(vendored_cucumber_bin)
+else
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
+ require 'cucumber'
+ load Cucumber::BINARY
+end

0 comments on commit 4b1fbf9

Please sign in to comment.
Something went wrong with that request. Please try again.