Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update rspec #100

Merged
merged 16 commits into from

3 participants

@bmarini

Updated to the latest RSpec and fixed some broken specs and warnings along the way

@gregbell
Owner

@bmarini This is great! Massive props to you for taking this on.

I'll get this merged in to master tonight.

@bmarini

@gregbell Right on. Jeremy and I threw in a couple more fixes to our work in this pull request, but we are done for now :)

@jeremyruppel

@gregbell Yeah man, thanks for the kickass project! Hope this helps.

@gregbell gregbell merged commit b4a90f7 into activeadmin:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 25, 2011
  1. Update to latest rspec

    Ben Marini authored
  2. Update Rspec to RSpec

    Ben Marini authored
  3. @jeremyruppel

    always require spec_helper the same way, fixes rspec yelling about po…

    jeremyruppel authored Ben Marini committed
    …st-example config
  4. @jeremyruppel

    arbre tags without any children should be self-closing, fixes whiny a…

    jeremyruppel authored Ben Marini committed
    …ssert_selects
  5. Fix index_as_csv_spec by making it a controller spec

    Ben Marini authored
  6. Fix arbre html test

    Ben Marini authored
  7. @jeremyruppel

    move inclusion of integration example group before any examples are d…

    jeremyruppel authored Ben Marini committed
    …efined
  8. Get specs passing

    Ben Marini authored
  9. @jeremyruppel
  10. @jeremyruppel
Commits on May 26, 2011
  1. @jeremyruppel
  2. @jeremyruppel
  3. @jeremyruppel

    This reverts 71036bf

    jeremyruppel authored
  4. @jeremyruppel
  5. @jeremyruppel
This page is out of date. Refresh to see the latest.
Showing with 98 additions and 63 deletions.
  1. +2 −2 Gemfile
  2. +4 −0 Rakefile
  3. +1 −0  cucumber.yml
  4. +1 −0  features/menu.feature
  5. +10 −2 lib/active_admin/arbre/tag.rb
  6. +18 −15 lib/active_admin/views/templates/active_admin/devise/sessions/new.html.erb
  7. +8 −13 spec/{integration → controllers}/index_as_csv_spec.rb
  8. +1 −1  spec/integration/belongs_to_spec.rb
  9. +10 −4 spec/spec_helper.rb
  10. +0 −4 spec/support/integration_example_group.rb
  11. +1 −1  spec/unit/action_builder_spec.rb
  12. +1 −1  spec/unit/action_items_spec.rb
  13. +1 −1  spec/unit/active_admin_spec.rb
  14. +21 −0 spec/unit/arbre/html_spec.rb
  15. +1 −1  spec/unit/asset_registration_spec.rb
  16. +1 −1  spec/unit/belongs_to_spec.rb
  17. +1 −1  spec/unit/breadcrumbs_spec.rb
  18. +1 −1  spec/unit/comments_spec.rb
  19. +1 −1  spec/unit/controller_filters_spec.rb
  20. +1 −1  spec/unit/dashboard_controller_spec.rb
  21. +1 −1  spec/unit/dashboard_section_spec.rb
  22. +1 −1  spec/unit/dashboards_spec.rb
  23. +1 −1  spec/unit/filter_form_builder_spec.rb
  24. +1 −1  spec/unit/form_builder_spec.rb
  25. +1 −1  spec/unit/menu_item_spec.rb
  26. +1 −1  spec/unit/menu_spec.rb
  27. +1 −1  spec/unit/namespace_spec.rb
  28. +1 −1  spec/unit/registration_spec.rb
  29. +1 −1  spec/unit/renderer_spec.rb
  30. +1 −1  spec/unit/resource_controller_spec.rb
  31. +1 −1  spec/unit/resource_spec.rb
  32. +1 −1  spec/unit/routing_spec.rb
  33. +1 −1  spec/unit/tabs_renderer_spec.rb
View
4 Gemfile
@@ -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
4 Rakefile
@@ -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  cucumber.yml
@@ -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
1  features/menu.feature
@@ -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:
"""
View
12 lib/active_admin/arbre/tag.rb
@@ -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
View
33 lib/active_admin/views/templates/active_admin/devise/sessions/new.html.erb
@@ -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>
View
21 spec/integration/index_as_csv_spec.rb → spec/controllers/index_as_csv_spec.rb
@@ -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
View
2  spec/integration/belongs_to_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe_with_capybara "Belongs To" do
View
14 spec/spec_helper.rb
@@ -59,7 +59,7 @@ 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
@@ -67,7 +67,6 @@ def describe_with_render(*args, &block)
# 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
View
4 spec/support/integration_example_group.rb
@@ -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
View
2  spec/unit/action_builder_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe 'defining new actions from registration blocks' do
View
2  spec/unit/action_items_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::ActionItems do
View
2  spec/unit/active_admin_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
require 'fileutils'
describe ActiveAdmin do
View
21 spec/unit/arbre/html_spec.rb
@@ -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
View
2  spec/unit/asset_registration_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module MockRegistration
extend ActiveAdmin::AssetRegistration
View
2  spec/unit/belongs_to_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
class Resource
View
2  spec/unit/breadcrumbs_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe "Breadcrumbs" do
View
2  spec/unit/comments_spec.rb
@@ -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
View
2  spec/unit/controller_filters_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin, "filters" do
View
2  spec/unit/dashboard_controller_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module Admin
View
2  spec/unit/dashboard_section_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Dashboards::Section do
View
2  spec/unit/dashboards_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Dashboards do
View
2  spec/unit/filter_form_builder_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::ViewHelpers::FilterFormHelper do
View
2  spec/unit/form_builder_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::FormBuilder do
include Arbre::HTML
View
2  spec/unit/menu_item_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
describe MenuItem do
View
2  spec/unit/menu_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Menu do
View
2  spec/unit/namespace_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin::Namespace do
View
2  spec/unit/registration_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe "Registering an object to administer" do
View
2  spec/unit/renderer_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
include ActiveAdmin
View
2  spec/unit/resource_controller_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe ActiveAdmin::ResourceController do
View
2  spec/unit/resource_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
module ActiveAdmin
describe Resource do
View
2  spec/unit/routing_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'spec_helper'
describe ActiveAdmin, "Routing" do
View
2  spec/unit/tabs_renderer_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe ActiveAdmin::Views::TabsRenderer do
Something went wrong with that request. Please try again.