Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Fixed a bug where if you had a WCF service with lowercase entities …

…(reported by Klaus Rohe)

- Added a rake task for running RSpec and Cucumber tests.
  • Loading branch information...
commit 2f15c696fa9d1dfbe3c1a8cd8284619b2c5bec5e 1 parent 1b7c75e
@visoft authored
View
1  .rspec
@@ -0,0 +1 @@
+--color
View
15 Rakefile
@@ -1,5 +1,7 @@
require 'rake/rdoctask'
require 'bundler'
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
@@ -7,4 +9,17 @@ Rake::RDocTask.new do |rd|
rd.rdoc_dir = 'doc'
end
+desc "Run specs"
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
+ # Put spec opts in a file named .rspec in root
+end
+
+desc "Run features"
+Cucumber::Rake::Task.new(:features) do |t|
+ t.cucumber_opts = "features --format progress"
+end
+
+
Bundler::GemHelper.install_tasks
+task :default => [:spec, :features]
View
2  lib/ruby_odata/class_builder.rb
@@ -8,7 +8,7 @@ class ClassBuilder
# - methods: The accessor methods to add to the class
# - nav_props: The accessor methods to add for navigation properties
def initialize(klass_name, methods, nav_props)
- @klass_name = klass_name
+ @klass_name = klass_name.camelcase
@methods = methods
@nav_props = nav_props
end
View
11 ruby_odata.gemspec
@@ -18,12 +18,11 @@ Gem::Specification.new do |s|
s.add_dependency('rest-client', '>= 1.5.1')
s.add_dependency('nokogiri', '>= 1.4.2')
- s.add_development_dependency('rspec')
- s.add_development_dependency('cucumber')
- s.add_development_dependency('sham')
- s.add_development_dependency('faker')
- s.add_development_dependency('machinist')
- s.add_development_dependency('webmock')
+ s.add_development_dependency('rspec', '~> 2.5.0')
+ s.add_development_dependency('cucumber', '~> 0.10.2')
+ s.add_development_dependency('faker', '~> 0.9.5')
+ s.add_development_dependency('machinist', '~> 1.0.6')
+ s.add_development_dependency('webmock', '~> 1.6.2')
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
View
13 spec/class_builder_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+module OData
+ describe ClassBuilder do
+ describe "#initialize" do
+ it "handles lowercase entities" do
+ klass = ClassBuilder.new 'product', [], []
+ result = klass.build
+ result.should == Product
+ end
+ end
+ end
+end
View
20 spec/fixtures/edmx_lowercase.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
+<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
+ <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
+ <Schema Namespace="acronymdbModel" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
+ <EntityType Name="acronym">
+ <Key>
+ <PropertyRef Name="aid" />
+ </Key>
+ <Property Name="aid" Type="Edm.Int32" Nullable="false" />
+ <Property Name="acrn" Type="Edm.String" Nullable="false" MaxLength="10" Unicode="true" FixedLength="true" />
+ <Property Name="meaning" Type="Edm.String" Nullable="false" MaxLength="500" Unicode="true" FixedLength="false" />
+ </EntityType>
+ </Schema>
+ <Schema Namespace="AcrnOData" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
+ <EntityContainer Name="acronymdbEntities" p7:LazyLoadingEnabled="true" m:IsDefaultEntityContainer="true" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
+ <EntitySet Name="acronyms" EntityType="acronymdbModel.acronym" />
+ </EntityContainer>
+ </Schema>
+ </edmx:DataServices>
+</edmx:Edmx>
View
27 spec/service_spec.rb
@@ -11,6 +11,33 @@ module OData
svc = OData::Service.new "http://test.com/test.svc/"
end
+ it "doesn't error with lowercase entities" do
+ # Required for the build_classes method
+ stub_request(:get, "http://test.com/test.svc/$metadata").
+ with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).
+ to_return(:status => 200, :body => File.new(File.expand_path("../fixtures/edmx_lowercase.xml", __FILE__)), :headers => {})
+
+ lambda { OData::Service.new "http://test.com/test.svc" }.should_not raise_error
+ end
+ end
+
+ describe "lowercase collections" do
+ before(:each) do
+ # Required for the build_classes method
+ stub_request(:get, "http://test.com/test.svc/$metadata").
+ with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).
+ to_return(:status => 200, :body => File.new(File.expand_path("../fixtures/edmx_lowercase.xml", __FILE__)), :headers => {})
+ end
+
+ it "should respond_to a lowercase collection" do
+ svc = OData::Service.new "http://test.com/test.svc"
+ svc.respond_to?('acronyms').should be_true
+ end
+
+ it "should allow a lowercase collections to be queried" do
+ svc = OData::Service.new "http://test.com/test.svc"
+ lambda { svc.send('acronyms') }.should_not raise_error
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.