Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
Added UserDecorator specs
Browse files Browse the repository at this point in the history
  • Loading branch information
LBRapid committed Jan 24, 2012
1 parent 686a24c commit 16bcc9e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
45 changes: 45 additions & 0 deletions spec/models/spree/user_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper'

describe Spree::User do
let(:user) { Factory(:user) }
let(:omni_params) { {"provider" => "twitter", "uid" => 12345} }
let(:auths) { mock "auths" }

context "#apply_omniauth" do
before { user.stub :user_authentications => auths }

it "should build an associated auth source" do
auths.should_receive(:build)
user.apply_omniauth(omni_params)
end
end

context "#password_required?" do
before { user.password = nil }

context "user authentications is empty" do
it "should be true" do
user.password_required?.should be_true
end
end

context "user authentications is not empty" do
before do
user.stub :user_authentications => auths
auths.stub(:empty?).and_return(false)
end

it "should be false" do
user.password_required?.should be_false
end
end

context "when the password has been set" do
before { user.password = "foobar" }

it "should be true" do
user.password_required?.should be_true
end
end
end
end
14 changes: 0 additions & 14 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require File.expand_path("../dummy/config/environment.rb", __FILE__)

require 'rspec/rails'

# Requires supporting ruby files with custom matchers and macros, etc,
Expand All @@ -13,18 +11,6 @@
require 'spree/core/testing_support/factories'

RSpec.configure do |config|
# == 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
config.mock_with :rspec

# 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.
Expand Down

0 comments on commit 16bcc9e

Please sign in to comment.