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
| def extract_highlights(highlighted_string) | |
| results = [] | |
| str = highlighted_string.dup | |
| while start_index = str.index("<em>") | |
| match_length = str[start_index..-1].index("</em>") - 4 | |
| results << [start_index, match_length] |
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
| it_behaves_like do | |
| a_serialized_user(response["user"], @expected_user) | |
| end | |
| --- | |
| shared_examples do | |
| a_serialized_user do |user_hash, user| | |
| it "should have a name" do | |
| expect(user_hash["name"]).to eq(user.name) |
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
| input: testabc:abc AND x:'test abc' OR y:123 AND testing123:'something else' | |
| expression | |
| / \ | |
| or <nil> | |
| / \________________ | |
| and \ | |
| / \ and | |
| testabc:abc x:'test abc' / \ | |
| y:123 testing123:'something else' |
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
| Random.unique do | |
| .. stuff that uses Random.rand, but will always be unique numbers (if its been used before, it'll generate another) ... | |
| 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
| Failure/Error: expect(helper.image_url("blah.jpg")).to eq("http://this-is-a-test.com/assets/blah.jpg") | |
| expected: "http://this-is-a-test.com/assets/blah.jpg" | |
| got: "http://test.hosthttp://this-is-a-test.com/assets/blah.jpg" | |
| (compared using ==) | |
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
| def screenshot! | |
| path = Tempfile.new(["ss", ".png"]).path | |
| save_screenshot(path, full: true) | |
| sleep 2 | |
| system("open #{path}") | |
| sleep 1 | |
| end | |
| def inspector! | |
| page.driver.debug |
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
| def merge_json_params | |
| body = request.body.read | |
| request.body.rewind | |
| params.merge!(ActiveSupport::JSON.decode(body)) if body != "" && request.format.json? | |
| 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
| class Campaign < ActiveRecord::Base | |
| has_many :daily_data | |
| attr_accessible :start_date | |
| def last_day_of_consecutive_daily_data | |
| # meh | |
| 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
| class Model | |
| def duration=(value) | |
| self.float_duration = process(value) | |
| end | |
| def duration | |
| unprocess(self.float_duration) | |
| 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
| checkToken: (token, cb) -> | |
| @sql.query "SELECT id FROM users WHERE login = ? AND cti_token = ?", [@login, token], (err, result) -> | |
| cb result.length == 1 |