This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Bar | |
| def self.included(clazz) | |
| clazz.extend Baz | |
| end | |
| module Baz | |
| def bar | |
| puts 'bar' | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ rspec spec/requests/homepage_spec.rb | |
| F | |
| Failures: | |
| 1) The homepage displays recent posts from Hacker News | |
| Failure/Error: visit '/' | |
| NoMethodError: | |
| undefined method `recent' for HN::Post:Class | |
| # ./app/models/post.rb:3:in `recent' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe 'The homepage', :vcr do | |
| before do | |
| visit '/' | |
| end | |
| it 'displays recent posts from Hacker News' do | |
| hacker_news_links = all '#hn .post a' | |
| hacker_news_links.should_not be_empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scenario Outline: Make an API request from a different domain | |
| When I ask if a <http-method> request to <api-path> from a different domain is supported | |
| Then I should receive a successful response | |
| And the <http-method> request should be allowed | |
| Scenarios: Available APIs | |
| | http-method | api-path | | |
| | GET | /api/v1/samples | | |
| | GET | /api/v1/samples/1 | | |
| | PUT | /api/v1/samples/1 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl \ | |
| --verbose \ | |
| --request OPTIONS \ | |
| http://localhost:3000/users/1.json \ | |
| --header 'Origin: http://server1.example.com' \ | |
| --header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \ | |
| --header 'Access-Control-Request-Method: PUT' | |
| * About to connect() to localhost port 3000 (#0) | |
| * Trying ::1... Connection refused | |
| * Trying 127.0.0.1... connected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| function parseUser (json) { | |
| var user = new User(json) | |
| // do something with the user | |
| } | |
| </script> | |
| <script type="text/javascript" | |
| src="http://server2.example.com/users/1.js?callback=parseUser"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In order to reference published articles in other applications | |
| As an API client | |
| I want to be able to request articles via a JSON API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cucumber features/api/v1/articles.feature | |
| Using the default profile... | |
| .... | |
| 1 scenario (1 passed) | |
| 4 steps (4 passed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ rspec spec/models/article_spec.rb | |
| . | |
| Finished in 0.10455 seconds | |
| 1 example, 0 failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Article < ActiveRecord::Base | |
| def self.published | |
| where :published => true | |
| end | |
| end |