Skip to content
This repository
Browse code

upgrading test dependencies, converting shoulda_macros to

test_matchers. no reason to invoke the name of shoulda anymore
  • Loading branch information...
commit 9358de8b69e1c9fdbb30407ec8eec799805cb2da 1 parent 76ca2ee
Dan Croak croaky authored
2  Gemfile
@@ -10,7 +10,7 @@ gem "capybara", "1.0.0"
10 10 gem "factory_girl_rails"
11 11 gem "shoulda-matchers", :git => "git://github.com/thoughtbot/shoulda-matchers.git"
12 12 gem "database_cleaner"
13   -gem "rspec-rails"
  13 +gem "rspec-rails", "~> 2.6.0"
14 14 gem "launchy"
15 15 gem "mocha"
16 16 gem "appraisal", "~> 0.3.5"
10 Gemfile.lock
... ... @@ -1,13 +1,13 @@
1 1 GIT
2 2 remote: git://github.com/thoughtbot/diesel.git
3   - revision: 9a7955eadd3e2f445ecf3d2d58edfc2a5e80a20b
  3 + revision: f68a990573e2684bb4645a90876603de0a772b69
4 4 specs:
5 5 diesel (0.1.4)
6 6 railties
7 7
8 8 GIT
9 9 remote: git://github.com/thoughtbot/shoulda-matchers.git
10   - revision: 85d3e5ea000cf162ef672059ea5e5f77f3ca9f03
  10 + revision: a922b8ec38b65ae3274f194e90eaff6ac642d0b1
11 11 specs:
12 12 shoulda-matchers (1.0.0.beta3)
13 13
@@ -118,7 +118,7 @@ GEM
118 118 rdoc (~> 3.4)
119 119 thor (~> 0.14.4)
120 120 rake (0.9.2)
121   - rdoc (3.6.1)
  121 + rdoc (3.7)
122 122 rspec (2.6.0)
123 123 rspec-core (~> 2.6.0)
124 124 rspec-expectations (~> 2.6.0)
@@ -143,7 +143,7 @@ GEM
143 143 thor (0.14.6)
144 144 treetop (1.4.9)
145 145 polyglot (>= 0.3.1)
146   - tzinfo (0.3.28)
  146 + tzinfo (0.3.29)
147 147 xpath (0.1.4)
148 148 nokogiri (~> 1.3)
149 149
@@ -161,6 +161,6 @@ DEPENDENCIES
161 161 launchy
162 162 mocha
163 163 rails (= 3.0.9)
164   - rspec-rails
  164 + rspec-rails (~> 2.6.0)
165 165 shoulda-matchers!
166 166 sqlite3
5 Rakefile
@@ -26,3 +26,8 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
26 26 t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
27 27 end
28 28
  29 +<<<<<<< HEAD
  30 +=======
  31 +desc "Default: run the specs and cucumber features"
  32 +task :default => [:spec, :cucumber]
  33 +>>>>>>> upgrading test dependencies, converting shoulda_macros to
172 features/step_definitions/web_steps.rb
... ... @@ -1,21 +1,46 @@
1   -# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2   -# It is recommended to regenerate this file in the future when you upgrade to a
3   -# newer version of cucumber-rails. Consider adding your own code to a new file
4   -# instead of editing this one. Cucumber will automatically load all features/**/*.rb
5   -# files.
  1 +# TL;DR: YOU SHOULD DELETE THIS FILE
  2 +#
  3 +# This file was generated by Cucumber-Rails and is only here to get you a head start
  4 +# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
  5 +# visit pages, interact with widgets and make assertions about page content.
  6 +#
  7 +# If you use these step definitions as basis for your features you will quickly end up
  8 +# with features that are:
  9 +#
  10 +# * Hard to maintain
  11 +# * Verbose to read
  12 +#
  13 +# A much better approach is to write your own higher level step definitions, following
  14 +# the advice in the following blog posts:
  15 +#
  16 +# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
  17 +# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
  18 +# * http://elabs.se/blog/15-you-re-cuking-it-wrong
  19 +#
6 20
7 21
8 22 require 'uri'
9 23 require 'cgi'
10 24 require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
  25 +require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
11 26
12 27 module WithinHelpers
13 28 def with_scope(locator)
14   - locator ? within(locator) { yield } : yield
  29 + locator ? within(*selector_for(locator)) { yield } : yield
15 30 end
16 31 end
17 32 World(WithinHelpers)
18 33
  34 +# Single-line step scoper
  35 +When /^(.*) within ([^:]+)$/ do |step, parent|
  36 + with_scope(parent) { When step }
  37 +end
  38 +
  39 +# Multi-line step scoper
  40 +When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
  41 + with_scope(parent) { When "#{step}:", table_or_string }
  42 +end
  43 +
19 44 Given /^(?:|I )am on (.+)$/ do |page_name|
20 45 visit path_to(page_name)
21 46 end
@@ -24,28 +49,20 @@ def with_scope(locator)
24 49 visit path_to(page_name)
25 50 end
26 51
27   -When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28   - with_scope(selector) do
29   - click_button(button)
30   - end
  52 +When /^(?:|I )press "([^"]*)"$/ do |button|
  53 + click_button(button)
31 54 end
32 55
33   -When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34   - with_scope(selector) do
35   - click_link(link)
36   - end
  56 +When /^(?:|I )follow "([^"]*)"$/ do |link|
  57 + click_link(link)
37 58 end
38 59
39   -When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40   - with_scope(selector) do
41   - fill_in(field, :with => value)
42   - end
  60 +When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
  61 + fill_in(field, :with => value)
43 62 end
44 63
45   -When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46   - with_scope(selector) do
47   - fill_in(field, :with => value)
48   - end
  64 +When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
  65 + fill_in(field, :with => value)
49 66 end
50 67
51 68 # Use this to fill in an entire form with data from a table. Example:
@@ -59,95 +76,70 @@ def with_scope(locator)
59 76 # TODO: Add support for checkbox, select og option
60 77 # based on naming conventions.
61 78 #
62   -When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63   - with_scope(selector) do
64   - fields.rows_hash.each do |name, value|
65   - When %{I fill in "#{name}" with "#{value}"}
66   - end
67   - end
68   -end
69   -
70   -When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71   - with_scope(selector) do
72   - select(value, :from => field)
  79 +When /^(?:|I )fill in the following:$/ do |fields|
  80 + fields.rows_hash.each do |name, value|
  81 + When %{I fill in "#{name}" with "#{value}"}
73 82 end
74 83 end
75 84
76   -When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77   - with_scope(selector) do
78   - check(field)
79   - end
  85 +When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
  86 + select(value, :from => field)
80 87 end
81 88
82   -When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83   - with_scope(selector) do
84   - uncheck(field)
85   - end
  89 +When /^(?:|I )check "([^"]*)"$/ do |field|
  90 + check(field)
86 91 end
87 92
88   -When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89   - with_scope(selector) do
90   - choose(field)
91   - end
  93 +When /^(?:|I )uncheck "([^"]*)"$/ do |field|
  94 + uncheck(field)
92 95 end
93 96
94   -When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95   - with_scope(selector) do
96   - attach_file(field, path)
97   - end
  97 +When /^(?:|I )choose "([^"]*)"$/ do |field|
  98 + choose(field)
98 99 end
99 100
100   -Then /^(?:|I )should see JSON:$/ do |expected_json|
101   - require 'json'
102   - expected = JSON.pretty_generate(JSON.parse(expected_json))
103   - actual = JSON.pretty_generate(JSON.parse(response.body))
104   - expected.should == actual
  101 +When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
  102 + attach_file(field, File.expand_path(path))
105 103 end
106 104
107   -Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108   - with_scope(selector) do
109   - if page.respond_to? :should
110   - page.should have_content(text)
111   - else
112   - assert page.has_content?(text)
113   - end
  105 +Then /^(?:|I )should see "([^"]*)"$/ do |text|
  106 + if page.respond_to? :should
  107 + page.should have_content(text)
  108 + else
  109 + assert page.has_content?(text)
114 110 end
115 111 end
116 112
117   -Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
  113 +Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
118 114 regexp = Regexp.new(regexp)
119   - with_scope(selector) do
120   - if page.respond_to? :should
121   - page.should have_xpath('//*', :text => regexp)
122   - else
123   - assert page.has_xpath?('//*', :text => regexp)
124   - end
  115 +
  116 + if page.respond_to? :should
  117 + page.should have_xpath('//*', :text => regexp)
  118 + else
  119 + assert page.has_xpath?('//*', :text => regexp)
125 120 end
126 121 end
127 122
128   -Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129   - with_scope(selector) do
130   - if page.respond_to? :should
131   - page.should have_no_content(text)
132   - else
133   - assert page.has_no_content?(text)
134   - end
  123 +Then /^(?:|I )should not see "([^"]*)"$/ do |text|
  124 + if page.respond_to? :should
  125 + page.should have_no_content(text)
  126 + else
  127 + assert page.has_no_content?(text)
135 128 end
136 129 end
137 130
138   -Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
  131 +Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
139 132 regexp = Regexp.new(regexp)
140   - with_scope(selector) do
141   - if page.respond_to? :should
142   - page.should have_no_xpath('//*', :text => regexp)
143   - else
144   - assert page.has_no_xpath?('//*', :text => regexp)
145   - end
  133 +
  134 + if page.respond_to? :should
  135 + page.should have_no_xpath('//*', :text => regexp)
  136 + else
  137 + assert page.has_no_xpath?('//*', :text => regexp)
146 138 end
147 139 end
148 140
149   -Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150   - with_scope(selector) do
  141 +Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
  142 + with_scope(parent) do
151 143 field = find_field(field)
152 144 field_value = (field.tag_name == 'textarea') ? field.text : field.value
153 145 if field_value.respond_to? :should
@@ -158,8 +150,8 @@ def with_scope(locator)
158 150 end
159 151 end
160 152
161   -Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162   - with_scope(selector) do
  153 +Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
  154 + with_scope(parent) do
163 155 field = find_field(field)
164 156 field_value = (field.tag_name == 'textarea') ? field.text : field.value
165 157 if field_value.respond_to? :should_not
@@ -170,8 +162,8 @@ def with_scope(locator)
170 162 end
171 163 end
172 164
173   -Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174   - with_scope(selector) do
  165 +Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
  166 + with_scope(parent) do
175 167 field_checked = find_field(label)['checked']
176 168 if field_checked.respond_to? :should
177 169 field_checked.should be_true
@@ -181,8 +173,8 @@ def with_scope(locator)
181 173 end
182 174 end
183 175
184   -Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185   - with_scope(selector) do
  176 +Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
  177 + with_scope(parent) do
186 178 field_checked = find_field(label)['checked']
187 179 if field_checked.respond_to? :should
188 180 field_checked.should be_false
3  features/support/aruba.rb
... ... @@ -0,0 +1,3 @@
  1 +Before do
  2 + @aruba_timeout_seconds = 60
  3 +end
16 features/support/clearance.rb
... ... @@ -0,0 +1,16 @@
  1 +require 'clearance'
  2 +
  3 +Clearance.configure do |config|
  4 +end
  5 +
  6 +class ApplicationController < ActionController::Base
  7 + include Clearance::Authentication
  8 +
  9 + def show
  10 + render :text => "", :layout => 'application'
  11 + end
  12 +end
  13 +
  14 +class User < ActiveRecord::Base
  15 + include Clearance::User
  16 +end
61 features/support/env.rb
... ... @@ -1,43 +1,52 @@
  1 +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
  2 +# It is recommended to regenerate this file in the future when you upgrade to a
  3 +# newer version of cucumber-rails. Consider adding your own code to a new file
  4 +# instead of editing this one. Cucumber will automatically load all features/**/*.rb
  5 +# files.
  6 +
1 7 ENV["RAILS_ENV"] ||= "test"
2 8
3 9 PROJECT_ROOT = File.expand_path("../../..", __FILE__)
4 10 $LOAD_PATH << File.join(PROJECT_ROOT, "lib")
5 11
6 12 require 'rails/all'
  13 +
7 14 Bundler.require
8 15
9 16 require 'diesel/testing'
10 17 require 'diesel/testing/integration'
11 18
12   -require 'clearance'
13   -require 'clearance/shoulda_macros'
14   -
15   -Clearance.configure do |config|
16   -end
17   -
18   -class ApplicationController < ActionController::Base
19   - include Clearance::Authentication
20   -
21   - def show
22   - render :text => "", :layout => 'application'
23   - end
24   -end
25   -
26   -class User < ActiveRecord::Base
27   - include Clearance::User
28   -end
29   -
30   -require 'cucumber/formatter/unicode'
31   -require 'cucumber/rails/world'
32   -require 'cucumber/rails/hooks'
33   -require 'cucumber/rails/capybara'
34   -require 'cucumber/web/tableish'
  19 +require 'cucumber/rails'
35 20
  21 +# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
  22 +# order to ease the transition to Capybara we set the default here. If you'd
  23 +# prefer to use XPath just remove this line and adjust any selectors in your
  24 +# steps to use the XPath syntax.
36 25 Capybara.default_selector = :css
37 26 Capybara.save_and_open_page_path = 'tmp'
38   -DatabaseCleaner.strategy = :transaction
39 27
40   -Before do
41   - @aruba_timeout_seconds = 60
  28 +# By default, any exception happening in your Rails application will bubble up
  29 +# to Cucumber so that your scenario will fail. This is a different from how
  30 +# your application behaves in the production environment, where an error page will
  31 +# be rendered instead.
  32 +#
  33 +# Sometimes we want to override this default behaviour and allow Rails to rescue
  34 +# exceptions and display an error page (just like when the app is running in production).
  35 +# Typical scenarios where you want to do this is when you test your error pages.
  36 +# There are two ways to allow Rails to rescue exceptions:
  37 +#
  38 +# 1) Tag your scenario (or feature) with @allow-rescue
  39 +#
  40 +# 2) Set the value below to true. Beware that doing this globally is not
  41 +# recommended as it will mask a lot of errors for you!
  42 +#
  43 +ActionController::Base.allow_rescue = false
  44 +
  45 +# Remove/comment out the lines below if your app doesn't have a database.
  46 +# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
  47 +begin
  48 + DatabaseCleaner.strategy = :transaction
  49 +rescue NameError
  50 + raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
42 51 end
43 52
1  lib/clearance.rb
@@ -3,3 +3,4 @@
3 3 require 'clearance/user'
4 4
5 5 require 'clearance/engine'
  6 +require 'clearance/test_matchers'
73 lib/clearance/shoulda_macros.rb
... ... @@ -1,73 +0,0 @@
1   -module Clearance
2   - module Shoulda
3   - # STATE OF AUTHENTICATION
4   -
5   - def should_deny_access(opts = {})
6   - if opts[:flash]
7   - should set_the_flash.to(opts[:flash])
8   - else
9   - should_not set_the_flash
10   - end
11   -
12   - should redirect_to('sign in page') { sign_in_url }
13   - end
14   -
15   - # HTTP FLUENCY
16   -
17   - def should_forbid(description, &block)
18   - warn "[DEPRECATION] should_forbid and Clearance's ActionController::Forbidden have been removed. Setting the 403 status code turned out to be an awful user experience in some browsers such as Chrome on Windows machines."
19   - end
20   -
21   - # RENDERING
22   -
23   - def should_render_nothing
24   - should "render nothing" do
25   - assert @response.body.blank?
26   - end
27   - end
28   -
29   - # REDIRECTS
30   -
31   - def should_redirect_to_url_after_create
32   - should redirect_to("the post-create url") { @controller.send(:url_after_create) }
33   - end
34   -
35   - def should_redirect_to_url_after_update
36   - should redirect_to("the post-update url") { @controller.send(:url_after_update) }
37   - end
38   -
39   - def should_redirect_to_url_after_destroy
40   - should redirect_to("the post-destroy url") { @controller.send(:url_after_destroy) }
41   - end
42   -
43   - def should_redirect_to_url_already_confirmed
44   - should redirect_to("the already confirmed url") { @controller.send(:url_already_confirmed) }
45   - end
46   - end
47   -end
48   -
49   -module Clearance
50   - module Shoulda
51   - module Helpers
52   - def sign_in_as(user)
53   - @controller.current_user = user
54   - return user
55   - end
56   -
57   - def sign_in
58   - sign_in_as Factory(:email_confirmed_user)
59   - end
60   -
61   - def sign_out
62   - @controller.current_user = nil
63   - end
64   - end
65   - end
66   -end
67   -
68   -if defined?(Test::Unit::TestCase)
69   - class Test::Unit::TestCase
70   - include Clearance::Shoulda::Helpers
71   - end
72   - Test::Unit::TestCase.extend(Clearance::Shoulda)
73   -end
60 lib/clearance/test_matchers.rb
... ... @@ -0,0 +1,60 @@
  1 +module Clearance
  2 + module Test
  3 + module Matchers
  4 + def deny_access(opts = {})
  5 + if opts[:flash]
  6 + should set_the_flash.to(opts[:flash])
  7 + else
  8 + should_not set_the_flash
  9 + end
  10 +
  11 + redirect_to(sign_in_url)
  12 + end
  13 +
  14 + def redirect_to_url_after_create
  15 + redirect_to(@controller.send(:url_after_create))
  16 + end
  17 +
  18 + def redirect_to_url_after_update
  19 + redirect_to(@controller.send(:url_after_update))
  20 + end
  21 +
  22 + def redirect_to_url_after_destroy
  23 + redirect_to(@controller.send(:url_after_destroy))
  24 + end
  25 +
  26 + def redirect_to_url_already_confirmed
  27 + redirect_to(@controller.send(:url_already_confirmed))
  28 + end
  29 + end
  30 +
  31 + module Helpers
  32 + def sign_in_as(user)
  33 + @controller.current_user = user
  34 + return user
  35 + end
  36 +
  37 + def sign_in
  38 + sign_in_as Factory(:user)
  39 + end
  40 +
  41 + def sign_out
  42 + @controller.current_user = nil
  43 + end
  44 + end
  45 + end
  46 +end
  47 +
  48 +if defined?(Test::Unit::TestCase)
  49 + Test::Unit::TestCase.extend Clearance::Test::Matchers
  50 + class Test::Unit::TestCase
  51 + include Clearance::Test::Helpers
  52 + end
  53 +end
  54 +
  55 +if defined?(RSpec) && RSpec.respond_to?(:configure)
  56 + RSpec.configure do |config|
  57 + config.include Clearance::Test::Matchers
  58 + config.include Clearance::Test::Helpers
  59 + end
  60 +end
50 spec/spec_helper.rb
@@ -4,62 +4,16 @@
4 4 $LOAD_PATH << File.join(PROJECT_ROOT, "lib")
5 5
6 6 require 'rails/all'
  7 +require 'rails/test_help'
  8 +
7 9 Bundler.require
8 10
9 11 require 'diesel/testing'
10   -require 'rails/test_help'
11 12 require 'rspec/rails'
12 13
13   -require 'clearance'
14   -require 'clearance/shoulda_macros'
15   -
16   -Clearance.configure do |config|
17   -end
18   -
19   -class ApplicationController < ActionController::Base
20   - include Clearance::Authentication
21   -end
22   -
23   -class User < ActiveRecord::Base
24   - include Clearance::User
25   -end
26   -
27 14 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
28 15
29 16 RSpec.configure do |config|
30 17 config.mock_with :mocha
31 18 config.use_transactional_fixtures = true
32   - config.backtrace_clean_patterns << %r{gems/}
33 19 end
34   -
35   -# class ActiveSupport::TestCase
36   -# def self.should_set_cookie(name, value, should_expire_at)
37   -# description = "set a '#{name}' cookie to '#{value}'"
38   -# if should_expire_at
39   -# description << " expiring at #{should_expire_at}"
40   -# else
41   -# description << " with no expiration date (session cookie)"
42   -# end
43   -# should description do
44   -# assert_equal value, cookies[name]
45   -# # the following statement may be redundant with the preceding one, but can't hurt
46   -# assert_equal value, @response.cookies[name]
47   -# # cookies and @response[cookies] don't give us the expire time, so we need to fish it out 'manually'
48   -# set_cookie_headers = @response.headers['Set-Cookie']
49   -# assert_not_nil set_cookie_headers, "@response.headers['Set-Cookie'] must not be nil"
50   -# set_cookie_headers = [set_cookie_headers] if set_cookie_headers.respond_to?(:to_str)
51   -# regex = /^#{name}=#{value}(;|$)/
52   -# assert_contains set_cookie_headers, regex
53   -# cookie = set_cookie_headers.find {|h| h =~ regex}
54   -# regex = /; expires=(.*?)(;|$)/
55   -# if should_expire_at
56   -# assert_contains cookie, regex, "cookie does not contain an 'expires=' attribute"
57   -# cookie =~ regex
58   -# expires_at = Time.parse($1)
59   -# assert_in_delta should_expire_at, expires_at, 100 # number of seconds we don't expect the test suite to exceed
60   -# else
61   -# assert_does_not_contain cookie, regex, "cookie contains an 'expires=' attribute but it shouldn't"
62   -# end
63   -# end
64   -# end
65   -# end
18 spec/support/authorization.rb
... ... @@ -1,18 +0,0 @@
1   -module AuthorizationHelpers
2   - def sign_in_as(user)
3   - @controller.current_user = user
4   - return user
5   - end
6   -
7   - def sign_in
8   - sign_in_as Factory(:email_confirmed_user)
9   - end
10   -
11   - def sign_out
12   - @controller.current_user = nil
13   - end
14   -end
15   -
16   -RSpec.configure do |config|
17   - config.include AuthorizationHelpers
18   -end
12 spec/support/clearance.rb
... ... @@ -0,0 +1,12 @@
  1 +require 'clearance'
  2 +
  3 +Clearance.configure do |config|
  4 +end
  5 +
  6 +class ApplicationController < ActionController::Base
  7 + include Clearance::Authentication
  8 +end
  9 +
  10 +class User < ActiveRecord::Base
  11 + include Clearance::User
  12 +end
21 spec/support/clearance_redirects.rb
... ... @@ -1,21 +0,0 @@
1   -module ClearanceRedirectMatchers
2   - def redirect_to_url_after_create
3   - redirect_to(@controller.send(:url_after_create))
4   - end
5   -
6   - def redirect_to_url_after_update
7   - redirect_to(@controller.send(:url_after_update))
8   - end
9   -
10   - def redirect_to_url_after_destroy
11   - redirect_to(@controller.send(:url_after_destroy))
12   - end
13   -
14   - def redirect_to_url_already_confirmed
15   - redirect_to(@controller.send(:url_already_confirmed))
16   - end
17   -end
18   -
19   -RSpec.configure do |config|
20   - config.include ClearanceRedirectMatchers
21   -end

0 comments on commit 9358de8

Please sign in to comment.
Something went wrong with that request. Please try again.