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
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ gemspec
gem 'appraisal'
gem 'rake'
gem 'rspec', '~> 3.6'
gem 'rspec-collection_matchers'
gem 'rspec-its'
gem 'webmock', '~> 3.0'

gem 'rake-release', '~> 1.0'
Expand Down
2 changes: 0 additions & 2 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
gem "rspec-its"
gem "webmock", "~> 3.0"
gem "rake-release", "~> 1.0"
gem "activesupport", "~> 7.2.0"
Expand Down
2 changes: 0 additions & 2 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
gem "rspec-its"
gem "webmock", "~> 3.0"
gem "rake-release", "~> 1.0"
gem "activesupport", "~> 8.0.0"
Expand Down
2 changes: 0 additions & 2 deletions gemfiles/rails_8.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
gem "rspec-its"
gem "webmock", "~> 3.0"
gem "rake-release", "~> 1.0"
gem "activesupport", "~> 8.1.0"
Expand Down
2 changes: 0 additions & 2 deletions gemfiles/rails_master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ source "https://rubygems.org"
gem "appraisal"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
gem "rspec-its"
gem "webmock", "~> 3.0"
gem "rake-release", "~> 1.0"
gem "activesupport", github: "rails/rails"
Expand Down
26 changes: 16 additions & 10 deletions spec/acfs/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:model) { MyUser }

describe 'Pagination' do
subject do
subject(:res) do
Acfs.run
collection
end
Expand All @@ -24,9 +24,11 @@
},)
end

its(:total_pages) { is_expected.to eq 2 }
its(:current_page) { is_expected.to eq 1 }
its(:total_count) { is_expected.to eq 10 }
it 'exposes pagination headers', :aggregate_failures do
expect(res.total_pages).to eq 2
expect(res.current_page).to eq 1
expect(res.total_count).to eq 10
end
end

context 'with page parameter' do
Expand All @@ -41,9 +43,11 @@
},)
end

its(:total_pages) { is_expected.to eq 2 }
its(:current_page) { is_expected.to eq 2 }
its(:total_count) { is_expected.to eq 10 }
it 'exposes pagination headers', :aggregate_failures do
expect(res.total_pages).to eq 2
expect(res.current_page).to eq 2
expect(res.total_count).to eq 10
end
end

context 'with non-numerical page parameter' do
Expand All @@ -58,9 +62,11 @@
},)
end

its(:total_pages) { is_expected.to eq 2 }
its(:current_page) { is_expected.to eq 'e546f5' }
its(:total_count) { is_expected.to eq 10 }
it 'exposes pagination headers', :aggregate_failures do
expect(res.total_pages).to eq 2
expect(res.current_page).to eq 'e546f5'
expect(res.total_count).to eq 10
end
end

describe '#next_page' do
Expand Down
4 changes: 2 additions & 2 deletions spec/acfs/global_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def events

it 'triggers event' do
Acfs.run
expect(collector.events).to have(1).items
expect(collector.events.size).to eq(1)
end
end

Expand All @@ -42,7 +42,7 @@ def events

it 'triggers event' do
Acfs.reset
expect(collector.events).to have(1).items
expect(collector.events.size).to eq(1)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/acfs/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
let(:operation) { described_class.new MyUser, :read, params: {id: 0} }

describe '#request' do
subject { operation.request }
subject(:op_request) { operation.request }

its(:operation) { is_expected.to eq operation }
it { expect(op_request.operation).to eq operation }
end
end
4 changes: 2 additions & 2 deletions spec/acfs/request/callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
it 'stores a given callback' do
request.on_complete(&callback)

expect(request.callbacks).to have(1).item
expect(request.callbacks.size).to eq(1)
expect(request.callbacks[0]).to eq callback
end

it 'stores multiple callback' do
request.on_complete {|_res| 'abc' }
request.on_complete(&callback)

expect(request.callbacks).to have(2).item
expect(request.callbacks.size).to eq(2)
expect(request.callbacks[0]).to eq callback
end
end
Expand Down
16 changes: 5 additions & 11 deletions spec/acfs/resource/locatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,31 @@
context ':list location' do
let(:action) { :list }

its(:raw_uri) do
is_expected.to eq 'http://users.example.org/users/:user_id/sessions'
end
it { expect(location.raw_uri).to eq 'http://users.example.org/users/:user_id/sessions' }
end

context ':create location' do
let(:action) { :create }

its(:raw_uri) { is_expected.to eq 'http://users.example.org/sessions' }
it { expect(location.raw_uri).to eq 'http://users.example.org/sessions' }
end

context ':read location' do
let(:action) { :read }

its(:raw_uri) { is_expected.to eq 'http://users.example.org/sessions/:id' }
it { expect(location.raw_uri).to eq 'http://users.example.org/sessions/:id' }
end

context ':update location' do
let(:action) { :update }

its(:raw_uri) do
expect { location }.to raise_error ArgumentError, /update.*disabled/
end
it { expect { location }.to raise_error ArgumentError, /update.*disabled/ }
end

context ':delete location' do
let(:action) { :delete }

its(:raw_uri) do
is_expected.to eq 'http://users.example.org/users/:user_id/sessions/del/:id'
end
it { expect(location.raw_uri).to eq 'http://users.example.org/users/:user_id/sessions/del/:id' }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acfs/resource/query_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
Acfs.run

expect(computers).to be_loaded
expect(computers).to have(3).items
expect(computers.size).to eq(3)
expect(computers[0]).to be_a PC
expect(computers[1]).to be_a Computer
expect(computers[2]).to be_a Mac
Expand Down
7 changes: 3 additions & 4 deletions spec/acfs/resource/validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@

before { model.valid? }

it { is_expected.not_to be_empty }
it { is_expected.to have(2).items }

it 'contains a list of error messages' do
it 'contains expected errors', :aggregate_failures do
expect(errors).not_to be_empty
expect(errors.size).to eq(2)
expect(errors.to_hash).to eq age: ["can't be blank"], name: ['is invalid']
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/acfs/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ def events
describe '#process' do
it 'triggers event' do
runner.process Acfs::Operation.new MyUser, :read, params: {id: 0}
expect(collector.events).to have(1).items
expect(collector2.events).to have(1).items
expect(collector.events.size).to eq(1)
expect(collector2.events.size).to eq(1)
end
end

describe '#run' do
it 'triggers event' do
runner.run Acfs::Operation.new MyUser, :read, params: {id: 0}
expect(collector.events).to have(1).items
expect(collector2.events).to have(0).items
expect(collector.events.size).to eq(1)
expect(collector2.events.size).to eq(0)
end
end

describe '#enqueue' do
it 'triggers event' do
runner.enqueue Acfs::Operation.new MyUser, :read, params: {id: 0}
expect(collector.events).to have(1).items
expect(collector2.events).to have(0).items
expect(collector.events.size).to eq(1)
expect(collector2.events.size).to eq(0)
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions spec/acfs/stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class SpecialCustomError < StandardError; end
users = MyUser.all
Acfs.run

expect(users).to have(2).items
expect(users.size).to eq(2)
end

it 'returns defined resources' do
Expand Down Expand Up @@ -169,7 +169,7 @@ class SpecialCustomError < StandardError; end
end

context 'with header' do
subject do
subject(:comments_result) do
Acfs.run
comments
end
Expand All @@ -188,8 +188,10 @@ class SpecialCustomError < StandardError; end
}
end

its(:total_pages) { is_expected.to eq 2 }
its(:total_count) { is_expected.to eq 10 }
it 'exposes pagination headers', :aggregate_failures do
expect(comments_result.total_pages).to eq 2
expect(comments_result.total_count).to eq 10
end
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/acfs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
Acfs.run

expect(users).to be_loaded
expect(users).to have(3).items
expect(users.size).to eq(3)

expect(users[0].id).to eq 2
expect(users[0].name).to eq 'John'
Expand All @@ -181,7 +181,7 @@
Acfs.run

expect(users).to be_loaded
expect(users).to have(2).items
expect(users.size).to eq(2)
expect(users[0].name).to eq 'Anon'
expect(users[0].age).to eq 12
expect(users[1].name).to eq 'John'
Expand All @@ -201,7 +201,7 @@
expect(user.name).to eq 'John'
expect(user.age).to eq 26

expect(friends).to have(1).items
expect(friends.size).to eq(1)
end

it 'loads associated resources from different service' do
Expand All @@ -218,6 +218,6 @@
expect(user.name).to eq 'John'
expect(user.age).to eq 26

expect(comments).to have(2).items
expect(comments.size).to eq(2)
end
end