Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I used Jasmine (supposedly inspired by Rspec) for unit tests for one of my Javascript projects and loved it. If Test::Unit wasn't simple and Good Enough I'd have spent an hour or two on learning to use Rspec.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true
I've gone over to Rspec, with Rspec-given, Shoulda, and FactoryGirl.

When I test. That's still my greatest weakness as a programmer.

mmachine
Jan 5, 2006

quote:

What order are they coming in over the wire, before Rails has a chance to mangle it?

According to the post params sniffed in the log, they come over in a proper integer order. So say a user enter a few records in this order: 23, 56, 24, 89. The post data for params[:foo_bar] that I sniff in the logs is sorted already as [23,24,56,89].

I suppose now I should look closer at the JS library I'm using for those form inputs? Seems really weird that RoR would auto-sort params -- but maybe it does? I mean, would it auto sort a set of string params by first character if I was posting strings instead of integers? Sounds kind of nutty.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Form parameters are sent in the order they appear in the document. Double check that ordering.

If that looks ok to you, look next at the raw POST data. You should see the same ordering there.

Smol fucked around with this message at 16:38 on Aug 18, 2013

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Fillerbunny posted:

I just came from the ChicagoRuby meetup where a couple guys from Hashrocket gave demos/presentations if how to use Rspec and Cucumber. Obviously they have different applications, especially where Cucumber is geared toward the front end. I'm definitely going to be looking into using it on my next project.

That said, I'm not sure it's an either/or situation with those. They're different tools that accomplish different things. Capybara was shown as one piece of it as well, but was not the focus of either talk.

Edit: I should mention that I was new to all of these tools going into the meetup. I knew about Rspec, but had never actually used it for anything.
Cucumber owns, you can basically write a to-do list that doubles as integration tests. I never use it in isolation though, because I still like having Test::Unit (well, as implemented by minitest) on my models and controllers (if the controllers do anything fancier than just calling a model method or two).

Capybara is a great way to drive a web browser and scrape a web page. I ran the YOSPOS RIM death pool with it: https://www.dropbox.com/sh/2s2vaccgc6nnb2g/ZjDk3OSXn9

I like and respect the Hashrocket guys (their Chicago office is nice, but their Jacksonville Beach office is amazing, shame it's in Jacksonville) but rspec is dumb bullshit that goes too loving far:

Deus Rex
Mar 5, 2005

RSpec is fine if you throw the should syntax in the trash where it belongs.

Also for more context:

Deus Rex fucked around with this message at 09:47 on Aug 19, 2013

prom candy
Dec 16, 2005

Only I may dance

Deus Rex posted:

RSpec is fine if you throw the should syntax in the trash where it belongs.

How do you write your specs? I find I have to fall back on the default it "should do something" do format when I'm relying on specs that make use of Whatever.should_receive. Am I thinking in the wrong order?

soullessshoe
Nov 6, 2011
with rspec, try and get in the habit of using

Ruby code:
expect(object).to eq("something")
see https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers and also https://github.com/rspec/rspec-expectations/blob/master/Should.md

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Deus Rex posted:

RSpec is fine if you throw the should syntax in the trash where it belongs.

And that's kind of my other beef with rspec: you have to do maintenance because the syntax du jour changes all the loving time.
code:
*****************************************************************
DEPRECATION WARNING: you are using deprecated behaviour that will
be removed from rspec-3.

* `expect { }.should_not` is deprecated.
* please use `expect { }.to_not` instead.
*****************************************************************
My oldest Test::Unit code doesn't complain about outdated syntax, even though the implementation has moved from test-unit to minitest.

Fillerbunny
Jul 25, 2002

so confused.
While we're on the subject, one of the tests highlighted during the Hashrocket dude's demo was meant to simulate mitigating DDOS attacks, and used the following:

Ruby code:
  Timeout::timeout(0.1, ArgumentError) do
    #some lengthy thing, like 999999999999**999999
  end
I can't for the life of me get this to raise the ArgumentError. What am I missing? I might have asked during the talk, but I couldn't follow along, thanks to Rspec and RVM being all jacked up (I've since got that sorted out).

prom candy
Dec 16, 2005

Only I may dance

soullessshoe posted:

with rspec, try and get in the habit of using

Ruby code:
expect(object).to eq("something")
see https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers and also https://github.com/rspec/rspec-expectations/blob/master/Should.md

A lot of my specs just revolve around making sure that messages get passed to other objects. I use should_receive a lot. Can you give me an example of how I could rewrite this spec?

code:
class Balloon
  attr_accessor :state 

  def initialize(capacity = 3)
    @capacity = capacity
    @fillAmount = 0
    @state = 'normal'
  end

  def inflate
    @fillAmount += 1
    @state = 'popped' if @fillAmount > @capacity
  end
end

class BalloonPopper
  def initialize(balloon)
    @balloon = balloon
  end

  def pop
    while balloon.state != 'popped'
      balloon.inflate
    end
  end
end

# BalloonPopper spec
describe BalloonPopper
  let(:balloon) { Balloon.new(3) }
  let(:popper) { BalloonPopper.new(balloon) }
  
  it "should pop the balloon" do
    balloon.should_receive(:inflate).exactly(3).times
    popper.pop
  end
end
The key to this test is that I don't really want to test any of the behaviour of Balloon, I just want to test that BalloonPopper is sending the right message. I haven't been able to figure out how to do that with cleaner syntax.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I really like the idea behind the describe - it "should asgsgfsdg" do syntax. So that instead of several Test::Unit cases like

code:
test "user without valid password should receive validation message" do
end

test "user without valid password should be invalid" do
end
I can have cases like

code:
describe "user without valid password"
  it "should receive validation message" do
  end

  it "should be invalid" do
  end
end
It saves typing and just looks better to me.

manero
Jan 30, 2006

prom candy posted:

A lot of my specs just revolve around making sure that messages get passed to other objects. I use should_receive a lot. Can you give me an example of how I could rewrite this spec?

I'd start by not checking balloon.state. Write a method on balloon called popped? (or inflated?) that checks the state. Then have your BalloonPopper call that method.

prom candy
Dec 16, 2005

Only I may dance
I'm not really looking for a critique on the example code I wrote to explain my spec situation! I'm not actually writing an interface for balloons.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

prom candy posted:

code:
  it "should pop the balloon" do
    balloon.should_receive(:inflate).exactly(3).times
    popper.pop
  end
The key to this test is that I don't really want to test any of the behaviour of Balloon, I just want to test that BalloonPopper is sending the right message. I haven't been able to figure out how to do that with cleaner syntax.

https://www.relishapp.com/rspec/rspec-mocks/v/2-14/docs/message-expectations/expect-message-using-expect

Ruby code:
  it "should pop the balloon" do
    expect(balloon).to receive(:inflate).exactly(3).times
    popper.pop
  end
You'll notice this syntax feels like a second-class citizen and is hidden away even in rspec-mocks.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
The main thing stopping me from using rspec is how bad the documentation is. It's not so much better than Test::Unit that I'm going to go out of my way to read when I could be learning something else.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
I really need to give cucumber a shot. The regex thing really turns me off, (not because I cant write regexes), it just seems like such an odd way of going about things. And if you're not really consistent with your syntax I expect it's super confusing to write.

Is cucumber particularly well suited to anything, like view testing or integration testing?

DONT THREAD ON ME fucked around with this message at 20:05 on Aug 19, 2013

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

chumpchous posted:

Is cucumber particularly well suited to anything, like view testing or integration testing?

It's very very high level integration testing: I use it as a to-do list that checks itself off. I've heard that you should write scenarios in a way that you could use the same set of scenarios for HTML, iOS, and Android versions of an application.

code:
Given I am at the login screen
When I fill in my credentials
Then I should see the dashboard

Given I am at the reply screen
When I make a post
Then I should see my post in the thread

kayakyakr
Feb 16, 2004

Kayak is true

Cocoa Crispies posted:

It's very very high level integration testing: I use it as a to-do list that checks itself off. I've heard that you should write scenarios in a way that you could use the same set of scenarios for HTML, iOS, and Android versions of an application.

code:
Given I am at the login screen
When I fill in my credentials
Then I should see the dashboard

Given I am at the reply screen
When I make a post
Then I should see my post in the thread

When I was writing heavy cucumber tests, I was going with the style of writing very generic, basic commands similar to what you have written and then making the step definitions more complex.

My biggest problem with cucumber is that it's an awful idea to use for testing a heavy javascript front end. It can do it, but good lord it takes a long time. Our (moderately complex) web app took in the order of an hour to run the test suite.

Granted a lot of that could have been the terrible decision to use ExtJS.

prom candy
Dec 16, 2005

Only I may dance

Cocoa Crispies posted:

https://www.relishapp.com/rspec/rspec-mocks/v/2-14/docs/message-expectations/expect-message-using-expect

Ruby code:
  it "should pop the balloon" do
    expect(balloon).to receive(:inflate).exactly(3).times
    popper.pop
  end
You'll notice this syntax feels like a second-class citizen and is hidden away even in rspec-mocks.

And why is this preferable to the should syntax?

aunt jenkins
Jan 12, 2001

So I wrote and published my first gem, based on a need for a personal project. Basically, it allows you to include custom model methods in to_json/to_xml using a simple DSL instead of having to deal with overriding the methods yourself. It's kind of small and silly, but I didn't like how ugly it was to override the methods myself, plus I've been looking for a reason to write a gem that might actually get some use for awhile.

Github link

Would love to get any feedback/code critiques to learn from. I already learned a ton writing it :)

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

prom candy posted:

And why is this preferable to the should syntax?

Some people don't like rspec adding Object#should and Object#should_not. Personally, I don't care.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Cocoa Crispies posted:

It's very very high level integration testing: I use it as a to-do list that checks itself off. I've heard that you should write scenarios in a way that you could use the same set of scenarios for HTML, iOS, and Android versions of an application.

code:
Given I am at the login screen
When I fill in my credentials
Then I should see the dashboard

Given I am at the reply screen
When I make a post
Then I should see my post in the thread

Okay that makes sense to me. This is kind of how I think of view testing (which I guess implicitly is integration testing), and I really hate doing it in Rspec/Capybara, so I'll give it a shot.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

kayakyakr posted:

My biggest problem with cucumber is that it's an awful idea to use for testing a heavy javascript front end. It can do it, but good lord it takes a long time. Our (moderately complex) web app took in the order of an hour to run the test suite.

Cucumber is awful once you get past the high-level happy case; that's when you want to consider something like Jasmine or Evergreen to test the JS independently of the Rails app, or use CI like Jenkins to move the slow tests out of your synchronous workflow.

chumpchous posted:

Okay that makes sense to me. This is kind of how I think of view testing (which I guess implicitly is integration testing), and I really hate doing it in Rspec/Capybara, so I'll give it a shot.
View testing is overrated unless it isn't.

Siguy
Sep 15, 2010

10.0 10.0 10.0 10.0 10.0
It's serendipity that the thread turned to Cucumber, Rspec and TDD/BDD because I just finished reading The Cucumber Book.

I am almost always a solo developer, so Cucumber's business jargon about stakeholders and team agreement really bugs me. It feels like silly MBA talk.

But I'm giving Cucumber a try because I want to see if it can encourage me to do actual test-driven development instead of my usual habit of writing a couple tests, getting distracted by something in the app, writing half the app, then remembering I was supposed to be testing things.

I'm using the Aruba gem with Cucumber on a small command line app I've been meaning to write. The gem provides baked in step definitions for testing command line apps, and it's actually pretty neat. It turns Cucumber into a magic test machine that automatically turns plain English like "When I run blah command, then the output should be blah" into working tests.

Molten Llama
Sep 20, 2006

Siguy posted:

Cucumber's business jargon about stakeholders and team agreement really bugs me. It feels like silly MBA talk.

It is silly MBA talk. Stakeholders that read or write specs in a stilted not-quite-English DSL exist only in the same universe as badass hair metal unicorns.

Between the regex matching and the central conceit of interested and/or competent stakeholders, I can't shake the feeling Cucumber is a prank gone too far. poo poo, your terminal has to be 165 characters wide to read the drat cucumber --help output.

Molten Llama fucked around with this message at 07:26 on Aug 20, 2013

Deus Rex
Mar 5, 2005

prom candy posted:

And why is this preferable to the should syntax?

For one thing, monkey patching is terrible and there's no excuse for a test suite to make extensive use of it. Just as importantly, it's impossible to test proxy objects with the should syntax. http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Monkey patching is all right if you can limit the scope, which is what refinements in 2.x try do. Unfortunately, the current implementation is quite problematic (especially for alternate ruby implementations).

That said, they're much more useful in statically typed languages, where its easier to see where the added methods come from and where the compiler can and will do a lot of sanity checks about their use.

Smol fucked around with this message at 16:52 on Aug 20, 2013

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
I messed with cucumber pretty hard last night and I take back all of the bad things I ever said.

Peristalsis
Apr 5, 2004
Move along.
I have three questions, but there's a wall o' text first.

Background:
I have to replace some existing apps that nobody likes with a Ruby on Rails web app. This app will have a back end API for other processes to send in data without going through the web pages. I'm vaguely aware of web services, and figured that would be the way to set up the API, assuming that it can be handled from the same rails server that is simultaneously handling the web app. I don't care whether I use a SOAP web service or a restful one (not entirely comfortable with the differences, but my requirements should be pretty simple database inserts and queries, so I imagine that can be done with either approach). I looked around, and it looks like the gems that let you plunk in web service functionality are old and not maintained, but that it's not supposed to be hard to do your own thing.

Current:
Working from this page, I made a GET route that can return just plain text in response to a request (which will probably be coming from curl commands in both R scripts and another Ruby script), and got a spot in my controller to render that text. I'll plan to use this to return completion codes and/or query results. I assume that setting up a post route will be similar, and that this is the way to return data to another process using the app.

My questions:
1) The requests might be quite large, involving insertion of several related and linked database rows, and will need to be parsed and processed before returning a completion code. I want to have the user pass in some XML string, or maybe a JSON construct (unless there's a better option), but I have no idea how to get that data into the controller. Should it just be a url parameter of some sort, or is there a better way to get this done?

Edit: I think I figured this one out -
code:
curl --data "xml=<input>...</input>" url
seems to do the trick, if I want to use XML input.

2) Is this the right way to go about this, or should I be looking at some more formal web service setup, even if it uses outdated code? Or some other way of setting up the API entirely?

3) Ultimately, I want to restrict use to approved people, so random weirdos can't just post data to our database for fun and profit. Is there a standard way to enforce something like that? I assume we don't just want login and password data coming through GET/POST requests.

Peristalsis fucked around with this message at 19:51 on Aug 20, 2013

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Siguy posted:

I am almost always a solo developer, so Cucumber's business jargon about stakeholders and team agreement really bugs me. It feels like silly MBA talk.

It's easy to get a non-technical stakeholder to sign off on scenarios that are written "properly." That's literally how Hashrocket runs their business, and why you see so many other consultancies using Cucumber.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Peristalsis posted:

My questions:
1) The requests might be quite large, involving insertion of several related and linked database rows, and will need to be parsed and processed before returning a completion code. I want to have the user pass in some XML string, or maybe a JSON construct (unless there's a better option), but I have no idea how to get that data into the controller. Should it just be a url parameter of some sort, or is there a better way to get this done?

2) Is this the right way to go about this, or should I be looking at some more formal web service setup, even if it uses outdated code? Or some other way of setting up the API entirely?

3) Ultimately, I want to restrict use to approved people, so random weirdos can't just post data to our database for fun and profit. Is there a standard way to enforce something like that? I assume we don't just want login and password data coming through GET/POST requests.

1) Put a number on "large." Kilobytes? Megabytes? Gigabytes?

2) Rails is a perfectly fine web service setup; Sinatra would work too, but past some complexity point I've always found myself wishing for Rails' structure.

3) The easy way is to use Basic auth and HTTPS so that login and password data coming through GET & POST requests isn't unencrypted on the wire.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

I have three questions, but there's a wall o' text first.

Background:
I have to replace some existing apps that nobody likes with a Ruby on Rails web app. This app will have a back end API for other processes to send in data without going through the web pages. I'm vaguely aware of web services, and figured that would be the way to set up the API, assuming that it can be handled from the same rails server that is simultaneously handling the web app. I don't care whether I use a SOAP web service or a restful one (not entirely comfortable with the differences, but my requirements should be pretty simple database inserts and queries, so I imagine that can be done with either approach). I looked around, and it looks like the gems that let you plunk in web service functionality are old and not maintained, but that it's not supposed to be hard to do your own thing.

Current:
Working from this page, I made a GET route that can return just plain text in response to a request (which will probably be coming from curl commands in both R scripts and another Ruby script), and got a spot in my controller to render that text. I'll plan to use this to return completion codes and/or query results. I assume that setting up a post route will be similar, and that this is the way to return data to another process using the app.

My questions:
1) The requests might be quite large, involving insertion of several related and linked database rows, and will need to be parsed and processed before returning a completion code. I want to have the user pass in some XML string, or maybe a JSON construct (unless there's a better option), but I have no idea how to get that data into the controller. Should it just be a url parameter of some sort, or is there a better way to get this done?

2) Is this the right way to go about this, or should I be looking at some more formal web service setup, even if it uses outdated code? Or some other way of setting up the API entirely?

3) Ultimately, I want to restrict use to approved people, so random weirdos can't just post data to our database for fun and profit. Is there a standard way to enforce something like that? I assume we don't just want login and password data coming through GET/POST requests.

I would suggest making a standard rails app but instead of (or in addition to) html.erb files, write json.jbuilder views. Makes a pretty good web service endpoint.

You can use basic auth + https and cookies to do that or you could implement an api key/secret thing. You might look into seeing if anyone else has implemented a jsonp renderer on top of jbuilder.

Peristalsis
Apr 5, 2004
Move along.

Cocoa Crispies posted:

1) Put a number on "large." Kilobytes? Megabytes? Gigabytes?
By "large", I just meant it could be a page or more of XML, and probably nobody would want to put all that text as a GET param in a URL. I noted above in an edit that I figured out how to make curl populate POST params, so hopefully that will be sufficient for this.

Cocoa Crispies posted:

2) Rails is a perfectly fine web service setup; Sinatra would work too, but past some complexity point I've always found myself wishing for Rails' structure.
Well, Rails is what we're using for the app, so I'll just stick with that as long as it's legit.

Cocoa Crispies posted:

3) The easy way is to use Basic auth and HTTPS so that login and password data coming through GET & POST requests isn't unencrypted on the wire.
Thanks! I'll look into how to use that.


kayakyakr posted:

I would suggest making a standard rails app but instead of (or in addition to) html.erb files, write json.jbuilder views. Makes a pretty good web service endpoint.

You can use basic auth + https and cookies to do that or you could implement an api key/secret thing. You might look into seeing if anyone else has implemented a jsonp renderer on top of jbuilder.
It's in addition to, but I'm inclined to stick with XML for the first version, if only because one of the people writing the client code isn't a programmer. He's more likely to be familiar with XML than with JSON. I'm also not sure he's going to like shoe-horning curl commands into his R scripts, but I guess he'll have to get over it. I found info on RCurl for him, so at least he shouldn't have to shell out to the OS to make it work. Eventually, I'd like to allow both approaches (XML and JSON), probably through different Rails routes.


Thanks for the help. I feel better knowing that I'm not way off base trying to do it this way, and that just rendering non-HTML stuff is a way to return info to the calling code.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Peristalsis posted:

By "large", I just meant it could be a page or more of XML, and probably nobody would want to put all that text as a GET param in a URL. I noted above in an edit that I figured out how to make curl populate POST params, so hopefully that will be sufficient for this.

Well, Rails is what we're using for the app, so I'll just stick with that as long as it's legit.

Thanks! I'll look into how to use that.

What's "a page or more?" I'm going to assume it's under a few megabytes and jamming it in a POST body (that's not wrapped in form encoding) should work.

Re: HTTP Basic auth: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

It's in addition to, but I'm inclined to stick with XML for the first version, if only because one of the people writing the client code isn't a programmer. He's more likely to be familiar with XML than with JSON. I'm also not sure he's going to like shoe-horning curl commands into his R scripts, but I guess he'll have to get over it. I found info on RCurl for him, so at least he shouldn't have to shell out to the OS to make it work. Eventually, I'd like to allow both approaches (XML and JSON), probably through different Rails routes.

For XML use Builder:
https://github.com/jimweirich/builder

Don't use routing tricks, use the format parameter. Example:
/users => html
/users.json => json
/users.xml => xml

Rails knows, via respond_to/respond_with which views to render for each. Support all of the API languages in one shot and be happy. Use standard form posts and url params for bringing data in.

Peristalsis
Apr 5, 2004
Move along.

Cocoa Crispies posted:

What's "a page or more?" I'm going to assume it's under a few megabytes and jamming it in a POST body (that's not wrapped in form encoding) should work.

Re: HTTP Basic auth: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
Thanks.

I don't know exactly what the xml input will look like yet. We're not passing around the library of congress, but I expect that a worst case could be a text file of hundreds of lines. If I had more info, I'd give it to you. I thought I remembered that POST params are not limited in size, so that this should be a reasonable thing to pass around via HTTP. In any case, it seemed like a bad thing to put in a URL parameter.


Is this a better option than Nokogiri? I've never really liked Nokogiri, but I thought it was sort of the de facto standard for XML and HTML parsing in Ruby.


kayakyakr posted:

Don't use routing tricks, use the format parameter. Example:
/users => html
/users.json => json
/users.xml => xml

Rails knows, via respond_to/respond_with which views to render for each. Support all of the API languages in one shot and be happy. Use standard form posts and url params for bringing data in.

Thanks, I'll look into that, too. I don't think there will be an HTML version of most of the web services routes, but I'll definitely want to combine the XML and JSON in one place.


Edit: I've probably been unclear - for the most part, I'll be reading the XML, and parsing it. I might pass back query results in XML, as well, but my main problem is passing the client's XML into my code and parsing it.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

Edit: I've probably been unclear - for the most part, I'll be reading the XML, and parsing it. I might pass back query results in XML, as well, but my main problem is passing the client's XML into my code and parsing it.

oh, gross.

Umm, I'm still a fan of taking in data in a standard post body rather than encoded as an XML field. But there is middleware for that:
https://github.com/rails/actionpack-xml_parser

Deus Rex
Mar 5, 2005

Anyone have thoughts on JBuilder vs. RABL for building a JSON API? I'm building an Angular app with a Rails backend and I don't think hacking around as_json is going to cut it as I've done in the past.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true

Deus Rex posted:

Anyone have thoughts on JBuilder vs. RABL for building a JSON API? I'm building an Angular app with a Rails backend and I don't think hacking around as_json is going to cut it as I've done in the past.

jbuilder is sorta the culmination of all of those that came before it. I really prefer jbuilder.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply