plexus / yaks

Ruby library for building hypermedia APIs
http://rubygems.org/gems/yaks
MIT License
236 stars 26 forks source link

Add specs for Yaks::Sinatra, classic and modular #105

Closed fidothe closed 9 years ago

fidothe commented 9 years ago

These are simple specs: they verify that for a given Accept header, a trivial Sinatra app with a trivial set of Yaks mappers will return a viable response with the correct mime type and explicit charset. Both a modular and a 'classic' Sinatra app are tested.

The MediaType class in spec/integration_helper.rb uses the HTTP spec's definition of the Content-Type header (and other media type headers) to parse a media type string and extract type and parameter parts. It's not ludicrous-real-world-example proof, but it should be more than enough for good-faith attempts at spec adherence of the kind expected from Sinatra and from Yaks.

This commit also remodels the Yaks::Sinatra namespace so that it's Yaks::Sinatra and not Sinatra::Yaks. Auto-registration for classic apps is verified, as is explicit registration for modular apps.

Notes are added to the README regarding correct usage in both classic and modular modes.

Files are Rubocop checked.

plexus commented 9 years ago

:heart_eyes:

Getting some timeouts on Travis installing gems. I restarted the build.

janko commented 9 years ago

Apparently the latest version of Mutant (0.8.0) requires Ruby >= 2.1.

plexus commented 9 years ago

And rspec 3.3. I'm fine with pinning mutant to ~> 0.7.0 for the time being until we get a chance to upgrade. Ruby 2.1 shouldn't be a big issue as it's enough to run mutant against the latest stable MRI, but I haven't looked yet at how involved upgrading RSpec would be.

fidothe commented 9 years ago

What's the issue with RSpec? I just got whatever came down when I bundle installed (all the tests pass locally on 2.2)

plexus commented 9 years ago

Never mind. There doesn't seem to be a real issue. Latest mutant relies on RSpec 3.3, and I wasn't sure if we were already 3.3-compatible. It seems things run fine though, just a few new warnings.

@janko-m is right though, the issue with the failing tests is that all builds in the matrix try to install mutant, but on Ruby < 2.1 that fails.

I just pushed an update to master, could you try rebasing?

fidothe commented 9 years ago

ha, i just committed essentially the same changes, except that I also stopped generating the mutant rake task on Ruby < 2.2. will pull your changes and revise my version number down in the rakelib file

fidothe commented 9 years ago

Rebased and passing the tests :-)

plexus commented 9 years ago

Ugh now I need to find an original gif :P

plexus commented 9 years ago

taylor_swift_dance