Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cucumber'ing rails integration

  • Loading branch information...
commit 3f07d009be203b755db73df068c971800f38aab1 1 parent a40ae01
@qrush qrush authored
View
15 Rakefile
@@ -7,4 +7,17 @@ Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/*_spec.rb']
end
-task :default => :spec
+begin
+ require 'cucumber/rake/task'
+
+ Cucumber::Rake::Task.new(:cucumber) do |t|
+ t.cucumber_opts = "--format pretty"
+ end
+rescue LoadError
+ desc 'Cucumber rake task not available'
+ task :features do
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ end
+end
+
+task :default => [:spec, :cucumber]
View
22 features/rack_integration.feature
@@ -0,0 +1,22 @@
+Feature: Integration into Rack Apps
+ As someone who loves syntactically awesome stylesheets
+ I want to be able to use sass when on (mostly) read only file systems
+ In order to make css less of a hassle
+
+ Scenario: Use hassle with Rails
+ Given I have a Rails app
+ And I have a file "public/stylesheets/sass/hassle.sass" with:
+ """
+ h1
+ :font-size 42em
+ """
+ When Hassle is installed as a plugin
+ And the app is initialized in production mode
+ Then I should see the following in "tmp/hassle/stylesheets/hassle.css":
+ """
+ h1 {
+ font-size: 42em; }
+ """
+
+ Scenario: Use hassle with Sinatra
+ Scenario: Use hassle with a pure Rack app
View
24 features/step_definitions/hassle_steps.rb
@@ -0,0 +1,24 @@
+Given /^I have a Rails app$/ do
+ `rails #{TEST_DIR}`
+end
+
+And /^I have a file "(.*)" with:$/ do |path, content|
+ FileUtils.mkdir_p(File.join(TEST_DIR, File.dirname(path)))
+ File.open(File.join(TEST_DIR, path), "w") do |f|
+ f.write content
+ end
+end
+
+Then /^I should see the following in "(.*)":$/ do |path, content|
+ content.strip.should == File.read(File.join(TEST_DIR, path)).strip
+end
+
+When /^Hassle is installed as a plugin$/ do
+ FileUtils.cp_r(ORIGINAL_DIR, File.join(TEST_DIR, "vendor", "plugins", "hassle"))
+end
+
+When /^the app is initialized in production mode$/ do
+ ENV["RAILS_ENV"] = "production"
+ require File.expand_path('./config/environment')
+end
+
View
15 features/support/env.rb
@@ -0,0 +1,15 @@
+require 'fileutils'
+
+ORIGINAL_DIR = Dir.pwd
+TEST_DIR = File.join('/', 'tmp', 'hassle')
+
+Before do
+ FileUtils.mkdir(TEST_DIR)
+ Dir.chdir(TEST_DIR)
+end
+
+After do
+ Dir.chdir(TEST_DIR)
+ FileUtils.rm_rf(TEST_DIR)
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.