spec/unit/router_spec.rb in restfulness-0.3.2 vs spec/unit/router_spec.rb in restfulness-0.3.3

- old
+ new

@@ -19,64 +19,64 @@ describe "#initialize" do it "should prepare routes" do obj = klass.new - obj.routes.should eql([]) + expect(obj.routes).to eql([]) end it "should prepare routes with instance eval block" do obj = klass.new do @foo = 'bar' end - obj.instance_variable_get(:@foo).should eql('bar') + expect(obj.instance_variable_get(:@foo)).to eql('bar') end end describe "#add" do it "should add route to object" do obj = klass.new obj.add 'projects', resource - obj.routes.length.should eql(1) + expect(obj.routes.length).to eql(1) route = obj.routes.first - route.should be_a(Restfulness::Route) - route.path.should eql(['projects']) + expect(route).to be_a(Restfulness::Route) + expect(route.path).to eql(['projects']) end it "should accept block as scope" do obj = klass.new obj.add 'project', RouterResource do add 'examples', SecondRouterResource end route = obj.routes.first - route.resource.should eql(SecondRouterResource) - route.path.should eql(['project', 'examples']) + expect(route.resource).to eql(SecondRouterResource) + expect(route.path).to eql(['project', 'examples']) route = obj.routes.last - route.resource.should eql(RouterResource) - route.path.should eql(['project']) + expect(route.resource).to eql(RouterResource) + expect(route.path).to eql(['project']) end end describe "#scope" do it "should append to the current_scope attribute in block and reset" do obj = klass.new subscope = nil # Can't use rspec inside instance eval! obj.scope 'api' do subscope = current_scope end - subscope.should eql(['api']) - obj.current_scope.should eql([]) + expect(subscope).to eql(['api']) + expect(obj.current_scope).to eql([]) end it "should add scope properties to add call" do obj = klass.new res = resource obj.scope 'api' do add 'projects', res end route = obj.routes.first - route.path.should eql(['api', 'projects']) + expect(route.path).to eql(['api', 'projects']) end it "should allow for scopes within scopes" do obj = klass.new res = resource @@ -87,15 +87,15 @@ add 'active', res subsubscope = current_scope end subscope = current_scope end - subsubscope.should eql(['api', 'projects']) - subscope.should eql(['api']) - obj.current_scope.should eql([]) + expect(subsubscope).to eql(['api', 'projects']) + expect(subscope).to eql(['api']) + expect(obj.current_scope).to eql([]) route = obj.routes.first - route.path.should eql(['api', 'projects', 'active']) + expect(route.path).to eql(['api', 'projects', 'active']) end end describe "#route_for" do let :obj do @@ -108,50 +108,50 @@ end end it "should determine the route for a simple path" do route = obj.route_for("/projects") - route.should_not be_nil - route.path.should eql(['projects']) + expect(route).not_to be_nil + expect(route.path).to eql(['projects']) end it "should determine the route for a simple path with id" do route = obj.route_for("/projects") - route.should_not be_nil - route.path.should eql(['projects']) + expect(route).not_to be_nil + expect(route.path).to eql(['projects']) end it "should determine the route for a simple path with id and end /" do route = obj.route_for("/projects/12345/") - route.should_not be_nil - route.path.should eql(['projects']) + expect(route).not_to be_nil + expect(route.path).to eql(['projects']) end it "should determine the route for a simple path with end /" do route = obj.route_for("/projects/") - route.should_not be_nil - route.path.should eql(['projects']) + expect(route).not_to be_nil + expect(route.path).to eql(['projects']) end it "should determine route for more complex path" do route = obj.route_for("/project/1235/status/1234") - route.should_not be_nil - route.path.should eql(['project', :project_id, 'status']) + expect(route).not_to be_nil + expect(route.path).to eql(['project', :project_id, 'status']) end it "should return nil if not matched" do route = obj.route_for("/projects/1235/statuses/") - route.should be_nil + expect(route).to be_nil end it "should match empty path" do route = obj.route_for("/") - route.path.should eql([]) + expect(route.path).to eql([]) end it "should match path with single parameter" do route = obj.route_for("/something") - route.path.should eql([:page]) + expect(route.path).to eql([:page]) end end end