Skip to content

Commit

Permalink
Remove whitespaces and replace double quotes with single quotes were …
Browse files Browse the repository at this point in the history
…possible
  • Loading branch information
cavalle committed Apr 24, 2011
1 parent a37eee1 commit 2ca42a7
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 65 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ The delicious combination of RSpec and Capybara for Acceptance BDD

Steak is a minimal extension of RSpec-Rails that adds several conveniences to do acceptance testing of Rails applications using Capybara. It's an alternative to Cucumber in plain Ruby. This is how and acceptance spec looks like in Steak:

feature "Main page" do
feature 'Main page' do

background do
create_user :login => "jdoe"
create_user :login => 'jdoe'
end

scenario "should show existing quotes" do
create_quote :text => "The language of friendship is not words, but meanings",
:author => "Henry David Thoreau"
scenario 'should show existing quotes' do
create_quote :text => 'The language of friendship is not words, but meanings',
:author => 'Henry David Thoreau'

login_as "jdoe"
visit "/"
login_as 'jdoe'
visit '/'

within(".quote") do
page.should have_content("The language of friendship is not words, but meanings")
page.should have_content("Henry David Thoreau")
within('.quote') do
page.should have_content('The language of friendship is not words, but meanings')
page.should have_content('Henry David Thoreau')
end
end
Expand Down Expand Up @@ -104,4 +104,3 @@ Steak was created by [Luismi Cavallé](http://lmcavalle.com) and improved thanks
* Joao Carlos

Copyright © 2009 - 2011 Luismi Cavallé, released under the MIT license

4 changes: 2 additions & 2 deletions lib/generators/steak/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module Steak
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.join(File.dirname(__FILE__), 'templates')

def main
generate 'rspec:install'
directory 'spec/acceptance/support'
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/generators/steak/spec_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def main
end
end
end
end
end
6 changes: 3 additions & 3 deletions lib/generators/steak/templates/acceptance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
As a ...
I want ...
} do

scenario 'first scenario' do
true.should == true
end
end

end
4 changes: 2 additions & 2 deletions lib/steak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Steak
class Railtie < ::Rails::Railtie
rake_tasks do
load "tasks/steak_tasks.rake"
load 'tasks/steak_tasks.rake'
end
end
end
end
2 changes: 1 addition & 1 deletion lib/steak/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Steak
VERSION = "2.0.0.a0"
VERSION = '2.0.0.a0'
end
6 changes: 3 additions & 3 deletions lib/tasks/steak_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace :spec do
desc "Run the acceptance specs in spec/acceptance"
RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t|
t.pattern = "spec/acceptance/**/*_spec.rb"
desc 'Run the acceptance specs in spec/acceptance'
RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t|
t.pattern = 'spec/acceptance/**/*_spec.rb'
end
end
16 changes: 8 additions & 8 deletions spec/acceptance/creating_specs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
As a lazy Rails developer
I want empty new specs to be generated for me
} do

scenario 'using the spec generator' do
new_project_from :rails_project_with_steak

run 'rails g steak:spec my_first_feature'

path('spec/acceptance/my_first_feature_spec.rb').should exist
content_of('spec/acceptance/my_first_feature_spec.rb').should include("feature 'My first feature'")

run 'rspec spec/acceptance/my_first_feature_spec.rb'

output.should =~ /1 example, 0 failures/
end

scenario 'under a subdirectory' do
new_project_from :rails_project_with_steak

Expand All @@ -30,5 +30,5 @@

output.should =~ /1 example, 0 failures/
end
end

end
12 changes: 6 additions & 6 deletions spec/acceptance/getting_started_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
As a Rails developer
I want set up my project for Acceptance BDD
} do

scenario 'from an empty Rails project' do
new_project_from :rails_project

append_to 'Gemfile', <<-GEMS
group :test, :development do
gem 'steak', :path => '#{root_path}'
gem 'capybara', :path => '#{Bundler.load.specs['capybara'].first.full_gem_path}' # Totally temporal. It should be a steak dependency
end
GEMS

run 'bundle --local'
run 'rails g steak:install'

# rspec-rails should be present
path('spec').should exist
path('spec/spec_helper.rb').should exist

# steak should be present
path('spec/acceptance').should exist
path('spec/acceptance/support').should exist
end

end
end
12 changes: 6 additions & 6 deletions spec/acceptance/rake_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
As a Rails developer
I want rake support in Steak
} do

background do
new_project_from :rails_project_with_steak
create_file 'spec/unit_spec.rb', <<-RSPEC
require 'spec_helper'
describe Object do
it { should respond_to :to_s }
end
RSPEC
run 'rails g steak:spec my_spec'
run 'rake db:migrate'
end

scenario 'to run acceptance specs as part of the test suite' do
run 'rake spec'
output.should =~ /2 examples, 0 failures/

run 'rake'
output.should =~ /2 examples, 0 failures/
end
Expand All @@ -31,5 +31,5 @@
run 'rake spec:acceptance'
output.should =~ /1 example, 0 failures/
end
end

end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
require 'rails'
require 'steak'

require 'support/helpers'
require 'support/helpers'
30 changes: 15 additions & 15 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'tempfile'

module Helpers

def new_project_from(fixture_name)
rm_rf rails_project_path
cp_r fixture_path(fixture_name), rails_project_path
Expand All @@ -11,53 +11,53 @@ def new_project_from(fixture_name)
def append_to(path, content)
rails_project_path.join(path).open('a') { |f| f.write content }
end

def create_file(path, content)
rails_project_path.join(path).open('w') { |f| f.write content }
end

attr_accessor :output

def run(command)
self.output = Bundler.with_clean_env { `#{command} 2>&1` }

log "$ #{command}"
log self.output
raise "`#{command}` failed with:\n#{output}" unless $?.success?
end

def path(path)
rails_project_path.join(path)
end

def content_of(path)
File.read path(path)
end

def cd(*args)
silence_warnings { Dir.chdir(*args) }
end

def rm_rf(*args)
FileUtils.rm_rf *args
end

def cp_r(*args)
FileUtils.cp_r *args
end

def root_path
Bundler.root
end

def rails_project_path
Pathname.new(Dir.tmpdir).join('rails_project')
end
def fixture_path(name = ".")

def fixture_path(name = '.')
root_path.join('spec', 'fixtures', name.to_s)
end

def log(text)
puts text if ENV['TRACE']
end
Expand Down
12 changes: 6 additions & 6 deletions spec/support/refresh_fixtures_task.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
desc "Regenerates the fixture projects in spec/fixtures"
desc 'Regenerates the fixture projects in spec/fixtures'
task :refresh_fixtures do
Bundler.setup
require 'rails'
require File.dirname(__FILE__) + '/helpers'
include Helpers

rm_rf fixture_path(:rails_project)
rm_rf fixture_path(:rails_project_with_steak)
rm_rf rails_project_path
Expand All @@ -15,16 +15,16 @@
cd rails_project_path

append_to 'Gemfile', <<-RUBY
group :test, :development do
group :test, :development do
gem 'steak', :path => '#{root_path}'
gem 'capybara', :path => '#{Bundler.load.specs['capybara'].first.full_gem_path}' # Totally temporal. It should be a steak dependency
end
RUBY

run 'bundle --local'
run 'rails g steak:install'

cp_r rails_project_path, fixture_path(:rails_project_with_steak)

cd root_path
end
end

0 comments on commit 2ca42a7

Please sign in to comment.