cathode 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cathode/_version.rb +1 -1
- data/spec/dummy/config/database.travis.yml +20 -0
- data/spec/dummy/config/database.yml +9 -20
- data/spec/dummy/log/development.log +241 -0
- data/spec/dummy/log/test.log +31895 -0
- data/spec/dummy/spec/requests/requests_spec.rb +21 -19
- data/spec/lib/cathode/show_request_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -4
- data/spec/support/factories/products.rb +5 -1
- metadata +5 -17
| @@ -4,7 +4,9 @@ def make_request(method, path, params = nil, version = '1.0.0') | |
| 4 4 | 
             
              send(method, path, params,  'Accept-Version' => version)
         | 
| 5 5 | 
             
            end
         | 
| 6 6 |  | 
| 7 | 
            -
            def request_spec(method,  | 
| 7 | 
            +
            def request_spec(method, pre_path, params = nil, &block)
         | 
| 8 | 
            +
              let(:path) { pre_path.is_a?(String) ? pre_path : instance_eval(&pre_path) }
         | 
| 9 | 
            +
             | 
| 8 10 | 
             
              context 'without version header' do
         | 
| 9 11 | 
             
                subject { send(method, path, params) }
         | 
| 10 12 |  | 
| @@ -42,7 +44,7 @@ describe 'API' do | |
| 42 44 |  | 
| 43 45 | 
             
                it 'makes a request' do
         | 
| 44 46 | 
             
                  make_request :get, 'api/products'
         | 
| 45 | 
            -
                  expect(response.body).to eq(products. | 
| 47 | 
            +
                  expect(JSON.parse(response.body).map { |i| i['title'] }).to eq(products.map(&:title))
         | 
| 46 48 | 
             
                end
         | 
| 47 49 | 
             
              end
         | 
| 48 50 |  | 
| @@ -67,16 +69,16 @@ describe 'API' do | |
| 67 69 | 
             
                    request_spec :get, 'api/products', nil do
         | 
| 68 70 | 
             
                      it 'responds with all records' do
         | 
| 69 71 | 
             
                        subject
         | 
| 70 | 
            -
                        expect(response.body).to eq(products. | 
| 72 | 
            +
                        expect(JSON.parse(response.body).map { |i| i['title'] }).to eq(products.map(&:title))
         | 
| 71 73 | 
             
                      end
         | 
| 72 74 | 
             
                    end
         | 
| 73 75 | 
             
                  end
         | 
| 74 76 |  | 
| 75 77 | 
             
                  describe 'show' do
         | 
| 76 | 
            -
                    request_spec :get,  | 
| 78 | 
            +
                    request_spec :get, proc { "api/products/#{products.first.id}" } do
         | 
| 77 79 | 
             
                      it 'responds with all records' do
         | 
| 78 80 | 
             
                        subject
         | 
| 79 | 
            -
                        expect(response.body).to eq(products.first. | 
| 81 | 
            +
                        expect(JSON.parse(response.body)['title']).to eq(products.first.title)
         | 
| 80 82 | 
             
                      end
         | 
| 81 83 | 
             
                    end
         | 
| 82 84 | 
             
                  end
         | 
| @@ -93,7 +95,7 @@ describe 'API' do | |
| 93 95 | 
             
                  end
         | 
| 94 96 |  | 
| 95 97 | 
             
                  describe 'update' do
         | 
| 96 | 
            -
                    request_spec :put,  | 
| 98 | 
            +
                    request_spec :put, proc { "api/products/#{products.first.id}" }, product: { title: 'goodbye' } do
         | 
| 97 99 | 
             
                      it 'responds with the updated record' do
         | 
| 98 100 | 
             
                        subject
         | 
| 99 101 | 
             
                        expect(JSON.parse(response.body)['title']).to eq('goodbye')
         | 
| @@ -102,7 +104,7 @@ describe 'API' do | |
| 102 104 | 
             
                  end
         | 
| 103 105 |  | 
| 104 106 | 
             
                  describe 'destroy' do
         | 
| 105 | 
            -
                    request_spec :delete,  | 
| 107 | 
            +
                    request_spec :delete, proc { "api/products/#{products.last.id}" } do
         | 
| 106 108 | 
             
                      it 'responds with success' do
         | 
| 107 109 | 
             
                        expect(subject).to eq(200)
         | 
| 108 110 | 
             
                      end
         | 
| @@ -140,7 +142,7 @@ describe 'API' do | |
| 140 142 | 
             
                  make_request :get, 'api/products', nil, '1.0'
         | 
| 141 143 | 
             
                  expect(response.status).to eq(200)
         | 
| 142 144 |  | 
| 143 | 
            -
                  make_request :get,  | 
| 145 | 
            +
                  make_request :get, "api/products/#{product.id}", nil, '1.0'
         | 
| 144 146 | 
             
                  expect(response.status).to eq(200)
         | 
| 145 147 |  | 
| 146 148 | 
             
                  make_request :get, 'api/sales', nil, '1.0'
         | 
| @@ -152,7 +154,7 @@ describe 'API' do | |
| 152 154 | 
             
                  make_request :get, 'api/sales', nil, '1.1.0'
         | 
| 153 155 | 
             
                  expect(response.status).to eq(404)
         | 
| 154 156 |  | 
| 155 | 
            -
                  make_request :get,  | 
| 157 | 
            +
                  make_request :get, "api/products/#{product.id}", nil, '1.1.0'
         | 
| 156 158 | 
             
                  expect(response.status).to eq(200)
         | 
| 157 159 |  | 
| 158 160 | 
             
                  make_request :get, 'api/products', nil, '1.1.0'
         | 
| @@ -257,7 +259,7 @@ describe 'API' do | |
| 257 259 |  | 
| 258 260 | 
             
                context 'with has_many association' do
         | 
| 259 261 | 
             
                  it 'uses the associations to get the records' do
         | 
| 260 | 
            -
                    make_request :get,  | 
| 262 | 
            +
                    make_request :get, "api/products/#{product.id}/sales"
         | 
| 261 263 | 
             
                    expect(response.status).to eq(200)
         | 
| 262 264 | 
             
                    expect(response.body).to eq(Sale.all.to_json)
         | 
| 263 265 | 
             
                  end
         | 
| @@ -265,29 +267,29 @@ describe 'API' do | |
| 265 267 |  | 
| 266 268 | 
             
                context 'with has_one association' do
         | 
| 267 269 | 
             
                  context ':show' do
         | 
| 268 | 
            -
                    let!(:payment) { create(:payment, sale: sale) }
         | 
| 270 | 
            +
                    let!(:payment) { create(:payment, amount: 323, sale: sale) }
         | 
| 269 271 |  | 
| 270 272 | 
             
                    it 'gets the association record' do
         | 
| 271 | 
            -
                      make_request :get,  | 
| 273 | 
            +
                      make_request :get, "api/sales/#{sale.id}/payment"
         | 
| 272 274 | 
             
                      expect(response.status).to eq(200)
         | 
| 273 | 
            -
                      expect(response.body).to eq( | 
| 275 | 
            +
                      expect(JSON.parse(response.body)['amount']).to eq(323)
         | 
| 274 276 | 
             
                    end
         | 
| 275 277 | 
             
                  end
         | 
| 276 278 |  | 
| 277 279 | 
             
                  context ':create' do
         | 
| 278 | 
            -
                    subject { make_request :post,  | 
| 280 | 
            +
                    subject { make_request :post, "api/sales/#{sale.id}/payment", { payment: { amount: 500 } } }
         | 
| 279 281 |  | 
| 280 282 | 
             
                    it 'adds a new record associated with the parent' do
         | 
| 281 283 | 
             
                      expect { subject }.to change(Payment, :count).by(1)
         | 
| 282 284 | 
             
                      expect(Payment.last.sale).to eq(sale)
         | 
| 283 285 | 
             
                      expect(response.status).to eq(200)
         | 
| 284 | 
            -
                      expect(response.body).to eq( | 
| 286 | 
            +
                      expect(JSON.parse(response.body)['amount']).to eq(500)
         | 
| 285 287 | 
             
                    end
         | 
| 286 288 | 
             
                  end
         | 
| 287 289 |  | 
| 288 290 | 
             
                  context ':update' do
         | 
| 289 291 | 
             
                    let!(:payment) { create(:payment, amount: 200, sale: sale) }
         | 
| 290 | 
            -
                    subject { make_request :put,  | 
| 292 | 
            +
                    subject { make_request :put, "api/sales/#{sale.id}/payment", { payment: { amount: 500 } } }
         | 
| 291 293 |  | 
| 292 294 | 
             
                    it 'updates the associated record' do
         | 
| 293 295 | 
             
                      expect { subject }.to_not change(Payment, :count).by(1)
         | 
| @@ -298,7 +300,7 @@ describe 'API' do | |
| 298 300 |  | 
| 299 301 | 
             
                  context ':destroy' do
         | 
| 300 302 | 
             
                    let!(:payment) { create(:payment, amount: 200, sale: sale) }
         | 
| 301 | 
            -
                    subject { make_request :delete,  | 
| 303 | 
            +
                    subject { make_request :delete, "api/sales/#{sale.id}/payment" }
         | 
| 302 304 |  | 
| 303 305 | 
             
                    it 'deletes the associated record' do
         | 
| 304 306 | 
             
                      expect { subject }.to change(Payment, :count).by(-1)
         | 
| @@ -313,9 +315,9 @@ describe 'API' do | |
| 313 315 | 
             
                    let!(:payment) { create(:payment, sale: sale) }
         | 
| 314 316 |  | 
| 315 317 | 
             
                    it 'gets the association record' do
         | 
| 316 | 
            -
                      make_request :get,  | 
| 318 | 
            +
                      make_request :get, "api/payments/#{payment.id}/sale"
         | 
| 317 319 | 
             
                      expect(response.status).to eq(200)
         | 
| 318 | 
            -
                      expect(response.body).to eq( | 
| 320 | 
            +
                      expect(JSON.parse(response.body)['product_id']).to eq(product.id)
         | 
| 319 321 | 
             
                    end
         | 
| 320 322 | 
             
                  end
         | 
| 321 323 | 
             
                end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,14 +1,11 @@ | |
| 1 1 | 
             
            ENV['RAILS_ENV'] ||= 'test'
         | 
| 2 2 |  | 
| 3 | 
            -
            require 'coveralls'
         | 
| 4 | 
            -
            Coveralls.wear!
         | 
| 5 | 
            -
             | 
| 6 3 | 
             
            require File.expand_path('../dummy/config/environment.rb',  __FILE__)
         | 
| 7 4 | 
             
            require 'rspec/rails'
         | 
| 8 5 | 
             
            require 'rspec/autorun'
         | 
| 9 6 | 
             
            require 'factory_girl_rails'
         | 
| 10 7 | 
             
            require 'timecop'
         | 
| 11 | 
            -
            require 'pry'
         | 
| 8 | 
            +
            require 'pry' if Gem::Specification::find_all_by_name('pry').any?
         | 
| 12 9 |  | 
| 13 10 | 
             
            Rails.backtrace_cleaner.remove_silencers!
         | 
| 14 11 |  | 
| @@ -24,6 +21,8 @@ RSpec.configure do |config| | |
| 24 21 | 
             
              config.include FactoryGirl::Syntax::Methods
         | 
| 25 22 | 
             
              config.include SpecHelpers
         | 
| 26 23 |  | 
| 24 | 
            +
              puts "Testing against database adapter: #{ActiveRecord::Base.connection_config[:adapter]}"
         | 
| 25 | 
            +
             | 
| 27 26 | 
             
              config.after(:each) do
         | 
| 28 27 | 
             
                Cathode::BaseController.subclasses.each do |controller|
         | 
| 29 28 | 
             
                  name = controller.name.try(:demodulize)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cathode
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Moby, Inc.
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-04- | 
| 11 | 
            +
            date: 2014-04-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rack-cors
         | 
| @@ -150,20 +150,6 @@ dependencies: | |
| 150 150 | 
             
                - - ~>
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 152 | 
             
                    version: 0.20.1
         | 
| 153 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            -
              name: sqlite3
         | 
| 155 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            -
                requirements:
         | 
| 157 | 
            -
                - - ~>
         | 
| 158 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            -
                    version: 1.3.9
         | 
| 160 | 
            -
              type: :development
         | 
| 161 | 
            -
              prerelease: false
         | 
| 162 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            -
                requirements:
         | 
| 164 | 
            -
                - - ~>
         | 
| 165 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            -
                    version: 1.3.9
         | 
| 167 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 168 154 | 
             
              name: timecop
         | 
| 169 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -247,6 +233,7 @@ files: | |
| 247 233 | 
             
            - spec/dummy/bin/rake
         | 
| 248 234 | 
             
            - spec/dummy/config/application.rb
         | 
| 249 235 | 
             
            - spec/dummy/config/boot.rb
         | 
| 236 | 
            +
            - spec/dummy/config/database.travis.yml
         | 
| 250 237 | 
             
            - spec/dummy/config/database.yml
         | 
| 251 238 | 
             
            - spec/dummy/config/environment.rb
         | 
| 252 239 | 
             
            - spec/dummy/config/environments/development.rb
         | 
| @@ -316,7 +303,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 316 303 | 
             
              requirements:
         | 
| 317 304 | 
             
              - - '>='
         | 
| 318 305 | 
             
                - !ruby/object:Gem::Version
         | 
| 319 | 
            -
                  version:  | 
| 306 | 
            +
                  version: 1.9.3
         | 
| 320 307 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 321 308 | 
             
              requirements:
         | 
| 322 309 | 
             
              - - '>='
         | 
| @@ -344,6 +331,7 @@ test_files: | |
| 344 331 | 
             
            - spec/dummy/bin/rake
         | 
| 345 332 | 
             
            - spec/dummy/config/application.rb
         | 
| 346 333 | 
             
            - spec/dummy/config/boot.rb
         | 
| 334 | 
            +
            - spec/dummy/config/database.travis.yml
         | 
| 347 335 | 
             
            - spec/dummy/config/database.yml
         | 
| 348 336 | 
             
            - spec/dummy/config/environment.rb
         | 
| 349 337 | 
             
            - spec/dummy/config/environments/development.rb
         |