Skip to content

Commit

Permalink
add spec and remove some germs
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair Anderson committed Mar 13, 2015
1 parent c7ae7fc commit 0008238
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/requests/items_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0008238

Please sign in to comment.