diff --git a/rails/map-mash/Gemfile b/rails/map-mash/Gemfile
index 96b8951..3bc9116 100644
--- a/rails/map-mash/Gemfile
+++ b/rails/map-mash/Gemfile
@@ -4,6 +4,7 @@ gem 'rails', '2.3.2'
gem 'active_presenter', '1.2.1'
gem 'activesupport', '2.3.2'
gem 'awesome_print', '0.2.1', :require => 'ap'
+gem 'haml'
gem 'mc-settings'
gem 'mongrel', '1.1.5'
gem 'nokogiri', '1.4.3.1'
diff --git a/rails/map-mash/Gemfile.lock b/rails/map-mash/Gemfile.lock
index 0749f74..697e915 100644
--- a/rails/map-mash/Gemfile.lock
+++ b/rails/map-mash/Gemfile.lock
@@ -44,6 +44,7 @@ GEM
em-websocket (>= 0.2.0)
guard (>= 0.10.0)
multi_json (~> 1.0)
+ haml (3.1.1)
kgio (2.7.2)
launchy (0.3.7)
configuration (>= 0.0.5)
@@ -167,6 +168,7 @@ DEPENDENCIES
foreman
guard
guard-livereload
+ haml
launchy (= 0.3.7)
machinist (= 1.0.6)
mc-settings
diff --git a/rails/map-mash/app/controllers/mashes_controller.rb b/rails/map-mash/app/controllers/mashes_controller.rb
new file mode 100644
index 0000000..bbf4e79
--- /dev/null
+++ b/rails/map-mash/app/controllers/mashes_controller.rb
@@ -0,0 +1,85 @@
+class MashesController < ApplicationController
+ # GET /mashes
+ # GET /mashes.xml
+ def index
+ @mashes = Mash.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @mashes }
+ end
+ end
+
+ # GET /mashes/1
+ # GET /mashes/1.xml
+ def show
+ @mash = Mash.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @mash }
+ end
+ end
+
+ # GET /mashes/new
+ # GET /mashes/new.xml
+ def new
+ @mash = Mash.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @mash }
+ end
+ end
+
+ # GET /mashes/1/edit
+ def edit
+ @mash = Mash.find(params[:id])
+ end
+
+ # POST /mashes
+ # POST /mashes.xml
+ def create
+ @mash = Mash.new(params[:mash])
+
+ respond_to do |format|
+ if @mash.save
+ flash[:notice] = 'Mash was successfully created.'
+ format.html { redirect_to(@mash) }
+ format.xml { render :xml => @mash, :status => :created, :location => @mash }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /mashes/1
+ # PUT /mashes/1.xml
+ def update
+ @mash = Mash.find(params[:id])
+
+ respond_to do |format|
+ if @mash.update_attributes(params[:mash])
+ flash[:notice] = 'Mash was successfully updated.'
+ format.html { redirect_to(@mash) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /mashes/1
+ # DELETE /mashes/1.xml
+ def destroy
+ @mash = Mash.find(params[:id])
+ @mash.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(mashes_url) }
+ format.xml { head :ok }
+ end
+ end
+end
diff --git a/rails/map-mash/app/helpers/mashes_helper.rb b/rails/map-mash/app/helpers/mashes_helper.rb
new file mode 100644
index 0000000..56888b5
--- /dev/null
+++ b/rails/map-mash/app/helpers/mashes_helper.rb
@@ -0,0 +1,2 @@
+module MashesHelper
+end
diff --git a/rails/map-mash/app/models/map.rb b/rails/map-mash/app/models/map.rb
new file mode 100644
index 0000000..e7d4ce2
--- /dev/null
+++ b/rails/map-mash/app/models/map.rb
@@ -0,0 +1,2 @@
+class Map < ActiveRecord::Base
+end
diff --git a/rails/map-mash/app/models/mash.rb b/rails/map-mash/app/models/mash.rb
new file mode 100644
index 0000000..be0264f
--- /dev/null
+++ b/rails/map-mash/app/models/mash.rb
@@ -0,0 +1,2 @@
+class Mash < ActiveRecord::Base
+end
diff --git a/rails/map-mash/app/views/layouts/mashes.html.erb b/rails/map-mash/app/views/layouts/mashes.html.erb
new file mode 100644
index 0000000..4b22e3b
--- /dev/null
+++ b/rails/map-mash/app/views/layouts/mashes.html.erb
@@ -0,0 +1,17 @@
+
+
+
+
+
+ Mashes: <%= controller.action_name %>
+ <%= stylesheet_link_tag 'scaffold' %>
+
+
+
+<%= flash[:notice] %>
+
+<%= yield %>
+
+
+
diff --git a/rails/map-mash/app/views/mashes/edit.html.erb b/rails/map-mash/app/views/mashes/edit.html.erb
new file mode 100644
index 0000000..16a3d4c
--- /dev/null
+++ b/rails/map-mash/app/views/mashes/edit.html.erb
@@ -0,0 +1,28 @@
+Editing mash
+
+<% form_for(@mash) do |f| %>
+ <%= f.error_messages %>
+
+
+ <%= f.label :requester %>
+ <%= f.text_field :requester %>
+
+
+ <%= f.label :map_a %>
+ <%= f.text_field :map_a %>
+
+
+ <%= f.label :map_b %>
+ <%= f.text_field :map_b %>
+
+
+ <%= f.label :winner %>
+ <%= f.text_field :winner %>
+
+
+ <%= f.submit 'Update' %>
+
+<% end %>
+
+<%= link_to 'Show', @mash %> |
+<%= link_to 'Back', mashes_path %>
\ No newline at end of file
diff --git a/rails/map-mash/app/views/mashes/index.html.erb b/rails/map-mash/app/views/mashes/index.html.erb
new file mode 100644
index 0000000..5d9cdfc
--- /dev/null
+++ b/rails/map-mash/app/views/mashes/index.html.erb
@@ -0,0 +1,26 @@
+Listing mashes
+
+
+
+ Requester |
+ Map a |
+ Map b |
+ Winner |
+
+
+<% @mashes.each do |mash| %>
+
+ <%=h mash.requester %> |
+ <%=h mash.map_a %> |
+ <%=h mash.map_b %> |
+ <%=h mash.winner %> |
+ <%= link_to 'Show', mash %> |
+ <%= link_to 'Edit', edit_mash_path(mash) %> |
+ <%= link_to 'Destroy', mash, :confirm => 'Are you sure?', :method => :delete %> |
+
+<% end %>
+
+
+
+
+<%= link_to 'New mash', new_mash_path %>
\ No newline at end of file
diff --git a/rails/map-mash/app/views/mashes/new.html.erb b/rails/map-mash/app/views/mashes/new.html.erb
new file mode 100644
index 0000000..3269278
--- /dev/null
+++ b/rails/map-mash/app/views/mashes/new.html.erb
@@ -0,0 +1,27 @@
+New mash
+
+<% form_for(@mash) do |f| %>
+ <%= f.error_messages %>
+
+
+ <%= f.label :requester %>
+ <%= f.text_field :requester %>
+
+
+ <%= f.label :map_a %>
+ <%= f.text_field :map_a %>
+
+
+ <%= f.label :map_b %>
+ <%= f.text_field :map_b %>
+
+
+ <%= f.label :winner %>
+ <%= f.text_field :winner %>
+
+
+ <%= f.submit 'Create' %>
+
+<% end %>
+
+<%= link_to 'Back', mashes_path %>
\ No newline at end of file
diff --git a/rails/map-mash/app/views/mashes/show.html.erb b/rails/map-mash/app/views/mashes/show.html.erb
new file mode 100644
index 0000000..bcee70b
--- /dev/null
+++ b/rails/map-mash/app/views/mashes/show.html.erb
@@ -0,0 +1,23 @@
+
+ Requester:
+ <%=h @mash.requester %>
+
+
+
+ Map a:
+ <%=h @mash.map_a %>
+
+
+
+ Map b:
+ <%=h @mash.map_b %>
+
+
+
+ Winner:
+ <%=h @mash.winner %>
+
+
+
+<%= link_to 'Edit', edit_mash_path(@mash) %> |
+<%= link_to 'Back', mashes_path %>
\ No newline at end of file
diff --git a/rails/map-mash/config/routes.rb b/rails/map-mash/config/routes.rb
index 4f3d9d2..4b28f6a 100644
--- a/rails/map-mash/config/routes.rb
+++ b/rails/map-mash/config/routes.rb
@@ -1,43 +1,4 @@
ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
-
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
-
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
-
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-
- # Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
- # end
-
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
-
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
-
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- # Note: These default routes make all actions in every controller accessible via GET requests. You should
- # consider removing the them or commenting them out if you're using named routes and resources.
- map.connect ':controller/:action/:id'
- map.connect ':controller/:action/:id.:format'
+ map.root :controller => 'mashes', :action => 'index'
+ map.resources :mashes
end
diff --git a/rails/map-mash/db/migrate/20120304151123_create_maps.rb b/rails/map-mash/db/migrate/20120304151123_create_maps.rb
new file mode 100644
index 0000000..00e9da5
--- /dev/null
+++ b/rails/map-mash/db/migrate/20120304151123_create_maps.rb
@@ -0,0 +1,13 @@
+class CreateMaps < ActiveRecord::Migration
+ def self.up
+ create_table :maps do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :maps
+ end
+end
diff --git a/rails/map-mash/db/migrate/20120304164625_create_mashes.rb b/rails/map-mash/db/migrate/20120304164625_create_mashes.rb
new file mode 100644
index 0000000..f4ac1bc
--- /dev/null
+++ b/rails/map-mash/db/migrate/20120304164625_create_mashes.rb
@@ -0,0 +1,16 @@
+class CreateMashes < ActiveRecord::Migration
+ def self.up
+ create_table :mashes do |t|
+ t.string :requester
+ t.integer :map_a
+ t.integer :map_b
+ t.integer :winner
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :mashes
+ end
+end
diff --git a/rails/map-mash/db/schema.rb b/rails/map-mash/db/schema.rb
index b81ae5a..0d8428b 100644
--- a/rails/map-mash/db/schema.rb
+++ b/rails/map-mash/db/schema.rb
@@ -9,6 +9,21 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 0) do
+ActiveRecord::Schema.define(:version => 20120304164625) do
+
+ create_table "maps", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "mashes", :force => true do |t|
+ t.string "requester"
+ t.integer "map_a"
+ t.integer "map_b"
+ t.integer "winner"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
end
diff --git a/rails/map-mash/log/.gitkeep b/rails/map-mash/log/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/rails/map-mash/public/index.html b/rails/map-mash/public/index.html
deleted file mode 100644
index 0dd5189..0000000
--- a/rails/map-mash/public/index.html
+++ /dev/null
@@ -1,275 +0,0 @@
-
-
-
-
- Ruby on Rails: Welcome aboard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Getting started
-
Here’s how to get rolling:
-
-
- -
-
Use script/generate to create your models and controllers
- To see all available options, run it without parameters.
-
-
- -
-
Set up a default route and remove or rename this file
- Routes are set up in config/routes.rb.
-
-
- -
-
Create your database
- Run rake db:migrate to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/rails/map-mash/public/robots.txt b/rails/map-mash/public/robots.txt
index 085187f..c6742d8 100644
--- a/rails/map-mash/public/robots.txt
+++ b/rails/map-mash/public/robots.txt
@@ -1,5 +1,2 @@
-# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
-#
-# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /
+User-Agent: *
+Disallow: /
diff --git a/rails/map-mash/public/stylesheets/scaffold.css b/rails/map-mash/public/stylesheets/scaffold.css
new file mode 100644
index 0000000..093c209
--- /dev/null
+++ b/rails/map-mash/public/stylesheets/scaffold.css
@@ -0,0 +1,54 @@
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
diff --git a/rails/map-mash/spec/controllers/mashes_controller_spec.rb b/rails/map-mash/spec/controllers/mashes_controller_spec.rb
new file mode 100644
index 0000000..b2be0db
--- /dev/null
+++ b/rails/map-mash/spec/controllers/mashes_controller_spec.rb
@@ -0,0 +1,131 @@
+require 'spec_helper'
+
+describe MashesController do
+
+ def mock_mash(stubs={})
+ @mock_mash ||= mock_model(Mash, stubs)
+ end
+
+ describe "GET index" do
+ it "assigns all mashes as @mashes" do
+ Mash.stub(:find).with(:all).and_return([mock_mash])
+ get :index
+ assigns[:mashes].should == [mock_mash]
+ end
+ end
+
+ describe "GET show" do
+ it "assigns the requested mash as @mash" do
+ Mash.stub(:find).with("37").and_return(mock_mash)
+ get :show, :id => "37"
+ assigns[:mash].should equal(mock_mash)
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new mash as @mash" do
+ Mash.stub(:new).and_return(mock_mash)
+ get :new
+ assigns[:mash].should equal(mock_mash)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested mash as @mash" do
+ Mash.stub(:find).with("37").and_return(mock_mash)
+ get :edit, :id => "37"
+ assigns[:mash].should equal(mock_mash)
+ end
+ end
+
+ describe "POST create" do
+
+ describe "with valid params" do
+ it "assigns a newly created mash as @mash" do
+ Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => true))
+ post :create, :mash => {:these => 'params'}
+ assigns[:mash].should equal(mock_mash)
+ end
+
+ it "redirects to the created mash" do
+ Mash.stub(:new).and_return(mock_mash(:save => true))
+ post :create, :mash => {}
+ response.should redirect_to(mash_url(mock_mash))
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns a newly created but unsaved mash as @mash" do
+ Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => false))
+ post :create, :mash => {:these => 'params'}
+ assigns[:mash].should equal(mock_mash)
+ end
+
+ it "re-renders the 'new' template" do
+ Mash.stub(:new).and_return(mock_mash(:save => false))
+ post :create, :mash => {}
+ response.should render_template('new')
+ end
+ end
+
+ end
+
+ describe "PUT update" do
+
+ describe "with valid params" do
+ it "updates the requested mash" do
+ Mash.should_receive(:find).with("37").and_return(mock_mash)
+ mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, :id => "37", :mash => {:these => 'params'}
+ end
+
+ it "assigns the requested mash as @mash" do
+ Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
+ put :update, :id => "1"
+ assigns[:mash].should equal(mock_mash)
+ end
+
+ it "redirects to the mash" do
+ Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
+ put :update, :id => "1"
+ response.should redirect_to(mash_url(mock_mash))
+ end
+ end
+
+ describe "with invalid params" do
+ it "updates the requested mash" do
+ Mash.should_receive(:find).with("37").and_return(mock_mash)
+ mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, :id => "37", :mash => {:these => 'params'}
+ end
+
+ it "assigns the mash as @mash" do
+ Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
+ put :update, :id => "1"
+ assigns[:mash].should equal(mock_mash)
+ end
+
+ it "re-renders the 'edit' template" do
+ Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
+ put :update, :id => "1"
+ response.should render_template('edit')
+ end
+ end
+
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested mash" do
+ Mash.should_receive(:find).with("37").and_return(mock_mash)
+ mock_mash.should_receive(:destroy)
+ delete :destroy, :id => "37"
+ end
+
+ it "redirects to the mashes list" do
+ Mash.stub(:find).and_return(mock_mash(:destroy => true))
+ delete :destroy, :id => "1"
+ response.should redirect_to(mashes_url)
+ end
+ end
+
+end
diff --git a/rails/map-mash/spec/fixtures/mashes.yml b/rails/map-mash/spec/fixtures/mashes.yml
new file mode 100644
index 0000000..73b294c
--- /dev/null
+++ b/rails/map-mash/spec/fixtures/mashes.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ requester: MyString
+ map_a: 1
+ map_b: 1
+ winner: 1
+
+two:
+ requester: MyString
+ map_a: 1
+ map_b: 1
+ winner: 1
diff --git a/rails/map-mash/spec/helpers/mashes_helper_spec.rb b/rails/map-mash/spec/helpers/mashes_helper_spec.rb
new file mode 100644
index 0000000..5da5698
--- /dev/null
+++ b/rails/map-mash/spec/helpers/mashes_helper_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe MashesHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "is included in the helper object" do
+ included_modules = (class << helper; self; end).send :included_modules
+ included_modules.should include(MashesHelper)
+ end
+
+end
diff --git a/rails/map-mash/spec/integration/mashes_spec.rb b/rails/map-mash/spec/integration/mashes_spec.rb
new file mode 100644
index 0000000..a1ddad8
--- /dev/null
+++ b/rails/map-mash/spec/integration/mashes_spec.rb
@@ -0,0 +1,4 @@
+require 'spec_helper'
+
+describe "Mashes" do
+end
diff --git a/rails/map-mash/spec/models/map_spec.rb b/rails/map-mash/spec/models/map_spec.rb
new file mode 100644
index 0000000..0a3fcbb
--- /dev/null
+++ b/rails/map-mash/spec/models/map_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe Map do
+ before(:each) do
+ @valid_attributes = {
+ :name => "value for name"
+ }
+ end
+
+ it "should create a new instance given valid attributes" do
+ Map.create!(@valid_attributes)
+ end
+end
diff --git a/rails/map-mash/spec/routing/mashes_routing_spec.rb b/rails/map-mash/spec/routing/mashes_routing_spec.rb
new file mode 100644
index 0000000..abf720c
--- /dev/null
+++ b/rails/map-mash/spec/routing/mashes_routing_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe MashesController do
+ describe "routing" do
+ it "recognizes and generates #index" do
+ { :get => "/mashes" }.should route_to(:controller => "mashes", :action => "index")
+ end
+
+ it "recognizes and generates #new" do
+ { :get => "/mashes/new" }.should route_to(:controller => "mashes", :action => "new")
+ end
+
+ it "recognizes and generates #show" do
+ { :get => "/mashes/1" }.should route_to(:controller => "mashes", :action => "show", :id => "1")
+ end
+
+ it "recognizes and generates #edit" do
+ { :get => "/mashes/1/edit" }.should route_to(:controller => "mashes", :action => "edit", :id => "1")
+ end
+
+ it "recognizes and generates #create" do
+ { :post => "/mashes" }.should route_to(:controller => "mashes", :action => "create")
+ end
+
+ it "recognizes and generates #update" do
+ { :put => "/mashes/1" }.should route_to(:controller => "mashes", :action => "update", :id => "1")
+ end
+
+ it "recognizes and generates #destroy" do
+ { :delete => "/mashes/1" }.should route_to(:controller => "mashes", :action => "destroy", :id => "1")
+ end
+ end
+end
diff --git a/rails/map-mash/spec/views/mashes/edit.html.erb_spec.rb b/rails/map-mash/spec/views/mashes/edit.html.erb_spec.rb
new file mode 100644
index 0000000..af199f9
--- /dev/null
+++ b/rails/map-mash/spec/views/mashes/edit.html.erb_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe "/mashes/edit.html.erb" do
+ include MashesHelper
+
+ before(:each) do
+ assigns[:mash] = @mash = stub_model(Mash,
+ :new_record? => false,
+ :requester => "value for requester",
+ :map_a => 1,
+ :map_b => 1,
+ :winner => 1
+ )
+ end
+
+ it "renders the edit mash form" do
+ render
+
+ response.should have_tag("form[action=#{mash_path(@mash)}][method=post]") do
+ with_tag('input#mash_requester[name=?]', "mash[requester]")
+ with_tag('input#mash_map_a[name=?]', "mash[map_a]")
+ with_tag('input#mash_map_b[name=?]', "mash[map_b]")
+ with_tag('input#mash_winner[name=?]', "mash[winner]")
+ end
+ end
+end
diff --git a/rails/map-mash/spec/views/mashes/index.html.erb_spec.rb b/rails/map-mash/spec/views/mashes/index.html.erb_spec.rb
new file mode 100644
index 0000000..6ea176e
--- /dev/null
+++ b/rails/map-mash/spec/views/mashes/index.html.erb_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe "/mashes/index.html.erb" do
+ include MashesHelper
+
+ before(:each) do
+ assigns[:mashes] = [
+ stub_model(Mash,
+ :requester => "value for requester",
+ :map_a => 1,
+ :map_b => 1,
+ :winner => 1
+ ),
+ stub_model(Mash,
+ :requester => "value for requester",
+ :map_a => 1,
+ :map_b => 1,
+ :winner => 1
+ )
+ ]
+ end
+
+ it "renders a list of mashes" do
+ render
+ response.should have_tag("tr>td", "value for requester".to_s, 2)
+ response.should have_tag("tr>td", 1.to_s, 2)
+ response.should have_tag("tr>td", 1.to_s, 2)
+ response.should have_tag("tr>td", 1.to_s, 2)
+ end
+end
diff --git a/rails/map-mash/spec/views/mashes/new.html.erb_spec.rb b/rails/map-mash/spec/views/mashes/new.html.erb_spec.rb
new file mode 100644
index 0000000..8ce3be3
--- /dev/null
+++ b/rails/map-mash/spec/views/mashes/new.html.erb_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe "/mashes/new.html.erb" do
+ include MashesHelper
+
+ before(:each) do
+ assigns[:mash] = stub_model(Mash,
+ :new_record? => true,
+ :requester => "value for requester",
+ :map_a => 1,
+ :map_b => 1,
+ :winner => 1
+ )
+ end
+
+ it "renders new mash form" do
+ render
+
+ response.should have_tag("form[action=?][method=post]", mashes_path) do
+ with_tag("input#mash_requester[name=?]", "mash[requester]")
+ with_tag("input#mash_map_a[name=?]", "mash[map_a]")
+ with_tag("input#mash_map_b[name=?]", "mash[map_b]")
+ with_tag("input#mash_winner[name=?]", "mash[winner]")
+ end
+ end
+end
diff --git a/rails/map-mash/spec/views/mashes/show.html.erb_spec.rb b/rails/map-mash/spec/views/mashes/show.html.erb_spec.rb
new file mode 100644
index 0000000..80ad4e7
--- /dev/null
+++ b/rails/map-mash/spec/views/mashes/show.html.erb_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe "/mashes/show.html.erb" do
+ include MashesHelper
+ before(:each) do
+ assigns[:mash] = @mash = stub_model(Mash,
+ :requester => "value for requester",
+ :map_a => 1,
+ :map_b => 1,
+ :winner => 1
+ )
+ end
+
+ it "renders attributes in " do
+ render
+ response.should have_text(/value\ for\ requester/)
+ response.should have_text(/1/)
+ response.should have_text(/1/)
+ response.should have_text(/1/)
+ end
+end