Skip to content

Commit

Permalink
- Fixed a bug where if you had a WCF service with lowercase entities …
Browse files Browse the repository at this point in the history
…(reported by Klaus Rohe)

- Added a rake task for running RSpec and Cucumber tests.
  • Loading branch information
visoft committed Aug 25, 2011
1 parent 1b7c75e commit 2f15c69
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 7 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--color
15 changes: 15 additions & 0 deletions Rakefile
@@ -1,10 +1,25 @@
require 'rake/rdoctask'
require 'bundler'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'

Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb")
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]
2 changes: 1 addition & 1 deletion lib/ruby_odata/class_builder.rb
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions ruby_odata.gemspec
Expand Up @@ -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")
Expand Down
13 changes: 13 additions & 0 deletions 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
20 changes: 20 additions & 0 deletions 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>
27 changes: 27 additions & 0 deletions spec/service_spec.rb
Expand Up @@ -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

0 comments on commit 2f15c69

Please sign in to comment.