This repository has been archived by the owner on Dec 23, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Goodsen
committed
Nov 23, 2008
1 parent
b21543f
commit 1426ac1
Showing
17 changed files
with
433 additions
and
0 deletions.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
Copyright (c) 2008 [name of plugin creator] | |||
|
|||
Permission is hereby granted, free of charge, to any person obtaining | |||
a copy of this software and associated documentation files (the | |||
"Software"), to deal in the Software without restriction, including | |||
without limitation the rights to use, copy, modify, merge, publish, | |||
distribute, sublicense, and/or sell copies of the Software, and to | |||
permit persons to whom the Software is furnished to do so, subject to | |||
the following conditions: | |||
|
|||
The above copyright notice and this permission notice shall be | |||
included in all copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
Rcumber | |||
============ | |||
This is a simple rails plugin that provides a web interface to view, edit and run Cucumber story tests in your rails project. | |||
I am designing it for use on our current projects with the idea that our customers can help us specify customer tests in Rcumber. | |||
|
|||
I just started it a few days ago, but it's already functional, so I'll put it up here on GitHub for the rest of the world to | |||
help me make it better. | |||
|
|||
Installation | |||
============ | |||
Grab it from git-hub, add it as a plugin. | |||
|
|||
Example | |||
======= | |||
Start your server and visit http://localhost:3000/rcumber. The UI should be self explanatory. | |||
|
|||
Release Notes: | |||
============= | |||
rcumber-0.1: Initial port into github | |||
|
|||
|
|||
Copyright (c) 2008 [John Goodsen, jgoodsen@radsoft.com], released under the MIT license |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
require 'rake' | |||
require 'rake/testtask' | |||
require 'rake/rdoctask' | |||
|
|||
desc 'Default: run unit tests.' | |||
task :default => :test | |||
|
|||
desc 'Test the rcumber_rails plugin.' | |||
Rake::TestTask.new(:test) do |t| | |||
t.libs << 'lib' | |||
t.pattern = 'test/**/*_test.rb' | |||
t.verbose = true | |||
end | |||
|
|||
desc 'Generate documentation for the rcumber_rails plugin.' | |||
Rake::RDocTask.new(:rdoc) do |rdoc| | |||
rdoc.rdoc_dir = 'rdoc' | |||
rdoc.title = 'RcumberRails' | |||
rdoc.options << '--line-numbers' << '--inline-source' | |||
rdoc.rdoc_files.include('README') | |||
rdoc.rdoc_files.include('lib/**/*.rb') | |||
end | |||
ENV['NODOT'] = 'true' # We don't want class diagrams in RDoc | |||
require 'config/requirements' | |||
require 'config/hoe' # setup Hoe + all gem configuration | |||
|
|||
Dir['gem_tasks/**/*.rake'].each { |rake| load rake } | |||
|
|||
# Hoe gives us :default => :test, but we don't have Test::Unit tests. | |||
Rake::Task[:default].clear_prerequisites | |||
task :default => [:spec, :features] |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
0.1 |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
Feature: Landing Page | |||
|
|||
As a customer, | |||
I want to see the rcumber landing page | |||
So I can begin to manage my customer test suite. | |||
|
|||
Scenario: Visit the rcumber landing page | |||
|
|||
Given a cucumber test landing_page exists | |||
When I visit the rcumber landing page | |||
Then I should see "Landing Page" | |||
|
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
require 'webrat' if !defined?(Webrat) # Because some people have it installed as a Gem | |||
|
|||
Given /a cucumber test (\w+) exists/ do |feature_name| | |||
path = File.expand_path(File.dirname(__FILE__) + "/#{feature_name}.feature") | |||
File.exist?(path).should be_true | |||
end | |||
|
|||
When /I visit the rcumber landing page/ do | |||
visits "/rcumbers" | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
controller_path = File.join(File.dirname(__FILE__), 'ui', 'controllers') | |||
helper_path = File.join(File.dirname(__FILE__), 'ui', 'helpers') | |||
$LOAD_PATH << controller_path | |||
$LOAD_PATH << helper_path | |||
|
|||
# Rails Edge | |||
if defined? ActiveSupport::Dependencies | |||
ActiveSupport::Dependencies.load_paths << controller_path | |||
ActiveSupport::Dependencies.load_paths << helper_path | |||
else | |||
Dependencies.load_paths << controller_path | |||
Dependencies.load_paths << helper_path | |||
end | |||
config.controller_paths << controller_path |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
# Install hook code here |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,80 @@ | |||
## | |||
## This class is designd to wrap around a particular implementation of a cucumber story test. | |||
## It provides a full API to | |||
## | |||
class Rcumber | |||
|
|||
## This class is used to hold the resulting log of a test run | |||
## and provides a basic API on the data: | |||
class RcumberResults < Array | |||
end | |||
|
|||
attr_accessor :path, :filename, :raw_content, :name, :preamble, :last_results | |||
|
|||
# For now, the UID is the basename w/o extension of the file: e.g. "../foo.feature" has uid =>"foo" | |||
# TODO: FIXME: This has the limitation that you need unique cucumber filenames down the entire directory tree... | |||
attr_reader :uid | |||
|
|||
PATH_PREFIX = RAILS_ROOT + "/features/" | |||
FEATURE_SUFFIX = ".feature" | |||
|
|||
def initialize(path) | |||
load_from_path(path) unless path.empty? | |||
end | |||
|
|||
def run | |||
self.last_results = RcumberResults.new(`rake features`.to_a) | |||
end | |||
|
|||
def self.all | |||
Dir.glob("#{PATH_PREFIX}**/*#{FEATURE_SUFFIX}").collect { |x| new(x) } | |||
end | |||
|
|||
def self.find(the_id) | |||
all.detect {|x| x.uid == the_id } | |||
end | |||
|
|||
|
|||
private | |||
|
|||
def load_from_path(path) | |||
@path = path | |||
@uid = File.basename(@path, FEATURE_SUFFIX) | |||
@raw_content = File.read(path) | |||
@preamble = [] | |||
|
|||
next_field = 'name' | |||
@raw_content.each do |line| | |||
|
|||
case next_field | |||
|
|||
when 'name' | |||
if @name = (line =~ /Feature: (.*)/ ? $1 : nil) | |||
next_field = 'preamble' | |||
break | |||
end | |||
|
|||
when 'preamble' | |||
if line =~ /Scenario:(.*)/ | |||
# next_field = 'scenarios' | |||
# break | |||
else | |||
puts "adding #{line}" | |||
@preamble << line | |||
end | |||
|
|||
else | |||
raise "unknown next_field #{next_field}" | |||
|
|||
|
|||
end | |||
|
|||
end | |||
end | |||
|
|||
def get_feature_name(content) | |||
content =~ /Feature: (.*)/ ? $1 : nil | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,83 @@ | |||
require File.dirname(__FILE__) + '/../../spec_helper' | |||
|
|||
describe Rcumber do | |||
|
|||
before(:each) do | |||
@all_rcumbers = Dir.glob("#{Rcumber::PATH_PREFIX}**/*.feature").collect{|x| Rcumber.new(x)} | |||
|
|||
|
|||
@content_feature =<<ENDL | |||
Feature: A User Story | |||
ENDL | |||
|
|||
@content_preamble =<<ENDL | |||
As a user, | |||
I want to xyz, | |||
So that I can abc | |||
ENDL | |||
|
|||
@content_scenario_one =<<ENDL | |||
Given something cool | |||
And something else | |||
When something happens | |||
And soemthing else happens | |||
Then this must be the case | |||
And this must also be the case | |||
ENDL | |||
|
|||
@file_content = [@content_feature.to_a, @content_preamble.to_a, @content_scenario_one.to_a].flatten | |||
end | |||
|
|||
describe "all" do | |||
it "should return all '.feature' files in the /features directory" do | |||
Rcumber.all.should_not be_empty | |||
end | |||
end | |||
|
|||
describe "after construction" do | |||
|
|||
before(:each) do | |||
@full_path = "#{Rcumber::PATH_PREFIX}folder/feature_x.feature" | |||
(@file_content.to_s =~ /Feature: (.*)/).should be_true | |||
File.should_receive(:read).with(@full_path).and_return(@file_content) | |||
@test = Rcumber.new(@full_path) | |||
end | |||
|
|||
it "should strip everything up to 'features' in the path" do | |||
@test.path.should == @full_path | |||
end | |||
|
|||
it "should have the content of the file" do | |||
@test.raw_content.should == @file_content | |||
end | |||
|
|||
it "should have parsed the name" do | |||
@test.name.should == "A User Story" | |||
end | |||
|
|||
it "should return the base filename without an extension as it's test_id" do | |||
@test.uid.should == "feature_x" | |||
end | |||
|
|||
# describe "preamble" do | |||
# it "should return the lines between 'Feature:' and the first Scenario:" do | |||
# @test.preamble.should == @content_preamble.to_a | |||
# end | |||
# end | |||
|
|||
describe "Rcumber.find" do | |||
it "should return an Rcumber object if it exists" do | |||
Rcumber.stub!(:all).and_return([@test]) | |||
Rcumber.all.should_receive(:detect).and_return(@test) | |||
Rcumber.find(@test.uid).uid.should == @test.uid | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |||
|
|||
describe RcumbersController do | |||
|
|||
describe 'index' do | |||
|
|||
it 'should render the index view' do | |||
get :index | |||
response.should render_template(:index) | |||
end | |||
|
|||
it 'build the list of cucumber tests' do | |||
tests = Dir.glob(RAILS_ROOT + '/features/**/*.feature') | |||
Rcumber.should_receive(:all).and_return(tests) | |||
get :index | |||
assigns[:rcumbers].should == tests | |||
end | |||
|
|||
end | |||
|
|||
describe 'show' do | |||
|
|||
before(:each) do | |||
@mock_test = mock Rcumber | |||
Rcumber.should_receive(:find).with("name").and_return(@mock_test) | |||
get :show, :id => "name" | |||
end | |||
|
|||
it "should render the show template" do | |||
response.should render_template(:show) | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
# desc "Explaining what the task does" | |||
# task :rcumber_rails do | |||
# # Task goes here | |||
# 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
|
|||
class RcumbersController < ApplicationController | |||
|
|||
def index | |||
@rcumbers = Rcumber.all | |||
end | |||
|
|||
def show | |||
@test = Rcumber.find(params[:id]) | |||
end | |||
|
|||
def run | |||
@test = Rcumber.find(params[:rcumber_id]) | |||
@test.run | |||
render :action => 'show' | |||
end | |||
|
|||
# don't want to include any filters inside the application chain - might create errors | |||
if respond_to? :filter_chain | |||
filters = filter_chain.collect do |f| | |||
if f.respond_to? :filter | |||
# rails 2.0 | |||
f.filter | |||
elsif f.respond_to? :method | |||
# rails 2.1 | |||
f.method | |||
else | |||
fail "Unknown filter class." | |||
end | |||
end | |||
skip_filter filters | |||
end | |||
|
|||
view_path = File.join(File.dirname(__FILE__), '..', 'views') | |||
if public_methods.include? 'append_view_path' # rails 2.1+ | |||
self.append_view_path view_path | |||
elsif public_methods.include? "view_paths" # rails 2.0+ | |||
self.view_paths << view_path | |||
else # rails <2.0 | |||
self.template_root = view_path | |||
end | |||
|
|||
|
|||
end |
Oops, something went wrong.