Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ gem 'spring-commands-teaspoon', group: :development
gem 'pageflow-theme-doc-publisher', git: 'https://github.com/tf/pageflow-theme-doc-publisher'

gem 'coveralls', require: false

# Early failure output
gem 'rspec-instafail', '~> 0.4.0', require: false
8 changes: 4 additions & 4 deletions pageflow.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ Gem::Specification.new do |s|
s.add_development_dependency 'mysql2', '~> 0.3.16'

# Testing framework
s.add_development_dependency 'rspec-rails', '~> 2.14'
s.add_development_dependency 'rspec-rails', '~> 3.4'

# Matchers like "to have(3).items"
s.add_development_dependency 'rspec-collection_matchers', '~> 1.1'

# Browser like integration testing
s.add_development_dependency 'capybara', '~> 2.4'
Expand All @@ -147,9 +150,6 @@ Gem::Specification.new do |s|
# Freeze time in tests
s.add_development_dependency 'timecop', '~> 0.7.1'

# Early failure output
s.add_development_dependency 'rspec-instafail', '~> 0.2.6'

# Colorized console output
s.add_development_dependency 'colorize', '~> 0.7.5'

Expand Down
2 changes: 1 addition & 1 deletion spec/models/pageflow/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module Pageflow
user = build(:user, :account_manager)
ability = Ability.new(user)

expect(ability.can?(:create, User)).to be_true
expect(ability.can?(:create, User)).to be true
end

it 'can read folders of own account' do
Expand Down
2 changes: 1 addition & 1 deletion spec/pageflow/seeds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module SeedsDsl
SeedsDsl.default_user_password('!Other123')
user = SeedsDsl.user(email: 'editor@example.com', account: create(:account))

expect(user.valid_password?('!Other123')).to be_true
expect(user.valid_password?('!Other123')).to be true
end

it 'allows overriding attributes in block' do
Expand Down
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Coveralls.wear!

require 'rspec/rails'
require 'rspec/collection_matchers'
require 'domino'

Dir[File.join(File.dirname(__FILE__), 'support/{config,dominos,helpers,matchers}/**/*.rb')].each { |file| require(file) }
Expand All @@ -15,5 +16,9 @@
config.use_transactional_fixtures = false

config.infer_base_class_for_anonymous_controllers = false
config.infer_spec_type_from_file_location!

config.example_status_persistence_file_path = './tmp/rspec_failures'

config.order = "random"
end
4 changes: 2 additions & 2 deletions spec/state_machines/pageflow/image_file_state_machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Pageflow

file.process

expect(file.reload.attachment.exists?(:thumbnail)).to be_true
expect(file.reload.attachment.exists?(:thumbnail)).to be true
end

it 'sets state to processed' do
Expand All @@ -35,7 +35,7 @@ module Pageflow

file.process

expect(file.reload.attachment.exists?(:thumbnail)).to be_true
expect(file.reload.attachment.exists?(:thumbnail)).to be true
end

it 'sets state to processed' do
Expand Down
5 changes: 1 addition & 4 deletions spec/support/helpers/view_component_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ def render(*args, &block)
end

RSpec.configure do |config|
config.include(ViewComponentExampleGroup,
:example_group => lambda { |example_group, metadata|
%r(spec/views/components) =~ example_group[:file_path]
})
config.include(ViewComponentExampleGroup, type: :view_component)
end
34 changes: 18 additions & 16 deletions spec/support/helpers/zencoder_api_double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,71 @@ module ZencoderApiDouble
def creating_job_with_id(id)
api = double

api.stub(:create_job).and_return(id)
allow(api).to receive(:create_job).and_return(id)

api
end

def finished
api = double

api.stub(:create_job).and_return(1)
api.stub(:get_info).and_return(finished_info_result)
api.stub(:get_input_details).and_return(input_details)
allow(api).to receive(:create_job).and_return(1)
allow(api).to receive(:get_info).and_return(finished_info_result)
allow(api).to receive(:get_input_details).and_return(input_details)

api
end

def finished_but_failed
api = double

api.stub(:create_job).and_return(1)
api.stub(:get_info).and_return(failed_info_result)
api.stub(:get_input_details).and_return(input_details)
allow(api).to receive(:create_job).and_return(1)
allow(api).to receive(:get_info).and_return(failed_info_result)
allow(api).to receive(:get_input_details).and_return(input_details)

api
end

def once_pending_then_finished
api = double

api.stub(:create_job).and_return(1)
api.stub(:get_info).and_return(pending_info_result, finished_info_result)
api.stub(:get_input_details).and_return(input_details)
allow(api).to receive(:create_job).and_return(1)
allow(api).to receive(:get_info).and_return(pending_info_result, finished_info_result)
allow(api).to receive(:get_input_details).and_return(input_details)

api
end

def pending(options = {})
api = double

api.stub(:create_job).and_return(1)
api.stub(:get_info).and_return(pending_info_result(options))
api.stub(:get_input_details).and_return(input_details)
allow(api).to receive(:create_job).and_return(1)
allow(api).to receive(:get_info).and_return(pending_info_result(options))
allow(api).to receive(:get_input_details).and_return(input_details)

api
end

def recoverably_failing
api = double

api.stub(:get_info).and_raise(Pageflow::ZencoderApi::RecoverableError)
allow(api).to receive(:get_info).and_raise(Pageflow::ZencoderApi::RecoverableError)

api
end

def unrecoverably_failing
api = double

api.stub(:get_info).and_raise(Pageflow::ZencoderApi::UnrecoverableError)
allow(api).to receive(:get_info).and_raise(Pageflow::ZencoderApi::UnrecoverableError)

api
end

private

def double
RSpec::Mocks::Mock.new('zencoder api')
RSpec::Mocks::Double.new('zencoder api')
end

def pending_info_result(options = {})
Expand All @@ -95,3 +95,5 @@ def input_details
:duration_in_ms => 5000 }
end
end

RSpec::Mocks::Syntax.enable_expect(ZencoderApiDouble)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'spec_helper'

module Pageflow
describe Admin::EmbeddedIndexTable do
describe Admin::EmbeddedIndexTable, type: :view_component do
before do
helper.extend(ActiveAdmin::ViewHelpers)
helper.stub(:url_for)
allow(helper).to receive(:url_for)
end

it 'renders table of entries' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

module Pageflow
describe Admin::GroupedFolderList do
describe Admin::GroupedFolderList, type: :view_component do
it 'renders all link' do
render([], :active_id => 3)

Expand Down
8 changes: 4 additions & 4 deletions spec/views/components/pageflow/admin/tabs_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Pageflow
module Admin
describe TabsView do
describe TabsView, type: :view_component do
let(:tab_view_component) do
Class.new(ViewComponent) do
def self.name
Expand Down Expand Up @@ -98,7 +98,7 @@ def build(custom)
it 'does not render links for tabs we are not authorized for' do
tabs = [{name: :some_tab, component: tab_view_component}]

helper.stub(:authorized?) { false }
allow(helper).to receive(:authorized?) { false }

render(tabs, authorize: true)

Expand All @@ -108,7 +108,7 @@ def build(custom)
it 'renders links for tabs we are authorized for' do
tabs = [{name: :some_tab, component: tab_view_component}]

helper.stub(:authorized?) { true }
allow(helper).to receive(:authorized?) { true }

render(tabs, authorize: true)

Expand All @@ -118,7 +118,7 @@ def build(custom)
it 'passes :view action and component class to authorized? method' do
tabs = [{name: :some_tab, component: tab_view_component}]

helper.stub(:authorized?) { true }
allow(helper).to receive(:authorized?) { true }

render(tabs, authorize: true)

Expand Down