forked from cucumber/cucumber-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial feature to check the files are generated in one case
- Loading branch information
Ashley Moran
committed
Feb 9, 2010
1 parent
3e67ca7
commit 661872d
Showing
8 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Manifest | ||
pkg | ||
doc | ||
doc | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: cucumber:skeleton | ||
In order to quickly set up Cucumber | ||
As a Rails developer | ||
I want to have the Cucumber skeleton generate automatically | ||
|
||
Scenario: Rails 2 with Capybara | ||
Given I'm using Ruby 1.8.7 and Rails 2.3.5 | ||
And a Rails app "rails-2-app" | ||
When I run "script/generate cucumber --capybara" in the app | ||
Then I will have the following new files and directories | ||
| name | | ||
| config/cucumber.yml | | ||
| config/environments/cucumber.rb | | ||
| script/cucumber | | ||
| features/step_definitions | | ||
| features/step_definitions/web_steps.rb | | ||
| features/support | | ||
| features/support/env.rb | | ||
| features/support/paths.rb | | ||
| lib/tasks | | ||
| lib/tasks/cucumber.rake | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# TODO ~/.bash_profile | ||
|
||
Given /^I'm using Ruby (.*) and Rails (.*)$/ do |ruby_version, rails_version| | ||
@commands = Commands.new(ruby_version, rails_version) | ||
end | ||
|
||
Given /^a Rails app "(.*)"$/ do |app_name| | ||
@rails_app = @commands.new_rails_app(app_name) | ||
end | ||
|
||
When /^I run "script\/(.*)" in the app$/ do |command| | ||
@rails_app.script(command) | ||
end | ||
|
||
Spec::Matchers.define :have_files do |expected_files| | ||
match do |rails_app| | ||
actual_files = rails_app.files | ||
@missing_files = expected_files - actual_files | ||
@missing_files.empty? | ||
end | ||
|
||
failure_message_for_should do |expected_files| | ||
"Rails app was missing these files:\n" + @missing_files.map { |file| " #{file}" }.join("\n") | ||
end | ||
end | ||
|
||
Then /^I will have the following new files and directories$/ do |table| | ||
expected_files = table.hashes.collect { |row| row[:name] } | ||
@rails_app.should have_files(expected_files) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Commands | ||
def initialize(ruby_version, rails_version) | ||
@ruby_version = ruby_version | ||
check_version("Ruby", @ruby_version, %w[ 1.8.7 1.9.1 ]) | ||
|
||
@rails_version = rails_version | ||
check_version("Rails", @rails_version, %w[ 2.3.5 ]) | ||
|
||
@runner = Runner.new("tmp", @ruby_version, @rails_version) | ||
end | ||
|
||
def new_rails_app(app_name) | ||
@runner.rails("#{app_name}") | ||
runner = Runner.new("tmp/#{app_name}", @ruby_version, @rails_version) | ||
RailsApp.new(app_name, @rails_version, runner) | ||
end | ||
|
||
private | ||
|
||
def check_version(command, version, allowed_versions) | ||
raise %Q{Invalid #{command} version "#{version}"} unless allowed_versions.include?(version) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Commands | ||
class RailsApp | ||
def initialize(app_name, rails_version, runner) | ||
@app_name = app_name | ||
@rails_version = rails_version | ||
@runner = runner | ||
end | ||
|
||
def script(options) | ||
@runner.rvm("script/#{options}") | ||
end | ||
|
||
def files | ||
@runner.files | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Commands | ||
class Runner | ||
attr_reader :command_history | ||
|
||
def initialize(directory, ruby_version, rails_version) | ||
@directory = directory | ||
@ruby_version = ruby_version | ||
@rails_version = rails_version | ||
@command_history = [] | ||
end | ||
|
||
def rails(options) | ||
rvm("rails _#{@rails_version}_ #{options}") | ||
end | ||
|
||
def rvm(command) | ||
run_and_log("rvm #{@ruby_version} -S #{command}") | ||
end | ||
|
||
def files | ||
in_runner_dir do | ||
Dir["**/*"] | ||
end | ||
end | ||
|
||
private | ||
|
||
def run_and_log(command) | ||
in_runner_dir do | ||
@command_history << command | ||
`#{command}` | ||
end | ||
end | ||
|
||
def in_runner_dir | ||
Dir.chdir(@directory) do | ||
yield | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'rubygems' | ||
|
||
gem 'rspec', '1.3.0' | ||
require 'spec' | ||
|
||
Before do | ||
Dir.mkdir("tmp") unless Dir.exist?("tmp") | ||
system "rm -rf tmp/*" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# TODO use this to set up the rvm environments | ||
# gem "bundler" | ||
gem "rails", "2.3.5" | ||
gem "cucumber-rails" | ||
gem "capybara" | ||
gem "webrat" |