Skip to content

Commit

Permalink
initial framework for running cukes
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Mar 26, 2010
1 parent d42b55d commit ec0a935
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ end

namespace :generate do
desc "generate a fresh app with rspec installed"
task :app => ["rails:clone", :clobber_app] do |t|
ruby "./tmp/rails/railties/bin/rails tmp/example_app --dev -m example_app_template.rb"
task :app => ["rails:clone"] do |t|
unless File.directory?('./tmp/example_app')
ruby "./tmp/rails/railties/bin/rails tmp/example_app --dev -m example_app_template.rb"
end
end

desc "generate a bunch of stuff with generators"
Expand All @@ -76,7 +78,7 @@ namespace :generate do
end

desc "run a variety of specs against the generated app"
task :run_specs do
task :smoke do
Dir.chdir("./tmp/example_app/") do
sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
end
Expand All @@ -91,5 +93,5 @@ task :clobber_app do
rm_rf "tmp/example_app"
end

task :default => [:spec, "generate:app", "generate:stuff", :run_specs]
task :default => [:spec, :clobber_app, "generate:app", "generate:stuff", :smoke]

21 changes: 21 additions & 0 deletions features/matchers/new_record_matcher.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: new_record matcher

Scenario: new record of correct class
Given a file named "spec/models/widget_spec.rb" with:
"""
require "spec_helper"
describe Widget do
context "when initialized" do
it { should be_a_new(Widget) }
end
end
"""
When I run "rspec spec/models/widget_spec.rb"
Then I should see "1 example, 0 failures"

Scenario: existing record of correct class

Scenario: new record of wrong class
Scenario: existing record of wrong class

3 changes: 3 additions & 0 deletions features/step_definitions/model_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Given /a (\w+) model/ do |model_class_name|
puts eval(model_class_name)
end
37 changes: 37 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require "aruba"
require "rspec/expectations"

unless File.directory?('./tmp/example_app')
system "rake generate:app generate:stuff"
end

def aruba_path(file_or_dir)
File.expand_path("../../../#{file_or_dir.sub('example_app','aruba')}", __FILE__)
end

def example_app_path(file_or_dir)
File.expand_path("../../../#{file_or_dir}", __FILE__)
end

def write_symlink(file_or_dir)
source = example_app_path(file_or_dir)
target = aruba_path(file_or_dir)
system "ln -s #{source} #{target}"
end

Before do
steps %Q{
Given a directory named "spec"
}

Dir['tmp/example_app/*'].each do |file_or_dir|
unless file_or_dir =~ /spec$/
write_symlink(file_or_dir)
end
end

["spec/spec_helper.rb"].each do |file_or_dir|
write_symlink("tmp/example_app/#{file_or_dir}")
end

end

0 comments on commit ec0a935

Please sign in to comment.