diff --git a/Gemfile b/Gemfile index df2ea92..03c7d1d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ source 'https://rubygems.org' gem 'active_model_serializers' gem 'active_api', github: 'blairanderson/active_api' +# gem 'active_api', path: '../active_api' gem 'jquery-rails' gem 'pg' @@ -23,16 +24,17 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' - gem 'swagger-docs' - gem 'factory_girl_rails' gem 'faker' gem 'rspec-rails', '~> 3.0' # https://github.com/rspec/rspec-rails gem 'rspec_api_documentation' # https://github.com/zipmark/rspec_api_documentation + gem 'shoulda-matchers' + + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' end diff --git a/Gemfile.lock b/Gemfile.lock index a228a57..d784f39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/blairanderson/active_api.git - revision: 0a00c5f0fdd4a1df4b9da0607b35cff5b9118e3e + revision: 3a842f983dcb01e6f2e84e5924c5f7f014732290 specs: active_api (0.0.1) active_model_serializers @@ -101,10 +101,10 @@ GEM rack-accept rack-mount virtus (>= 1.0.0) - grape-entity (0.4.4) + grape-entity (0.4.5) activesupport multi_json (>= 1.3.2) - grape-swagger (0.9.0) + grape-swagger (0.10.1) grape (>= 0.8.0) grape-entity grape-swagger-rails (0.1.0) @@ -210,6 +210,8 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (~> 1.1) + shoulda-matchers (2.8.0) + activesupport (>= 3.0.0) simple_form (3.1.0) actionpack (~> 4.0) activemodel (~> 4.0) @@ -228,9 +230,6 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - swagger-docs (0.1.9) - activesupport (>= 3, < 5) - rails (>= 3, < 5) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) @@ -272,10 +271,10 @@ DEPENDENCIES rspec-rails (~> 3.0) rspec_api_documentation sass-rails (~> 5.0) + shoulda-matchers simple_form sorcery (= 0.9.0) spring - swagger-docs turbolinks uglifier (>= 1.3.0) validate_url diff --git a/spec/requests/items_spec.rb b/spec/requests/items_spec.rb index f2848e2..7aa3bc3 100644 --- a/spec/requests/items_spec.rb +++ b/spec/requests/items_spec.rb @@ -12,6 +12,17 @@ expect(response).to be_success # test for the 200 status-code expect(json['items'].length).to eq(length) # check to make sure the right amount of messages are returned end + + it 'gets authenticated items' do + user = FactoryGirl.create(:user) + expected_number = 4 + FactoryGirl.create_list(:item, expected_number, user: user) + FactoryGirl.create_list(:item, rand(1..20)) + + get active_api_path + "items", nil, {'Authorization' => "Token token=#{user.token}"} + expect(response).to be_success + expect(json['items'].length).to eq(expected_number) + end end describe "GET /items/:id" do