Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions Gemfile-master.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
GIT
remote: https://github.com/rack/rack.git
revision: b81080be0e5b3e9a794aa56609083b5d9dc90c3b
specs:
rack (1.2.1)

GIT
remote: https://github.com/rails/arel.git
revision: 2b27e653f7be7649f56b834543bcaf27e2b44c74
specs:
arel (2.0.7.beta.20110228092631)

GIT
remote: https://github.com/rails/rails.git
revision: 9772de8d459960cc114c5b214343b7ce08fea21c
specs:
actionmailer (3.1.0.beta)
actionpack (= 3.1.0.beta)
mail (~> 2.2.15)
actionpack (3.1.0.beta)
activemodel (= 3.1.0.beta)
activesupport (= 3.1.0.beta)
builder (~> 3.0.0)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-cache (~> 1.0.0)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.1.0.beta)
activesupport (= 3.1.0.beta)
bcrypt-ruby (~> 2.1.4)
builder (~> 3.0.0)
i18n (~> 0.5.0)
activerecord (3.1.0.beta)
activemodel (= 3.1.0.beta)
activesupport (= 3.1.0.beta)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.1.0.beta)
activemodel (= 3.1.0.beta)
activesupport (= 3.1.0.beta)
activesupport (3.1.0.beta)
rails (3.1.0.beta)
actionmailer (= 3.1.0.beta)
actionpack (= 3.1.0.beta)
activerecord (= 3.1.0.beta)
activeresource (= 3.1.0.beta)
activesupport (= 3.1.0.beta)
bundler (~> 1.0)
railties (= 3.1.0.beta)
railties (3.1.0.beta)
actionpack (= 3.1.0.beta)
activesupport (= 3.1.0.beta)
rake (>= 0.8.7)
thor (~> 0.14.4)

PATH
remote: /home/hugolnx/programacao/projetos/ruby/open_sources/rspec-dev/repos/rspec
specs:
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)

PATH
remote: /home/hugolnx/programacao/projetos/ruby/open_sources/rspec-dev/repos/rspec-core
specs:
rspec-core (2.5.1)

PATH
remote: /home/hugolnx/programacao/projetos/ruby/open_sources/rspec-dev/repos/rspec-expectations
specs:
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)

PATH
remote: /home/hugolnx/programacao/projetos/ruby/open_sources/rspec-dev/repos/rspec-mocks
specs:
rspec-mocks (2.5.0)

PATH
remote: .
specs:
rspec-rails (2.5.0)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.5.0)

GEM
remote: http://rubygems.org/
specs:
ZenTest (4.4.2)
abstract (1.0.0)
archive-tar-minitar (0.5.2)
aruba (0.2.2)
bcrypt-ruby (2.1.4)
builder (3.0.0)
columnize (0.3.2)
configuration (1.2.0)
cucumber (0.10.0)
builder (>= 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.3.2)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
gherkin (2.3.5)
json (>= 1.4.6)
growl (1.0.3)
guard (0.3.0)
open_gem (~> 1.4.2)
thor (~> 0.14.6)
guard-rspec (0.1.9)
guard (>= 0.2.2)
i18n (0.5.0)
json (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
nokogiri (1.4.4)
open_gem (1.4.2)
launchy (~> 0.3.5)
polyglot (0.3.1)
rack-cache (1.0)
rack (>= 0.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rake (0.8.7)
rb-fsevent (0.3.10)
rcov (0.9.9)
relish (0.2.0)
archive-tar-minitar (~> 0.5.2)
json (~> 1.4.6)
rest-client (~> 1.6.1)
rest-client (1.6.1)
mime-types (>= 1.16)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
ruby-debug-base19 (0.11.24)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby-prof (0.9.2)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
term-ansicolor (1.0.5)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.25)
webrat (0.7.2)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)

PLATFORMS
ruby

DEPENDENCIES
ZenTest (~> 4.4.2)
arel!
aruba (= 0.2.2)
cucumber (= 0.10.0)
growl (= 1.0.3)
guard-rspec (= 0.1.9)
jruby-openssl
rack!
rails!
rake (= 0.8.7)
rb-fsevent (~> 0.3.9)
rcov (= 0.9.9)
relish (= 0.2.0)
rspec!
rspec-core!
rspec-expectations!
rspec-mocks!
rspec-rails!
ruby-debug
ruby-debug19 (~> 0.11.6)
ruby-prof (~> 0.9.2)
sqlite3-ruby
webrat (= 0.7.2)
15 changes: 15 additions & 0 deletions features/routing_specs/route_to_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ Feature: route_to matcher

{ :get => "/" }.should route_to(:controller => "welcome")

Scenario: passing route spec with describe title request pair
Given a file named "spec/routing/widgets_routing_spec.rb" with:
"""
require "spec_helper"

describe "routes for Widgets" do
describe get("/widgets") do
it {should route_to "widgets#index" }
end
end
"""

When I run "rspec spec/routing/widgets_routing_spec.rb"
Then the examples should all pass

Scenario: passing route spec with shortcut syntax
Given a file named "spec/routing/widgets_routing_spec.rb" with:
"""
Expand Down
3 changes: 3 additions & 0 deletions lib/rspec/rails/example/routing_example_group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "action_dispatch/testing/assertions/routing"
require 'rspec/rails/example/routing_example_group/describe_with_request_pair_support'

module RSpec::Rails
module RoutingExampleGroup
Expand All @@ -19,6 +20,8 @@ def method_missing(m, *args, &block)
end

included do
extend RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
extend DescribeWithRequestPairSupport
metadata[:type] = :routing

before do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rspec/rails/example/routing_example_group/describe_with_request_pair_support/request_pair'

module RSpec::Rails
module RoutingExampleGroup
module DescribeWithRequestPairSupport
def set_it_up(*args)
describe_title = args.first
if describe_title.is_a?(Hash) && ['get','post','put','delete'].include?(describe_title.keys.first.to_s.downcase)
describe_title.instance_eval{extend RSpec::Rails::Ruby::Hash}
describe_title.keep_first!
request_pair = RequestPair.new :http_method => describe_title.key,
:path => describe_title.value
args[0] = request_pair.to_s
superclass_metadata[:example_group].store(:describes, request_pair.to_hash)
end
super(*args)
end
end
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module RSpec::Rails
module RoutingExampleGroup
module DescribeWithRequestPairSupport
class RequestPair
def initialize(args={})
@method = args[:http_method]
@path = args[:path]
end

def to_hash
{@method => @path}
end

def to_s
"#{@method.to_s.upcase} #{@path}"
end
end
end
end
end

1 change: 1 addition & 0 deletions lib/rspec/rails/extensions.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require 'rspec/rails/extensions/active_record/base'
require 'rspec/rails/extensions/ruby/hash'
Binary file added lib/rspec/rails/extensions/ruby/.hash.rb.swo
Binary file not shown.
Binary file added lib/rspec/rails/extensions/ruby/.hash.rb.swp
Binary file not shown.
18 changes: 18 additions & 0 deletions lib/rspec/rails/extensions/ruby/hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module RSpec::Rails
module Ruby
module Hash
def key
self.keys.first
end

def value
self.values.first
end

def keep_first!
pair = self.first
self.replace(pair.first => pair.last)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

module RSpec::Rails::RoutingExampleGroup
module DescribeWithRequestPairSupport
describe RequestPair do
before :each do
@request_pair = RequestPair.new :http_method => :get,
:path => "/"
end

it 'should became a hash' do
@request_pair.to_hash.should be == {:get => "/"}
end

it 'should became a string' do
@request_pair.to_s.should be == "GET /"
end
end
end
end
20 changes: 20 additions & 0 deletions spec/rspec/rails/example/routing_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,25 @@ module RSpec::Rails
example.foo_path.should == "foo"
end
end

context "use route helpers" do
it "should get 'path' return {:get => 'path'}" do
group = RSpec::Core::ExampleGroup.describe do
include RoutingExampleGroup
end
group.get("path").should be == {:get => "path"}
end
end

context "use request pair in describe title" do
it "should request pair be the subject" do
group = RSpec::Core::ExampleGroup.describe do
include RoutingExampleGroup
end
inner_group = group.describe ({:get => "path"})
inner_group.new.subject.should be == {:get => "path"}
end
end

end
end
23 changes: 23 additions & 0 deletions spec/rspec/rails/extensions/ruby/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

module RSpec::Rails::Ruby
describe "Hash" do
before :each do
@hash = {:name => "nobody", :age => 0}
@hash.instance_eval{extend Hash}
end

it 'should return the first element' do
@hash.keep_first!
@hash.should be == {:name => "nobody"}
end

it 'should return the key of the first element' do
@hash.key.should be == :name
end

it 'should return the value of the first element' do
@hash.value.should be == "nobody"
end
end
end