Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use and generate 1.9 hash syntax #371

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ with a Step Definition that perhaps looks like this:

Given /^I have signed up as "([^"]*)"$/ do |email|
visit(signup_path)
fill_in('Email', :with => email)
fill_in('Password', :with => 's3cr3t')
fill_in('Password Confirmation', :with => 's3cr3t')
fill_in('Email', with: email)
fill_in('Password', with: 's3cr3t')
fill_in('Password Confirmation', with: 's3cr3t')
click_button('Sign up')
end

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Cucumber-Rails brings Cucumber to Rails 4.x and 5.x. For Rails 3.x support, use
Before you can use the generator, add the gem to your project's Gemfile as follows:

group :test do
gem 'cucumber-rails', :require => false
gem 'cucumber-rails', require: false
# database_cleaner is not required, but highly recommended
gem 'database_cleaner'
end
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Dir["#{File.dirname(__FILE__)}/dev_tasks/*.rake"].sort.each { |ext| load ext }

CLEAN.include('doc', 'tmp')

task :default => :test
task default: :test

task :test => [:spec, :cucumber]
task test: [:spec, :cucumber]

namespace :test do
desc "Run tests against all gemfiles"
Expand Down Expand Up @@ -45,5 +45,5 @@ namespace :gemfiles do
end

desc "Rebuild generated gemfiles and install dependencies"
task :rebuild => [:clean, :install]
task rebuild: [:clean, :install]
end
4 changes: 2 additions & 2 deletions dev_tasks/yard.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace :api do
mkdir_p dir
yard.options = ["--out", dir]
end
task :yard => :dir
task yard: :dir

task :release do
Dir.chdir(SITE_DIR) do
Expand All @@ -31,5 +31,5 @@ namespace :api do
end

desc "Generate YARD docs for Cucumber-Rails' API"
task :doc => [:yard, :release]
task doc: [:yard, :release]
end
8 changes: 4 additions & 4 deletions features/capybara_javascript_drivers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Feature: Capybara Javascript Drivers
And I write to "features/step_definitions/date_time_steps.rb" with:
"""
When /^(?:|I )select "([^"]+)" as the "([^"]+)" time$/ do |time, selector|
select_time(time, :from => selector)
select_time(time, from: selector)
end

When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
select_date(date, :from => selector)
select_date(date, from: selector)
end

When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
select_datetime(datetime, :from => selector)
select_datetime(datetime, from: selector)
end
"""

Expand Down Expand Up @@ -56,7 +56,7 @@ Feature: Capybara Javascript Drivers
And I write to "features/step_definitions/custom_steps.rb" with:
"""
Given /^a random appointment$/ do
@appointment = Appointment.create!(:name => 'Random appointment', :when => DateTime.now)
@appointment = Appointment.create!(name: 'Random appointment', when: DateTime.now)
end

Given /^I am viewing random appointment$/ do
Expand Down
4 changes: 2 additions & 2 deletions features/database_cleaner.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Feature: DatabaseCleaner
"""
Given /^I have (\d+) widgets$/ do |n|
n.to_i.times do |i|
Widget.create! :name => "Widget #{Widget.count + i}"
Widget.create! name: "Widget #{Widget.count + i}"
end
end

When /^I create (\d+) more widgets$/ do |n|
n.to_i.times do |i|
Widget.create! :name => "Widget #{Widget.count + i}"
Widget.create! name: "Widget #{Widget.count + i}"
end
end

Expand Down
4 changes: 2 additions & 2 deletions features/disable_automatic_database_cleaning.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Feature: Disable automatic database cleaning
"""
Given /^I have (\d+) widgets$/ do |n|
n.to_i.times do |i|
Widget.create! :name => "Widget #{Widget.count + i}"
Widget.create! name: "Widget #{Widget.count + i}"
end
end

When /^I create (\d+) widgets$/ do |n|
n.to_i.times do |i|
Widget.create! :name => "Widget #{Widget.count + i}"
Widget.create! name: "Widget #{Widget.count + i}"
end
end

Expand Down
8 changes: 4 additions & 4 deletions features/emulate_javascript.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Emulate Javascript
And I write to "features/step_definitions/s.rb" with:
"""
Given /^there is a widget named "([^"]*)"$/ do |name|
FactoryGirl.create(:widget, :name => name)
FactoryGirl.create(:widget, name: name)
end
"""
And I write to "features/support/factories.rb" with:
Expand Down Expand Up @@ -52,8 +52,8 @@ Feature: Emulate Javascript
"""
class ApplicationController < ActionController::Base
protect_from_forgery
before_action :except => :establish do
render :text => "denied", :status => :forbidden and return false unless session[:verified]
before_action except: :establish do
render text: "denied", status: :forbidden and return false unless session[:verified]
end
end
"""
Expand All @@ -73,7 +73,7 @@ Feature: Emulate Javascript
And I write to "features/step_definitions/s.rb" with:
"""
Given /^there is a widget named "([^"]*)"$/ do |name|
FactoryGirl.create(:widget, :name => name)
FactoryGirl.create(:widget, name: name)
end
"""
And I write to "features/support/factories.rb" with:
Expand Down
6 changes: 3 additions & 3 deletions features/no_database.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Feature: No Database
"""
source 'http://rubygems.org'
gem 'rails'
gem "cucumber-rails", :group => :test, :path => "../../.."
gem "capybara", :group => :test
gem "rspec-rails", :group => :test
gem "cucumber-rails", group: :test, path: "../../.."
gem "capybara", group: :test
gem "rspec-rails", group: :test
if RUBY_VERSION >= '2.0.0'
gem 'sass-rails'
gem 'uglifier'
Expand Down
2 changes: 1 addition & 1 deletion features/rest_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: REST API
"""
class PostsController < ApplicationController
def index
render :json => {'hello' => 'world'}.to_json
render json: {'hello' => 'world'}.to_json
end
end
"""
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/cucumber_rails_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def fixture(path)
browser_options = ::Selenium::WebDriver::Firefox::Options.new()
browser_options.args << '--headless'

Capybara::Selenium::Driver.new(app, :browser => :firefox, options: browser_options)
Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
end
}

Expand Down
14 changes: 7 additions & 7 deletions features/support/legacy_web_steps_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def with_scope(locator)
end

When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
fill_in(field, with: value)
end

When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
fill_in(field, :with => value)
fill_in(field, with: value)
end

# Use this to fill in an entire form with data from a table. Example:
Expand All @@ -78,7 +78,7 @@ def with_scope(locator)
end

When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
select(value, :from => field)
select(value, from: field)
end

When /^(?:|I )check "([^"]*)"$/ do |field|
Expand Down Expand Up @@ -109,9 +109,9 @@ def with_scope(locator)
regexp = Regexp.new(regexp)

if page.respond_to? :should
page.should have_xpath('//*', :text => regexp)
page.should have_xpath('//*', text: regexp)
else
assert page.has_xpath?('//*', :text => regexp)
assert page.has_xpath?('//*', text: regexp)
end
end

Expand All @@ -127,9 +127,9 @@ def with_scope(locator)
regexp = Regexp.new(regexp)

if page.respond_to? :should
page.should have_no_xpath('//*', :text => regexp)
page.should have_no_xpath('//*', text: regexp)
else
assert page.has_no_xpath?('//*', :text => regexp)
assert page.has_no_xpath?('//*', text: regexp)
end
end

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ gem "uglifier", "~> 2.7.2"
gem "sqlite3", "~> 1.3.7"
gem "database_cleaner", ">= 1.1.0"

gemspec :path => "../"
gemspec path: "../"
4 changes: 2 additions & 2 deletions lib/cucumber/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
MultiTest.disable_autorun
else
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred until env.rb is called.
To avoid this warning, move 'gem \'cucumber-rails\', :require => false' under only group :test in your Gemfile.
If already in the :test group, be sure you are specifying ':require => false'."
To avoid this warning, move 'gem \'cucumber-rails\', require: false' under only group :test in your Gemfile.
If already in the :test group, be sure you are specifying 'require: false'."
end
6 changes: 3 additions & 3 deletions lib/cucumber/rails/capybara/select_dates_and_times.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Rails
module Capybara
# This module defines methods for selecting dates and times
module SelectDatesAndTimes
# Select a Rails date. Options hash must include :from => +label+
# Select a Rails date. Options hash must include from: +label+
def select_date(date, options)
date = Date.parse(date)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])
Expand All @@ -13,7 +13,7 @@ def select_date(date, options)
find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
end

# Select a Rails time. Options hash must include :from => +label+
# Select a Rails time. Options hash must include from: +label+
def select_time(time, options)
time = Time.zone.parse(time)
base_dom_id = get_base_dom_id_from_label_tag(options[:from])
Expand All @@ -22,7 +22,7 @@ def select_time(time, options)
find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
end

# Select a Rails datetime. Options hash must include :from => +label+
# Select a Rails datetime. Options hash must include from: +label+
def select_datetime(datetime, options)
select_date(datetime, options)
select_time(datetime, options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { :except => [:widgets] } may not do what you expect here
# # { except: [:widgets] } may not do what you expect here
# # as Cucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ begin
require 'cucumber/rake/task'

namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
Cucumber::Rake::Task.new({ok: '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 => 'test:prepare'}, 'Run features that are being worked on') do |t|
Cucumber::Rake::Task.new({wip: '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 => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
Cucumber::Rake::Task.new({rerun: '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]
task all: [:ok, :wip]

task :statsetup do
require 'rails/code_statistics'
Expand All @@ -46,21 +46,21 @@ begin
end
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
task cucumber: 'cucumber:ok'

task :default => :cucumber
task default: :cucumber

task :features => :cucumber do
task features: :cucumber do
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
end

# In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
task 'test:prepare' do
end

task :stats => 'cucumber:statsetup'
task stats: 'cucumber:statsetup'

task :notes => 'cucumber:annotations_setup'
task notes: 'cucumber:annotations_setup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
Expand Down
2 changes: 1 addition & 1 deletion spec/generators/cucumber/install/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
subject { file('lib/tasks/cucumber.rake') }
it { is_expected.to exist }
it { is_expected.to contain '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.' }
it { is_expected.to contain "task :cucumber => 'cucumber:ok'" }
it { is_expected.to contain "task cucumber: 'cucumber:ok'" }
end

describe 'script/cucumber' do
Expand Down