Last active
December 12, 2015 01:38
-
-
Save totallymike/4692661 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe CategoriesController do | |
def valid_attributes | |
{ "name" => "MyString" } | |
end | |
def valid_session | |
{} | |
end | |
describe "POST create" do | |
fixtures :users | |
let (:user) { users(:miketheboss) } | |
describe "user loading" do | |
it "should load the damned user" do | |
user.username.should eq "miketheboss" | |
end | |
end | |
describe "role authorization" do | |
it "prevents non-administrators from creating new categories" do | |
login_user user | |
post :create, {:category => valid_attributes} | |
response.should render_template 'New' | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rack::File headers parameter replaces cache_control after Rack 1.5. | |
.F | |
Failures: | |
1) CategoriesController POST create role authorization prevents non-administrators from creating new categories | |
Failure/Error: let (:user) { users(:miketheboss) } | |
ActiveRecord::RecordNotFound: | |
Couldn't find User with id=702598363 | |
# ./spec/controllers/categories_controller_spec.rb:15:in `block (3 levels) in <top (required)>' | |
# ./spec/controllers/categories_controller_spec.rb:25:in `block (4 levels) in <top (required)>' | |
Finished in 1.23 seconds | |
2 examples, 1 failure | |
Failed examples: | |
rspec ./spec/controllers/categories_controller_spec.rb:24 # CategoriesController POST create role authorization prevents non-administrators from creating new categories | |
Randomized with seed 44970 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FF | |
Failures: | |
1) CategoriesController POST create role authorization prevents non-administrators from creating new categories | |
Failure/Error: login_user user | |
NoMethodError: | |
undefined method `username_attribute_names' for nil:NilClass | |
# ./spec/controllers/categories_controller_spec.rb:25:in `block (4 levels) in <top (required)>' | |
2) CategoriesController POST create user loading should load the damned user | |
Failure/Error: let (:user) { users(:miketheboss) } | |
ActiveRecord::RecordNotFound: | |
Couldn't find User with id=702598363 | |
# ./spec/controllers/categories_controller_spec.rb:15:in `block (3 levels) in <top (required)>' | |
# ./spec/controllers/categories_controller_spec.rb:19:in `block (4 levels) in <top (required)>' | |
Finished in 1.22 seconds | |
2 examples, 2 failures | |
Failed examples: | |
rspec ./spec/controllers/categories_controller_spec.rb:24 # CategoriesController POST create role authorization prevents non-administrators from creating new categories | |
rspec ./spec/controllers/categories_controller_spec.rb:18 # CategoriesController POST create user loading should load the damned user | |
Randomized with seed 17596 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is copied to spec/ when you run 'rails generate rspec:install' | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'email_spec' | |
require 'rspec/autorun' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
RSpec.configure do |config| | |
config.include(EmailSpec::Helpers) | |
config.include(EmailSpec::Matchers) | |
config.include(Sorcery::TestHelpers::Rails) | |
# ## Mock Framework | |
# | |
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: | |
# | |
# config.mock_with :mocha | |
# config.mock_with :flexmock | |
# config.mock_with :rr | |
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
# If you're not using ActiveRecord, or you'd prefer not to run each of your | |
# examples within a transaction, remove the following line or assign false | |
# instead of true. | |
config.use_transactional_fixtures = true | |
# If true, the base class of anonymous controllers will be inferred | |
# automatically. This will be the default behavior in future versions of | |
# rspec-rails. | |
config.infer_base_class_for_anonymous_controllers = false | |
# Run specs in random order to surface order dependencies. If you find an | |
# order dependency and want to debug it, you can fix the order by providing | |
# the seed, which is printed after each run. | |
# --seed 1234 | |
config.order = "random" | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
miketheboss: | |
username: miketheboss | |
email: [email protected] | |
salt: <%= salt = "eucenuteouh282" %> | |
crypted_password: <%= Sorcery::CryptoProviders::BCrypt.encrypt("secret", salt) %> | |
type: Admin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment