Update rspec #100

Merged
merged 16 commits into from May 26, 2011
Jump to file
+98 −63
Split
View
@@ -35,8 +35,8 @@ group :development, :test do
end
group :test do
- gem 'rspec', '2.0.0.beta.22'
- gem 'rspec-rails', '2.0.0.beta.22'
+ gem 'rspec', '~> 2.6.0'
+ gem 'rspec-rails', '~> 2.6.0'
gem 'capybara', '0.3.9'
gem 'cucumber', '0.9.2'
gem 'cucumber-rails', '0.3.2'
View
@@ -71,6 +71,10 @@ namespace :cucumber do
Cucumber::Rake::Task.new(:all) do |t|
t.profile = 'default'
end
+
+ Cucumber::Rake::Task.new(:wip) do |t|
+ t.profile = 'wip'
+ end
end
task :cucumber => "cucumber:all"
View
@@ -1 +1,2 @@
default: --format 'progress' --require features/support/env.rb --require features/step_definitions features
+wip: --format 'progress' --require features/support/env.rb --require features/step_definitions features --tags @wip:3 --wip features
View
@@ -13,6 +13,7 @@ Feature: Menu
When I am on the dashboard
Then I should not see a menu item for "Posts"
+ @wip
Scenario: Set the menu item label
Given a configuration of:
"""
@@ -86,8 +86,12 @@ def indent(open_tag, child_content, close_tag)
html = ""
if no_child? || child_is_text?
- # one line
- html << spaces << open_tag << child_content << close_tag
+ if self_closing_tag?
+ html << spaces << open_tag.sub( />$/, '/>' )
+ else
+ # one line
+ html << spaces << open_tag << child_content << close_tag
+ end
else
# multiple lines
html << spaces << open_tag << "\n"
@@ -100,6 +104,10 @@ def indent(open_tag, child_content, close_tag)
html
end
+ def self_closing_tag?
+ %w|meta link|.include?(tag_name)
+ end
+
def no_child?
children.empty?
end
@@ -1,18 +1,21 @@
-<div id="login">
- <h2><%= title "#{ActiveAdmin.site_title} Login" %></h2>
+<div id="active_admin_content">
+ <div id="login">
+ <h2><%= title "#{ActiveAdmin.site_title} Login" %></h2>
- <% scope = Devise::Mapping.find_scope!(resource_name) %>
- <%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
- f.inputs do
- Devise.authentication_keys.each { |key| f.input key }
- f.input :password
- f.input :remember_me, :as => :boolean, :if => false #devise_mapping.rememberable? }
- end
- f.buttons do
- f.commit_button "Login"
- end
- end
- %>
+ <% scope = Devise::Mapping.find_scope!(resource_name) %>
+ <%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
+ f.inputs do
+ Devise.authentication_keys.each { |key| f.input key }
+ f.input :password
+ f.input :remember_me, :as => :boolean, :if => false #devise_mapping.rememberable? }
+ end
+ f.buttons do
+ f.commit_button "Login"
+ end
+ end
+ %>
- <%= render :partial => "devise/shared/links" %>
+ <%= render :partial => "devise/shared/links" %>
+ </div>
+
</div>
@@ -1,40 +1,35 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
-describe_with_render "Index as CSV" do
-
- before :all do
- load_defaults!
- reload_routes!
- end
-
- before(:each) do
- Admin::PostsController.reset_index_config!
- end
-
+describe_with_render Admin::PostsController do
describe "get index with format csv" do
+
before do
Post.create :title => "Hello World"
Post.create :title => "Goodbye World"
end
+
it "should return csv" do
get :index, 'format' => 'csv'
response.content_type.should == 'text/csv'
end
+
it "should return a header and a line for each item" do
get :index, 'format' => 'csv'
response.body.split("\n").size.should == 3
end
+
Post.columns.each do |column|
it "should include a header for #{column.name}" do
get :index, 'format' => 'csv'
response.body.split("\n").first.should include(column.name.titleize)
end
end
+
it "should set a much higher per page pagination" do
100.times{ Post.create :title => "woot" }
get :index, 'format' => 'csv'
response.body.split("\n").size.should == 103
end
- end
+ end
end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe_with_capybara "Belongs To" do
View
@@ -59,15 +59,14 @@ def describe_with_render(*args, &block)
describe *args do
include RSpec::Rails::ControllerExampleGroup
render_views
- metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
+ # metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
module_eval &block
end
end
# Setup a describe block which uses capybara and rails integration
# test methods.
def describe_with_capybara(*args, &block)
- require 'integration_example_group'
describe *args do
include RSpec::Rails::IntegrationExampleGroup
module_eval &block
@@ -113,15 +112,22 @@ def mock_action_view(assigns = {})
# test for the presence of an asset file
ENV["RAILS_ASSET_ID"] = ''
-Rspec.configure do |config|
+RSpec.configure do |config|
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
end
+# All RSpec configuration needs to happen before any examples
+# or else it whines.
+require 'integration_example_group'
+RSpec.configure do |c|
+ c.include RSpec::Rails::IntegrationExampleGroup, :example_group => { :file_path => /\bspec\/integration\// }
+end
+
# Ensure this is defined for Ruby 1.8
module MiniTest; class Assertion < Exception; end; end
-Rspec::Matchers.define :have_tag do |*args|
+RSpec::Matchers.define :have_tag do |*args|
match_unless_raises Test::Unit::AssertionFailedError do |response|
tag = args.shift
@@ -28,10 +28,6 @@ def last_response
@router = ::Rails.application.routes
end
end
-
- RSpec.configure do |c|
- c.include self, :example_group => { :file_path => /\bspec\/integration\// }
- end
end
end
end
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe 'defining new actions from registration blocks' do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::ActionItems do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'fileutils'
describe ActiveAdmin do
@@ -148,6 +148,27 @@
end
end
+ describe "self-closing nodes" do
+ it "should not self-close script tags" do
+ tag = script :type => 'text/javascript'
+ tag.to_html.should == <<-HTML
+<script type="text/javascript"></script>
+HTML
+ end
+ it "should self-close meta tags" do
+ tag = meta :content => "text/html; charset=utf-8"
+ tag.to_html.should == <<-HTML
+<meta content="text/html; charset=utf-8\"/>
+HTML
+ end
+ it "should self-close link tags" do
+ tag = link :rel => "stylesheet"
+ tag.to_html.should == <<-HTML
+<link rel="stylesheet"/>
+HTML
+ end
+ end
+
describe "html safe" do
it "should escape the contents" do
span("<br />").to_html.should == <<-HTML
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module MockRegistration
extend ActiveAdmin::AssetRegistration
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
class Resource
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe "Breadcrumbs" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe "Configuration" do
it "should have an array of namespaces which allow comments" do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin, "filters" do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module Admin
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Dashboards::Section do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Dashboards do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::ViewHelpers::FilterFormHelper do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::FormBuilder do
include Arbre::HTML
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
describe MenuItem do
View
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Menu do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Namespace do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe "Registering an object to administer" do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
include ActiveAdmin
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe ActiveAdmin::ResourceController do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
describe Resource do
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin, "Routing" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe ActiveAdmin::Views::TabsRenderer do