Permalink
Browse files

Add missing tests

  • Loading branch information...
1 parent 1575550 commit 8e3153acd625276d979febbad542f3db54052f45 @josepjaume josepjaume committed Oct 10, 2011
Showing with 87 additions and 0 deletions.
  1. +6 −0 Rakefile
  2. +11 −0 features/rails3/rails_3_1_app.feature
  3. +68 −0 features/steps/rails3/rails_3_1_app.rb
  4. +1 −0 features/support/env.rb
  5. +1 −0 spinach-rails.gemspec
View
@@ -1,2 +1,8 @@
#!/usr/bin/env rake
require 'bundler/gem_tasks'
+
+task :spinach do
+ exec "bundle exec spinach"
+end
+
+task :default => [:spinach]
@@ -0,0 +1,11 @@
+Feature: Spinach works with a Rails 3.1 app
+ In order to use spinach with Rails 3.1
+ As a developer
+ I want spinach to be fully compatible with Rails 3.1
+
+ Scenario: Boot a bare Rails 3.1 app
+ Given I create a new rails 3 app
+ And I add spinach-rails to it
+ And I add some test features
+ When I run spinach
+ Then the features should pass
@@ -0,0 +1,68 @@
+require 'aruba/api'
+
+Feature 'Spinach works with a Rails 3.1 app' do
+
+ include Aruba::Api
+
+ Given "I create a new rails 3 app" do
+ create_rails_app('3.1')
+ end
+ And "I add spinach-rails to it" do
+ add_spinach_rails
+ end
+ And "I add some test features" do
+ add_test_features
+ end
+ When "I run spinach" do
+ run "spinach"
+ end
+ Then "the features should pass" do
+ stop_processes!
+ last_exit_status.must_equal 0
+ end
+
+ private
+
+ def create_rails_app(version = '3.1')
+ write_file(
+ 'Gemfile',
+ " source :rubygems
+ gem 'rails', '#{version}'
+ ")
+ run "bundle install"
+ run "rm -fR rails_app"
+ stop_processes!
+ run 'bundle exec rails new rails_app'
+ stop_processes!
+ cd "rails_app"
+ end
+
+ def add_spinach_rails
+ append_to_file("Gemfile",
+ "gem 'spinach-rails', group: :test, path: '#{Dir.pwd}'")
+ run "bundle install"
+ end
+
+ def add_test_features
+ write_file('features/test_feature.feature',
+ "Feature: Test feature
+ Scenario: Test scenario
+ Given I am running spinach
+ Then It should be all OK
+ ")
+ write_file('features/steps/test_feature.rb',
+ "Feature 'Test feature' do
+ Given 'I am running spinach' do
+ visit '/'
+ end
+ Then 'It should be all OK' do
+ page.has_content?('Rails').must_equal true
+ end
+ end
+ ")
+ write_file('features/support/env.rb',
+ "require 'minitest/spec'
+ require_relative '../../config/application'")
+ end
+
+end
View
@@ -0,0 +1 @@
+require 'minitest/spec'
View
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'capybara'
gem.add_runtime_dependency 'spinach', '~> 0.1'
gem.add_runtime_dependency 'rails', '>= 3'
+ gem.add_development_dependency 'aruba'
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")

0 comments on commit 8e3153a

Please sign in to comment.