Actually use spec_helper, lol

footer-fixes
Marcin Kulik 10 years ago
parent 411540d690
commit 96e30031b2

@ -176,6 +176,14 @@ describe AsciicastDecorator do
let(:snapshot) { double('snapshot', :thumbnail => thumbnail) }
let(:thumbnail) { double('thumbnail') }
before do
RSpec::Mocks.configuration.verify_partial_doubles = false # for stubbing "helpers"
end
after do
RSpec::Mocks.configuration.verify_partial_doubles = true
end
before do
allow(asciicast).to receive(:snapshot) { json }
allow(Snapshot).to receive(:build).with(json) { snapshot }

@ -9,10 +9,18 @@ describe UserDecorator do
let(:user) { User.new(username: 'satyr') }
before do
RSpec::Mocks.configuration.verify_partial_doubles = false # for stubbing "h"
end
before do
allow(h).to receive(:profile_path).with(user) { '/path' }
end
after do
RSpec::Mocks.configuration.verify_partial_doubles = true
end
context "when user is real" do
before do
user.dummy = false
@ -39,11 +47,19 @@ describe UserDecorator do
let(:user) { User.new(username: 'satyr') }
before do
RSpec::Mocks.configuration.verify_partial_doubles = false # for stubbing "h"
end
before do
allow(h).to receive(:profile_path).with(user) { '/path' }
allow(decorator).to receive(:avatar_image_tag) { '<img ...>'.html_safe }
end
after do
RSpec::Mocks.configuration.verify_partial_doubles = true
end
context "when user is real" do
before do
user.dummy = false

@ -25,7 +25,7 @@ describe AsciicastPagePresenter do
end
let(:presenter) { described_class.new(asciicast, current_user, policy, nil) }
let(:asciicast) { stub_model(Asciicast, user: author) }
let(:asciicast) { stub_model(Asciicast, user: author).decorate }
let(:current_user) { User.new }
let(:policy) { double('policy') }
let(:author) { User.new }
@ -113,16 +113,13 @@ describe AsciicastPagePresenter do
describe '#embed_script' do
subject { presenter.embed_script(view_context) }
let(:asciicast) { stub_model(Asciicast, id: 123).decorate }
let(:src_regexp) { /src="[^"]+\b123\b[^"]*\.js"/ }
let(:id_regexp) { /id="asciicast-123"/ }
let(:script_regexp) {
/^<script[^>]+#{src_regexp}[^>]+#{id_regexp}[^>]*><\/script>/
}
before do
allow(asciicast).to receive(:id).and_return(123)
end
it 'is an async script tag including asciicast id' do
expect(subject).to match(script_regexp)
end

@ -46,7 +46,7 @@ describe UserPagePresenter do
let(:presenter) { described_class.new(user, current_user, policy, page,
per_page) }
let(:user) { stub_model(User, username: 'cartman') }
let(:user) { stub_model(User, username: 'cartman').decorate }
let(:current_user) { stub_model(User) }
let(:policy) { double('policy') }
let(:page) { 2 }

@ -1,3 +1,7 @@
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
if ENV["CI"] && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
require 'simplecov'
require 'coveralls'
@ -9,7 +13,6 @@ if ENV["CI"] && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
end
end
ENV["RAILS_ENV"] ||= 'test'
ENV['CARRIERWAVE_STORAGE_DIR_PREFIX'] ||= 'uploads/test/'
require File.expand_path("../../config/environment", __FILE__)

Loading…
Cancel
Save