Permalink
Browse files

cleaned up navigation and added new cucumber user story

  • Loading branch information...
1 parent 738a454 commit 5f0e12be27a41a871bf5ed3adac9bf9108be97ed John Goodsen committed Nov 25, 2008
@@ -1,12 +0,0 @@
-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"
-
View
@@ -2,6 +2,7 @@
## This class is designd to wrap around a particular implementation of a cucumber story test.
## It provides a full API to
##
+require 'pathname'
class Rcumber
attr_accessor :new_filename
@@ -21,10 +22,19 @@ class RcumberResults < Array
PATH_PREFIX = RAILS_ROOT + "/features/"
FEATURE_SUFFIX = ".feature"
- def initialize(path)
- load_from_path(path) unless path.empty?
+ def initialize(path=nil)
+ load_from_path(path) unless path.nil?
end
+ ## Use this to
+ def self.create_with_relative_path(path)
+ Rcumber.new("#{RAILS_ROOT}/features/#{path}.feature")
+ end
+
+ def to_s
+ uid
+ end
+
def run
self.last_results = RcumberResults.new(`cucumber #{@path}`.to_a)
end
@@ -62,7 +72,7 @@ def self.find(the_id)
def load_from_path(path)
@path = path
@uid = File.basename(@path, FEATURE_SUFFIX)
- @raw_content = File.read(path)
+ @raw_content = File.exist?(path) ? File.read(path) : ''
@preamble = []
next_field = 'name'
@@ -71,10 +71,36 @@
end
describe 'new' do
- it "should render a form asking for the filename (w/o) the .feature extension" do
+
+ it "GET request should render a form asking for the filename (w/o) the .feature extension" do
get :new
response.should render_template(:new)
end
+
+ it "POST request should create a new cucumber test" do
+ @mock_rcumber = mock Rcumber
+ Rcumber.should_receive(:new).and_return(@mock_rcumber)
+ @mock_rcumber.should_receive(:raw_content=).and_return(true)
+ @mock_rcumber.should_receive(:save).and_return(true)
+
+ post :new, :rcumber => {:path => 'foobar', :name => 'A feature name'}
+ response.should render_template(:show)
+ assigns[:rcumber].should == @mock_rcumber
+ end
+
+ it "POST request should check for blank path" do
+ post :new, :rcumber => {:path => '', :name => 'A feature name'}
+ response.should render_template(:new)
+ flash[:error].should_not be_nil
+
+ # rcumber = params[:rcumber]
+ # if rcumber[:path].empty?
+ # flash.now[:error] = "Must provide a path"
+ # render :action => 'new'
+ # else
+ end
+
+ it "POST request should check for blank name"
end
end
View
@@ -42,6 +42,7 @@
before(:each) do
@full_path = File.dirname(__FILE__) + '/../fixtures/feature_x.feature'
(@file_content.to_s =~ /Feature: (.*)/).should == 0
+ File.should_receive(:exist?).with(@full_path).and_return(true)
File.should_receive(:read).with(@full_path).and_return(@file_content)
@rcumber = Rcumber.new(@full_path)
end
@@ -37,6 +37,29 @@ def run
render :action => 'show'
end
+ def new
+ if request.post?
+ rcumber = params[:rcumber]
+ begin
+ raise "Must supply a base filename" if rcumber[:path].empty?
+ raise "Must supply a feature name" if rcumber[:name].empty?
+ raise "Path can only contain alphanumerics and underscores" unless (rcumber[:name] =~ /^[a-z_]+$/)
+ @rcumber = Rcumber.create_with_relative_path(params[:rcumber][:path])
+ raise "Are you sure you have Cucumber installed? We can't seem to find the directory #{File.dirname(@rcumber.path)}" unless File.exist?(File.dirname(@rcumber.path))
+ @rcumber.raw_content = "Feature: #{params[:rcumber][:name]}"
+ @rcumber.save
+ flash.now[:notice] = "Cucumber was pickled!"
+ redirect_to :controller => 'rcumbers', :action => 'edit', :id => @rcumber.uid
+ rescue Exception => e
+ @rcumber = Rcumber.new
+ flash.now[:error] = e.to_s
+ end
+ elsif request.get?
+ @rcumber = Rcumber.new
+ render :action => 'new'
+ end
+ end
+
def edit
get_rcumber
raise "Could not find cucumber file for #{params[:id]}" if @rcumber.nil?
@@ -23,7 +23,8 @@
</div>
<div id="bd">
<div class="yui-g">
- <!-- YOUR DATA GOES HERE -->
+ <%= rcumber_flashes %>
+
</div>
<div class="yui-g">
@@ -26,7 +26,7 @@ padding:0.5em;
}
ul.rcumber_content {
- min-height: 600px;
+ min-height: 300px;
background: #eee;
border: 1px solid #999;
width: 400px;
@@ -39,7 +39,7 @@ padding:0.5em;
margin-left: 4px;
}
ul#cucumber_tests {
- min-height: 600px;
+ min-height: 300px;
background: #eee;
border: 1px solid #999;
width: 400px;
@@ -67,6 +67,15 @@ fieldset#edit_rcumber {
width: 600px;
}
+fieldset#new_rcumber legend {
+ font-size: 1.5em;
+}
+fieldset#new_rcumber {
+ padding: 10px;
+ margin-top: 20px;
+ width: 300px;
+}
+
textarea {
background: #eee;
}
@@ -30,7 +30,7 @@ var myTabs = new YAHOO.widget.TabView("demo");
<div><p>
<fieldset id="edit_rcumber">
- <legend>Edit: <%= @rcumber.name %></legend>
+ <legend><%= image_tag('rcumber.gif') %> Edit: <%= @rcumber.name %></legend>
<% form_for @rcumber, :url => rcumber_path(@rcumber.uid) do |f| %>
<%= f.text_area :raw_content, :cols => 70 %>
@@ -1,11 +1,8 @@
<div id="cucumber_index">
<h1><img src="/images/rcumber.gif"/>Rcumber</h1>
-<h2>Rcumber - Rails plugin to manage Cucumber tests.</h1>
- <p>You are looking at the very first version of rcumber. <br/>
- Please give us feedback at github so we can turn many a mickle into a muckle.
- </p>
<h3>Here's all your Cukes!</h3>
+<%= link_to 'create a new cucumber', new_rcumber_path + demo_parameters %>
<ul id="cucumber_tests">
<% if @rcumbers.empty? %>
<p>You don't have any Cucumber tests in the ./feature directory of your project. <br/>
@@ -1,8 +1,12 @@
-<fieldset>
-<legend>New Cucumber</legend>
-<% form_for :rcumber, :method => 'put' do |f| %>
- <h2>Enter the base filename</h2>
- <%= f.text_field :new_filename %>
- <%= submit_tag 'Create' %>
-<% end %>
-</fieldset>
+<fieldset id="new_rcumber">
+ <legend><%= image_tag('rcumber.gif') %> Create a new Cucumber</legend>
+ <% form_for :rcumber, :method => :put do |f| %>
+ <%= content_tag :h3, 'Enter the base filename' %>
+ <%= content_tag :p, '(alphanumerics and underscores only please)'%>
+ <%= f.text_field :path %>
+ <%= content_tag :h3, 'Enter the Feature name:' %>
+ <%= f.text_field :name %>
+ <%= submit_tag 'Create' %>
+ <% end %>
+</fieldset>
+<%= link_to 'see all cucumbers', rcumbers_path %>
@@ -1,5 +1,3 @@
-<%= rcumber_flashes %>
-
<h1><%= @rcumber.name %></h1>
<script type="text/javascript">
@@ -21,7 +19,7 @@ var myTabs = new YAHOO.widget.TabView("demo");
<div class="yui-content">
<div><p>
- <%= link_to 'see all cucumbers', '/rcumber' %>
+ <%= link_to 'see all cucumbers', rcumbers_path %>
| <%= link_to 'run this cucumber', rcumber_run_path(@rcumber.uid) + demo_parameters %>
| <%= link_to 'edit this cucumber', edit_rcumber_path(@rcumber.uid) + demo_parameters %>
| <%= link_to 'create a new cucumber', new_rcumber_path + demo_parameters %>

0 comments on commit 5f0e12b

Please sign in to comment.