This file contains 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' | |
require 'spec/environments/mongoid' | |
require_unless_rails_loaded 'app/models/ability' | |
describe Ability do | |
let(:user) { mock(User) } | |
describe ".build" do |
This file contains 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
describe "#current_report" do | |
its(:current_report) { should be == report } | |
context "with a new" do | |
let(:new_report) { Report.make(state: new_report_state, project_date: new_report_date) } | |
before(:each) do | |
subject.reports << new_report | |
end |
This file contains 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 'bundler' | |
Bundler.setup | |
require 'mongoid' | |
require 'rspec/autorun' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("has_many_bug") | |
end | |
class Kid |
This file contains 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
describe Report::ReportStateMachine do | |
describe "state machine" do | |
describe "locking state machine" do | |
shared_examples_for "an unlocked report" do | |
it { should be_report_unlocked } | |
describe "updating the report" do | |
its(:can_update_content?) { should be_false } | |
its(:can_check_out_report?) { should be_true } | |
its(:can_check_in_report?) { should be_false } |
This file contains 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' | |
require 'spec/environments/mongoid' | |
require 'spec/environments/capybara' | |
feature "Edit Report: Locking", js: true, full_backtrace: true, wip: true do | |
include Capybara::DSL | |
include AcceptanceDSL | |
before(:each) do |
This file contains 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
# Some of the tests for this fail, in a way that's surprising to Python users... | |
# Why? | |
class List | |
def initialize(*elements) | |
@elements = elements | |
@elements.each do |e| | |
return if e.nil? | |
end | |
end |
This file contains 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 'rack/lobster' | |
module App | |
class Router | |
def initialize | |
@app = Rack::Mount::RouteSet.new do |set| | |
set.add_route ->(*args) { Rack::Lobster.new.call(*args) }, { :request_method => 'GET', :path_info => %r{^/lobster$} }, {}, :lobster | |
end | |
end |
This file contains 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 Class | |
def define_class_typed_method(name, types, &block) | |
define_method(name) do |args| | |
args.each do |(arg, value)| | |
raise ArgumentError.new("Wrong class for #{arg}") unless value.is_a?(types[arg]) | |
end | |
block.call(args) | |
end | |
end | |
end |
This file contains 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 Class | |
def define_class_typed_method(name, types, &block) | |
define_method(name) do |args| | |
args.each do |(arg, value)| | |
raise ArgumentError.new("Wrong class for #{arg}") unless value.is_a?(types[arg]) | |
end | |
block.call(args) | |
end | |
end | |
end |
This file contains 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 "satisfies: The Content-Length MUST be specified and correct according to the guidelines and rules laid out in Section 4.4, 'Message Length', of the HTTP specification" do | |
ascii_data = "This > O < is a snowman" | |
utf8_data = "This > ☃ < is a snowman" | |
post_request(method: ascii_data) | |
content_length = nil | |
request.with { |actual_request| | |
(content_length = actual_request.headers["Content-Length"].to_i) > 0 | |
}.should have_been_requested |