stubs

rspec view stubs and partials

不打扰是莪最后的温柔 提交于 2020-01-02 05:43:07
问题 I'm testing a view with RSpec (2.12 on Rails 3.2.8). I'm using CanCan to conditionally display certain elements on a page. This requires a controller method 'current_user'. In some of my specs I've been able to stub out current_user, eg. controller.stub(:current_user).and_return(etc) or view.stub.etc . This works for some of my specs. But I've got a couple where it's not working and I don't understand why. The two specs where it's not working test a view, which calls down into a partial, and

Oauth Model Concern Test Coverage Stubs

允我心安 提交于 2019-12-31 05:40:34
问题 I am trying to figure out the best way to reach 100% test coverage on this class. I have outlined my full spec and I am hoping someone can point me in the right direction. My assumption is stubbing the Oauth2 request would do this, but I can not seem to make that work. I'm using Rails 4. Spec RSpec.describe 'AppOmniAuthentication', type: :concern do let(:klass) { User } let(:user) { create(:user) } let(:user_oauth_json_response) do unfiltered_oauth_packet = load_json_fixture('app_omni

issue with stubs and rspec old syntax

こ雲淡風輕ζ 提交于 2019-12-24 04:54:08
问题 I am writing some code and using rspec but received a warning that the syntax is old and i can't quite figure out how i should be writing it instead? it "should calculate the value correctly" do mock_cards = [Card.new(:clubs, 5), Card.new(:diamonds, 10)] hand = Hand.new hand.stub(:cards) { cards } #stub out cards and have it return cards expect(hand.value).to eq (15) end The error message is as follows: Using stub from rspec-mocks' old :should syntax without explicitly enabling the syntax is

Microsoft Fakes (Shims and / or Stubs) on a c# method with SQL code

╄→гoц情女王★ 提交于 2019-12-23 17:15:20
问题 I am trying to learn a bit more about Unit Testing, using out-of-the-box functionality (i believe it is MSTest.exe), and Microsoft Fakes (stubs and Shims). I am using Visual Studio 2012 Ultimate and .Net 4.5 Framework. Given the following code that calls a stored procedure (SQL Server) which returns a single output value (for simplicity): public string GetSomeDatabaseValue() { string someValue = String.Empty; SqlParameter paramater = new SqlParameter(); paramater.ParameterName = "

stub_image showing on universal image loader in recyclerview

廉价感情. 提交于 2019-12-11 12:53:33
问题 I have implement universal image loader for showing images in recyclerview. it showing stub_image. Code contain One fragment and its adapter, its working properly before i added universal-image-loader. Here is the code: Fragment.Class public class FourthFragment extends Fragment { private DisplayImageOptions options; ImageLoader imageLoader; RecyclerView rv; RecyclerView.LayoutManager mLayoutManager; RecyclerView.Adapter mAdapter; String[] str = {"one","two","three","four"}; int[] img = {R

How to create JAXWS web service server skeletons from wsdl ( not in IDE)

我们两清 提交于 2019-12-08 00:49:41
问题 i can't find any where how to create web service from server skeletons ( java pojo's )from wsdl using JAXWS. The only tutorials I see are using automated wizard in NetBeans and and axis2 in eclipse. Can someone please give me hints on how to generate server side classes from given wsdl? Thanks UPADATE: I just need to do : wsimport.bat -Xendorsed SOAP.WSDL and it creates the artifacts. But now how do I implement it in the server ? 回答1: In addition to client side classes, wsimport also

How to create JAXWS web service server skeletons from wsdl ( not in IDE)

﹥>﹥吖頭↗ 提交于 2019-12-06 09:26:48
i can't find any where how to create web service from server skeletons ( java pojo's )from wsdl using JAXWS. The only tutorials I see are using automated wizard in NetBeans and and axis2 in eclipse. Can someone please give me hints on how to generate server side classes from given wsdl? Thanks UPADATE: I just need to do : wsimport.bat -Xendorsed SOAP.WSDL and it creates the artifacts. But now how do I implement it in the server ? In addition to client side classes, wsimport also generates a SEI (Service Endpoint Interface). All you need to do is creating an implementation for that. Then it

Python's StringIO doesn't do well with `with` statements

五迷三道 提交于 2019-12-04 10:04:33
问题 I need to stub tempfile and StringIO seemed perfect. Only that all this fails in an omission: In [1]: from StringIO import StringIO In [2]: with StringIO("foo") as f: f.read() --> AttributeError: StringIO instance has no attribute '__exit__' What's the usual way to provide canned info instead of reading files with nondeterministic content? 回答1: The StringIO module predates the with statement. Since StringIO has been removed in Python 3 anyways, you can just use its replacement, io.BytesIO: >>

Python's StringIO doesn't do well with `with` statements

穿精又带淫゛_ 提交于 2019-12-03 05:49:31
I need to stub tempfile and StringIO seemed perfect. Only that all this fails in an omission: In [1]: from StringIO import StringIO In [2]: with StringIO("foo") as f: f.read() --> AttributeError: StringIO instance has no attribute '__exit__' What's the usual way to provide canned info instead of reading files with nondeterministic content? The StringIO module predates the with statement. Since StringIO has been removed in Python 3 anyways, you can just use its replacement, io.BytesIO : >>> import io >>> with io.BytesIO(b"foo") as f: f.read() b'foo' this monkeypatch works for me in python2.

Oauth Model Concern Test Coverage Stubs

天涯浪子 提交于 2019-12-02 11:32:46
I am trying to figure out the best way to reach 100% test coverage on this class. I have outlined my full spec and I am hoping someone can point me in the right direction. My assumption is stubbing the Oauth2 request would do this, but I can not seem to make that work. I'm using Rails 4. Spec RSpec.describe 'AppOmniAuthentication', type: :concern do let(:klass) { User } let(:user) { create(:user) } let(:user_oauth_json_response) do unfiltered_oauth_packet = load_json_fixture('app_omni_authentication_spec') unfiltered_oauth_packet['provider'] = unfiltered_oauth_packet['provider'].to_sym